新增工作汇报
This commit is contained in:
parent
0ec1c7b804
commit
9d3aefd4a7
@ -0,0 +1,102 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.controller.admin;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.property.entity.Property;
|
||||||
|
import cn.iocoder.yudao.module.workReport.entity.WorkReport;
|
||||||
|
import cn.iocoder.yudao.module.workReport.service.WorkReportService;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportSaveReqVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 工作汇报")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/work/report")
|
||||||
|
@Validated
|
||||||
|
public class WorkReportController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkReportService reportService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建工作汇报")
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:create')")
|
||||||
|
public CommonResult<Integer> createReport(@Valid @RequestBody WorkReportSaveReqVO createReqVO) {
|
||||||
|
createReqVO.setUserId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getId());
|
||||||
|
return success(reportService.createReport(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新工作汇报")
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:update')")
|
||||||
|
public CommonResult<Boolean> updateReport(@Valid @RequestBody WorkReportSaveReqVO updateReqVO) {
|
||||||
|
reportService.updateReport(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除工作汇报")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:delete')")
|
||||||
|
public CommonResult<Boolean> deleteReport(@RequestParam("id") Integer id) {
|
||||||
|
reportService.deleteReport(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得工作汇报")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:query')")
|
||||||
|
public CommonResult<WorkReportRespVO> getReport(@RequestParam("id") Integer id) {
|
||||||
|
WorkReport report = reportService.getReport(id);
|
||||||
|
return success(BeanUtils.toBean(report, WorkReportRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得工作汇报分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:query')")
|
||||||
|
public CommonResult<IPage<WorkReportRespVO>> getReportPage(@Valid WorkReportPageReqVO pageReqVO) {
|
||||||
|
Page<WorkReport> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||||
|
IPage<WorkReportRespVO> pageResult = reportService.getReportPage(page, pageReqVO);
|
||||||
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出工作汇报 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('work:report:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportReportExcel(@Valid WorkReportPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
Page<WorkReport> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||||
|
IPage<WorkReportRespVO> pageResult = reportService.getReportPage(page, pageReqVO);
|
||||||
|
List<WorkReportRespVO> list = pageResult.getRecords();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "工作汇报.xls", "数据", WorkReportRespVO.class, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.entity;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作汇报 DO
|
||||||
|
*
|
||||||
|
* @author lighting
|
||||||
|
*/
|
||||||
|
@TableName("work_report")
|
||||||
|
@KeySequence("work_report_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class WorkReport extends TenantBaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 服务套餐表id(system_service_package)
|
||||||
|
*/
|
||||||
|
private String servicePackageId;
|
||||||
|
/**
|
||||||
|
* 汇报主题
|
||||||
|
*/
|
||||||
|
private String reportTopic;
|
||||||
|
/**
|
||||||
|
* 汇报时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime reportTime;
|
||||||
|
/**
|
||||||
|
* 汇报内容
|
||||||
|
*/
|
||||||
|
private String reportContent;
|
||||||
|
/**
|
||||||
|
* 汇报人
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.mapper;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.workReport.entity.WorkReport;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作汇报 Mapper
|
||||||
|
*
|
||||||
|
* @author lighting
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WorkReportMapper extends BaseMapper<WorkReport> {
|
||||||
|
|
||||||
|
IPage<WorkReportRespVO> selectPage(Page page, WorkReportPageReqVO pageReqVO);
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.service;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.workReport.entity.WorkReport;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportSaveReqVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作汇报 Service 接口
|
||||||
|
*
|
||||||
|
* @author lighting
|
||||||
|
*/
|
||||||
|
public interface WorkReportService extends IService<WorkReport> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建工作汇报
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Integer createReport(@Valid WorkReportSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新工作汇报
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateReport(@Valid WorkReportSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除工作汇报
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteReport(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得工作汇报
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 工作汇报
|
||||||
|
*/
|
||||||
|
WorkReport getReport(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得工作汇报分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 工作汇报分页
|
||||||
|
*/
|
||||||
|
IPage<WorkReportRespVO> getReportPage(Page<WorkReport> page, WorkReportPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.service.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.workReport.entity.WorkReport;
|
||||||
|
import cn.iocoder.yudao.module.workReport.mapper.WorkReportMapper;
|
||||||
|
import cn.iocoder.yudao.module.workReport.service.WorkReportService;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO;
|
||||||
|
import cn.iocoder.yudao.module.workReport.vo.WorkReportSaveReqVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作汇报 Service 实现类
|
||||||
|
*
|
||||||
|
* @author lighting
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class WorkReportServiceImpl extends ServiceImpl<WorkReportMapper, WorkReport> implements WorkReportService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkReportMapper reportMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer createReport(WorkReportSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
WorkReport report = BeanUtils.toBean(createReqVO, WorkReport.class);
|
||||||
|
reportMapper.insert(report);
|
||||||
|
// 返回
|
||||||
|
return report.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateReport(WorkReportSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateReportExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
WorkReport updateObj = BeanUtils.toBean(updateReqVO, WorkReport.class);
|
||||||
|
reportMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteReport(Integer id) {
|
||||||
|
// 校验存在
|
||||||
|
validateReportExists(id);
|
||||||
|
// 删除
|
||||||
|
reportMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateReportExists(Integer id) {
|
||||||
|
if (reportMapper.selectById(id) == null) {
|
||||||
|
throw new RuntimeException("工作汇报不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkReport getReport(Integer id) {
|
||||||
|
return reportMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<WorkReportRespVO> getReportPage(Page<WorkReport> page, WorkReportPageReqVO pageReqVO) {
|
||||||
|
return reportMapper.selectPage(page, pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 工作汇报分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class WorkReportPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "汇报主题")
|
||||||
|
private String reportTopic;
|
||||||
|
|
||||||
|
@Schema(description = "汇报时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] reportTime;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "汇报人", example = "24401")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 工作汇报 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class WorkReportRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6601")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "汇报主题")
|
||||||
|
@ExcelProperty("汇报主题")
|
||||||
|
private String reportTopic;
|
||||||
|
|
||||||
|
@Schema(description = "汇报时间")
|
||||||
|
@ExcelProperty("汇报时间")
|
||||||
|
private LocalDateTime reportTime;
|
||||||
|
|
||||||
|
@Schema(description = "汇报内容")
|
||||||
|
@ExcelProperty("汇报内容")
|
||||||
|
private String reportContent;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "汇报人", example = "24401")
|
||||||
|
@ExcelProperty("汇报人")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@Schema(description = "汇报人姓名", example = "李四")
|
||||||
|
@ExcelProperty("汇报人姓名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.iocoder.yudao.module.workReport.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 工作汇报新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class WorkReportSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6601")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "汇报主题")
|
||||||
|
private String reportTopic;
|
||||||
|
|
||||||
|
@Schema(description = "汇报时间")
|
||||||
|
private LocalDateTime reportTime;
|
||||||
|
|
||||||
|
@Schema(description = "汇报内容")
|
||||||
|
private String reportContent;
|
||||||
|
|
||||||
|
@Schema(description = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.workReport.mapper.WorkReportMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectPage" resultType="cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO">
|
||||||
|
SELECT wr.*,su.nickname as userName
|
||||||
|
FROM work_report wr
|
||||||
|
LEFT JOIN system_users su on su.id = wr.user_id
|
||||||
|
<where>
|
||||||
|
<if test="pageReqVO.reportTopic != null">
|
||||||
|
AND wr.report_topic LIKE CONCAT('%', #{pageReqVO.reportTopic}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.reportTime != null">
|
||||||
|
AND wr.report_time BETWEEN #{pageReqVO.reportTime[0]} AND #{pageReqVO.reportTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.createTime != null">
|
||||||
|
AND wr.create_time BETWEEN #{pageReqVO.createTime[0]} AND #{pageReqVO.createTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.userId != null">
|
||||||
|
AND wr.user_id = #{pageReqVO.userId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user