新增汇总模版模块
This commit is contained in:
parent
f25fbed7b9
commit
c210b1fc88
@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
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 java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
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.*;
|
||||
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo.*;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspecttemplate.InspectTemplateDO;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspecttemplate.InspectTemplateService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Tag(name = "管理后台 - 汇总模板")
|
||||
@RestController
|
||||
@RequestMapping("/inspect/template")
|
||||
@Validated
|
||||
public class InspectTemplateController {
|
||||
|
||||
@Resource
|
||||
private InspectTemplateService templateService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建汇总模板")
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:create')")
|
||||
public CommonResult<Integer> createTemplate(@Valid @RequestBody InspectTemplateSaveReqVO createReqVO) {
|
||||
return success(templateService.createTemplate(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新汇总模板")
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:update')")
|
||||
public CommonResult<Boolean> updateTemplate(@Valid @RequestBody InspectTemplateSaveReqVO updateReqVO) {
|
||||
templateService.updateTemplate(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除汇总模板")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:delete')")
|
||||
public CommonResult<Boolean> deleteTemplate(@RequestParam("id") Integer id) {
|
||||
templateService.deleteTemplate(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得汇总模板")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:query')")
|
||||
public CommonResult<InspectTemplateRespVO> getTemplate(@RequestParam("id") Integer id) {
|
||||
InspectTemplateDO template = templateService.getTemplate(id);
|
||||
return success(BeanUtils.toBean(template, InspectTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得汇总模板分页")
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:query')")
|
||||
public CommonResult<PageResult<InspectTemplateRespVO>> getTemplatePage(@Valid InspectTemplatePageReqVO pageReqVO) {
|
||||
PageResult<InspectTemplateDO> pageResult = templateService.getTemplatePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, InspectTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出汇总模板 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('inspect:template:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportTemplateExcel(@Valid InspectTemplatePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<InspectTemplateDO> list = templateService.getTemplatePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "汇总模板.xls", "数据", InspectTemplateRespVO.class,
|
||||
BeanUtils.toBean(list, InspectTemplateRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.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 InspectTemplatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "主键id ", example = "4550")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "模板内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Double orderNum;
|
||||
|
||||
@Schema(description = "模板名称", example = "赵六")
|
||||
private String contentName;
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 汇总模板 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class InspectTemplateRespVO {
|
||||
|
||||
@Schema(description = "主键id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "4550")
|
||||
@ExcelProperty("主键id ")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
@ExcelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
@ExcelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "模板内容")
|
||||
@ExcelProperty("模板内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@ExcelProperty("排序")
|
||||
private Double orderNum;
|
||||
|
||||
@Schema(description = "创建人", example = "1845")
|
||||
@ExcelProperty("创建人")
|
||||
private String createId;
|
||||
|
||||
@Schema(description = "模板名称", example = "赵六")
|
||||
@ExcelProperty("模板名称")
|
||||
private String contentName;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 汇总模板新增/修改 Request VO")
|
||||
@Data
|
||||
public class InspectTemplateSaveReqVO {
|
||||
|
||||
@Schema(description = "主键id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "4550")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "模板内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Double orderNum;
|
||||
|
||||
@Schema(description = "创建人", example = "1845")
|
||||
private String createId;
|
||||
|
||||
@Schema(description = "模板名称", example = "赵六")
|
||||
private String contentName;
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.inspect.dal.dataobject.inspecttemplate;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 汇总模板 DO
|
||||
*
|
||||
* @author 李晓东
|
||||
*/
|
||||
@TableName("tb_template")
|
||||
@KeySequence("tb_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InspectTemplateDO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
/**
|
||||
* 模板内容
|
||||
*/
|
||||
@TableField("content")
|
||||
private String content;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("orderNum")
|
||||
private Double orderNum;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("createId")
|
||||
private String createId;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField("updateId")
|
||||
private String updateId;
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
@TableField("contentName")
|
||||
private String contentName;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.inspect.dal.mysql.inspecttemplate;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspecttemplate.InspectTemplateDO;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo.*;
|
||||
|
||||
/**
|
||||
* 汇总模板 Mapper
|
||||
*
|
||||
* @author 李晓东
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Mapper
|
||||
public interface InspectTemplateMapper extends BaseMapperX<InspectTemplateDO> {
|
||||
|
||||
default PageResult<InspectTemplateDO> selectPage(InspectTemplatePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<InspectTemplateDO>()
|
||||
.eqIfPresent(InspectTemplateDO::getId, reqVO.getId())
|
||||
.eqIfPresent(InspectTemplateDO::getType, reqVO.getType())
|
||||
.eqIfPresent(InspectTemplateDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(InspectTemplateDO::getContent, reqVO.getContent())
|
||||
.eqIfPresent(InspectTemplateDO::getOrderNum, reqVO.getOrderNum())
|
||||
.likeIfPresent(InspectTemplateDO::getContentName, reqVO.getContentName())
|
||||
.orderByDesc(InspectTemplateDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.inspecttemplate;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo.*;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspecttemplate.InspectTemplateDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 汇总模板 Service 接口
|
||||
*
|
||||
* @author 李晓东
|
||||
*/
|
||||
public interface InspectTemplateService {
|
||||
|
||||
/**
|
||||
* 创建汇总模板
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createTemplate(@Valid InspectTemplateSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新汇总模板
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateTemplate(@Valid InspectTemplateSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除汇总模板
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteTemplate(Integer id);
|
||||
|
||||
/**
|
||||
* 获得汇总模板
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 汇总模板
|
||||
*/
|
||||
InspectTemplateDO getTemplate(Integer id);
|
||||
|
||||
/**
|
||||
* 获得汇总模板分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 汇总模板分页
|
||||
*/
|
||||
PageResult<InspectTemplateDO> getTemplatePage(InspectTemplatePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.inspecttemplate;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspecttemplate.vo.*;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspecttemplate.InspectTemplateDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.inspect.dal.mysql.inspecttemplate.InspectTemplateMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 汇总模板 Service 实现类
|
||||
*
|
||||
* @author 李晓东
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class InspectTemplateServiceImpl implements InspectTemplateService {
|
||||
|
||||
@Resource
|
||||
private InspectTemplateMapper templateMapper;
|
||||
|
||||
@Override
|
||||
public Integer createTemplate(InspectTemplateSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
InspectTemplateDO template = BeanUtils.toBean(createReqVO, InspectTemplateDO.class);
|
||||
templateMapper.insert(template);
|
||||
// 返回
|
||||
return template.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTemplate(InspectTemplateSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateTemplateExists(updateReqVO.getId());
|
||||
// 更新
|
||||
InspectTemplateDO updateObj = BeanUtils.toBean(updateReqVO, InspectTemplateDO.class);
|
||||
templateMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTemplate(Integer id) {
|
||||
// 校验存在
|
||||
validateTemplateExists(id);
|
||||
// 删除
|
||||
templateMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateTemplateExists(Integer id) {
|
||||
if (templateMapper.selectById(id) == null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectTemplateDO getTemplate(Integer id) {
|
||||
return templateMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InspectTemplateDO> getTemplatePage(InspectTemplatePageReqVO pageReqVO) {
|
||||
return templateMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?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.inspect.dal.mysql.inspecttemplate.InspectTemplateMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user