From 197440a8bb3fb4e658884203da288bf0e7782688 Mon Sep 17 00:00:00 2001 From: PQZ Date: Mon, 9 Sep 2024 18:28:53 +0800 Subject: [PATCH] 1 --- dl-module-repair/pom.xml | 35 +++++++ .../admin/RepairProjectController.java | 93 +++++++++++++++++++ .../module/project/entity/RepairProject.java | 75 +++++++++++++++ .../project/mapper/RepairProjectMapper.java | 15 +++ .../project/service/RepairProjectService.java | 57 ++++++++++++ .../impl/RepairProjectServiceImpl.java | 70 ++++++++++++++ .../project/vo/RepairProjectPageReqVO.java | 56 +++++++++++ .../project/vo/RepairProjectRespVO.java | 68 ++++++++++++++ .../project/vo/RepairProjectSaveReqVO.java | 49 ++++++++++ .../mapper/project/RepairProjectMapper.xml | 12 +++ pom.xml | 1 + 11 files changed, 531 insertions(+) create mode 100644 dl-module-repair/pom.xml create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/entity/RepairProject.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectPageReqVO.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectRespVO.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectSaveReqVO.java create mode 100644 dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml diff --git a/dl-module-repair/pom.xml b/dl-module-repair/pom.xml new file mode 100644 index 00000000..d474358e --- /dev/null +++ b/dl-module-repair/pom.xml @@ -0,0 +1,35 @@ + + + + yudao + cn.iocoder.boot + ${revision} + + 4.0.0 + + dl-module-repair + + + cn.iocoder.boot + dl-module-base + ${revision} + + + cn.iocoder.boot + dl-module-company + ${revision} + + + cn.iocoder.boot + yudao-module-system-biz + ${revision} + + + + 8 + 8 + + + \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java new file mode 100644 index 00000000..e254afe9 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java @@ -0,0 +1,93 @@ +package cn.iocoder.yudao.module.project.controller.admin; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.project.entity.RepairProject; +import cn.iocoder.yudao.module.project.service.RepairProjectService; +import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; +import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; +import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 维修项目") +@RestController +@RequestMapping("/repair/project") +@Validated +public class RepairProjectController { + + @Resource + private RepairProjectService repairProjectService; + + @PostMapping("/create") + @Operation(summary = "创建维修项目") + @PreAuthorize("@ss.hasPermission('repair:project:create')") + public CommonResult createRepairProject(@Valid @RequestBody RepairProjectSaveReqVO createReqVO) { + return success(repairProjectService.createRepairProject(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新维修项目") + @PreAuthorize("@ss.hasPermission('repair:project:update')") + public CommonResult updateRepairProject(@Valid @RequestBody RepairProjectSaveReqVO updateReqVO) { + repairProjectService.updateRepairProject(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除维修项目") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('repair:project:delete')") + public CommonResult deleteRepairProject(@RequestParam("id") String id) { + repairProjectService.deleteRepairProject(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得维修项目") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('repair:project:query')") + public CommonResult getRepairProject(@RequestParam("id") String id) { + RepairProject repairProject = repairProjectService.getRepairProject(id); + return success(BeanUtils.toBean(repairProject, RepairProjectRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得维修项目分页") + @PreAuthorize("@ss.hasPermission('repair:project:query')") + public CommonResult> getRepairProjectPage(@Valid RepairProjectPageReqVO pageReqVO) { + PageResult pageResult = repairProjectService.getRepairProjectPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, RepairProjectRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出维修项目 Excel") + @PreAuthorize("@ss.hasPermission('repair:project:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportRepairProjectExcel(@Valid RepairProjectPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = repairProjectService.getRepairProjectPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "维修项目.xls", "数据", RepairProjectRespVO.class, + BeanUtils.toBean(list, RepairProjectRespVO.class)); + } + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/entity/RepairProject.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/entity/RepairProject.java new file mode 100644 index 00000000..6809015d --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/entity/RepairProject.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.project.entity; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.math.BigDecimal; + +/** + * 维修项目 DO + * + * @author pqz + */ +@TableName("dl_repair_project") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RepairProject extends TenantBaseDO { + /** + * 主键标识 + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + /** + * 名称 + */ + private String name; + /** + * 成本 + */ + private Long cost; + /** + * 规格 + */ + private String spec; + /** + * 售价 + */ + private BigDecimal price; + /** + * 编码 + */ + private String code; + /** + * 单位 + */ + private String unit; + /** + * 分类 + */ + private String type; + /** + * 工时 + */ + private String manHour; + /** + * 是否自助(0否1是) + */ + private String isSelf; + /** + * 是否允许分店公用此产品(0否1是) + */ + private String isPublic; + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java new file mode 100644 index 00000000..8b2b259c --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.project.mapper; + +import cn.iocoder.yudao.module.project.entity.RepairProject; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 维修项目 Mapper + * + * @author pqz + */ +@Mapper +public interface RepairProjectMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java new file mode 100644 index 00000000..6fe81843 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.project.service; + + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.project.entity.RepairProject; +import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; +import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; +import com.baomidou.mybatisplus.extension.service.IService; + +import javax.validation.Valid; + +/** + * 维修项目 Service 接口 + * + * @author pqz + */ +public interface RepairProjectService extends IService { + + /** + * 创建维修项目 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String createRepairProject(@Valid RepairProjectSaveReqVO createReqVO); + + /** + * 更新维修项目 + * + * @param updateReqVO 更新信息 + */ + void updateRepairProject(@Valid RepairProjectSaveReqVO updateReqVO); + + /** + * 删除维修项目 + * + * @param id 编号 + */ + void deleteRepairProject(String id); + + /** + * 获得维修项目 + * + * @param id 编号 + * @return 维修项目 + */ + RepairProject getRepairProject(String id); + + /** + * 获得维修项目分页 + * + * @param pageReqVO 分页查询 + * @return 维修项目分页 + */ + PageResult getRepairProjectPage(RepairProjectPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java new file mode 100644 index 00000000..c0e04f32 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.project.service.impl; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.project.entity.RepairProject; +import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper; +import cn.iocoder.yudao.module.project.service.RepairProjectService; +import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; +import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * 维修项目 Service 实现类 + * + * @author pqz + */ +@Service +@Validated +public class RepairProjectServiceImpl extends ServiceImpl implements RepairProjectService { + + @Resource + private RepairProjectMapper repairProjectMapper; + + @Override + public String createRepairProject(RepairProjectSaveReqVO createReqVO) { + // 插入 + RepairProject repairProject = BeanUtils.toBean(createReqVO, RepairProject.class); + repairProjectMapper.insert(repairProject); + // 返回 + return repairProject.getId(); + } + + @Override + public void updateRepairProject(RepairProjectSaveReqVO updateReqVO) { + // 校验存在 + validateRepairProjectExists(updateReqVO.getId()); + // 更新 + RepairProject updateObj = BeanUtils.toBean(updateReqVO, RepairProject.class); + repairProjectMapper.updateById(updateObj); + } + + @Override + public void deleteRepairProject(String id) { + // 校验存在 + validateRepairProjectExists(id); + // 删除 + repairProjectMapper.deleteById(id); + } + + private void validateRepairProjectExists(String id) { + if (repairProjectMapper.selectById(id) == null) { +// throw exception(); + } + } + + @Override + public RepairProject getRepairProject(String id) { + return repairProjectMapper.selectById(id); + } + + @Override + public PageResult getRepairProjectPage(RepairProjectPageReqVO pageReqVO) { + return null; + } + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectPageReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectPageReqVO.java new file mode 100644 index 00000000..03a6a043 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectPageReqVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.project.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.math.BigDecimal; +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 RepairProjectPageReqVO extends PageParam { + + @Schema(description = "名称", example = "王五") + private String name; + + @Schema(description = "成本") + private Long cost; + + @Schema(description = "规格") + private String spec; + + @Schema(description = "售价", example = "16985") + private BigDecimal price; + + @Schema(description = "编码") + private String code; + + @Schema(description = "单位") + private String unit; + + @Schema(description = "分类", example = "1") + private String type; + + @Schema(description = "工时") + private String manHour; + + @Schema(description = "是否自助(0否1是)") + private String isSelf; + + @Schema(description = "是否允许分店公用此产品(0否1是)") + private String isPublic; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectRespVO.java new file mode 100644 index 00000000..a33ecf76 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectRespVO.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.project.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 维修项目 Response VO") +@Data +@ExcelIgnoreUnannotated +public class RepairProjectRespVO { + + @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "2050") + @ExcelProperty("主键标识") + private String id; + + @Schema(description = "名称", example = "王五") + @ExcelProperty("名称") + private String name; + + @Schema(description = "成本") + @ExcelProperty("成本") + private Long cost; + + @Schema(description = "规格") + @ExcelProperty("规格") + private String spec; + + @Schema(description = "售价", example = "16985") + @ExcelProperty("售价") + private BigDecimal price; + + @Schema(description = "编码") + @ExcelProperty("编码") + private String code; + + @Schema(description = "单位") + @ExcelProperty("单位") + private String unit; + + @Schema(description = "分类", example = "1") + @ExcelProperty("分类") + private String type; + + @Schema(description = "工时") + @ExcelProperty("工时") + private String manHour; + + @Schema(description = "是否自助(0否1是)") + @ExcelProperty("是否自助(0否1是)") + private String isSelf; + + @Schema(description = "是否允许分店公用此产品(0否1是)") + @ExcelProperty("是否允许分店公用此产品(0否1是)") + private String isPublic; + + @Schema(description = "备注", example = "你说的对") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectSaveReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectSaveReqVO.java new file mode 100644 index 00000000..f1f4e808 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectSaveReqVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.project.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.math.BigDecimal; + +@Schema(description = "管理后台 - 维修项目新增/修改 Request VO") +@Data +public class RepairProjectSaveReqVO { + + @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "2050") + private String id; + + @Schema(description = "名称", example = "王五") + private String name; + + @Schema(description = "成本") + private Long cost; + + @Schema(description = "规格") + private String spec; + + @Schema(description = "售价", example = "16985") + private BigDecimal price; + + @Schema(description = "编码") + private String code; + + @Schema(description = "单位") + private String unit; + + @Schema(description = "分类", example = "1") + private String type; + + @Schema(description = "工时") + private String manHour; + + @Schema(description = "是否自助(0否1是)") + private String isSelf; + + @Schema(description = "是否允许分店公用此产品(0否1是)") + private String isPublic; + + @Schema(description = "备注", example = "你说的对") + private String remark; + +} \ No newline at end of file diff --git a/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml b/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml new file mode 100644 index 00000000..3973a873 --- /dev/null +++ b/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 033a20ae..edff85f6 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ dl-module-company dl-module-knowledge dl-module-rescue + dl-module-repair dl-module-jx yudao-server