diff --git a/pom.xml b/pom.xml index 862d6bed..8b2a3b0a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ yudao-module-bs yudao-module-archives yudao-module-electronic + yudao-module-setting ${project.artifactId} diff --git a/yudao-module-setting/pom.xml b/yudao-module-setting/pom.xml new file mode 100644 index 00000000..72f633bd --- /dev/null +++ b/yudao-module-setting/pom.xml @@ -0,0 +1,43 @@ + + + + cn.iocoder.boot + yudao + ${revision} + + 4.0.0 + + yudao-module-setting-api + yudao-module-setting-biz + + yudao-module-setting + pom + + ${project.artifactId} + + 档案设置业务模块 + + + + com.baidu.aip + java-sdk + 4.8.0 + + + + commons-io + commons-io + 2.6 + + + + com.alibaba + fastjson + 1.2.80 + + + + + diff --git a/yudao-module-setting/yudao-module-setting-api/pom.xml b/yudao-module-setting/yudao-module-setting-api/pom.xml new file mode 100644 index 00000000..ec60a95f --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-api/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + cn.iocoder.boot + yudao-module-setting + ${revision} + + + yudao-module-setting-api + jar + + ${project.artifactId} + + setting 模块 API,暴露给其它模块调用 + + + + + cn.iocoder.boot + yudao-common + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + + diff --git a/yudao-module-setting/yudao-module-setting-api/src/main/java/cn/iocoder/yudao/module/setting/enums/ErrorCodeConstants.java b/yudao-module-setting/yudao-module-setting-api/src/main/java/cn/iocoder/yudao/module/setting/enums/ErrorCodeConstants.java new file mode 100644 index 00000000..6c9119a2 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-api/src/main/java/cn/iocoder/yudao/module/setting/enums/ErrorCodeConstants.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.setting.enums; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; +public interface ErrorCodeConstants { + ErrorCode ORGANIZATION_NOT_EXISTS = new ErrorCode(200100, "立档单位不存在"); + ErrorCode DEPOT_CABINET_NOT_EXISTS = new ErrorCode(300100, "档案柜管理不存在"); + ErrorCode DEPOT_NOT_EXISTS = new ErrorCode(400100, "库房管理不存在"); + +} \ No newline at end of file diff --git a/yudao-module-setting/yudao-module-setting-biz/pom.xml b/yudao-module-setting/yudao-module-setting-biz/pom.xml new file mode 100644 index 00000000..c8ced187 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/pom.xml @@ -0,0 +1,82 @@ + + + + cn.iocoder.boot + yudao-module-setting + ${revision} + + 4.0.0 + yudao-module-setting-biz + jar + + ${project.artifactId} + + setting 模块,主要实现商品相关功能 + 例如:品牌、商品分类、spu、sku等功能。 + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-tenant + + + cn.iocoder.boot + yudao-module-setting-api + ${revision} + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-data-permission + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-operatelog + + + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + + + + + cn.iocoder.boot + yudao-spring-boot-starter-excel + + + cn.iocoder.boot + yudao-module-bpm-api + 1.7.3-snapshot + compile + + + cn.iocoder.boot + yudao-module-system-biz + 1.7.3-snapshot + compile + + + + diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/DepotController.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/DepotController.java new file mode 100644 index 00000000..e54d8e56 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/DepotController.java @@ -0,0 +1,136 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot; + +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.DepotCabinetExportReqVO; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +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.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.module.setting.convert.depot.DepotConvert; +import cn.iocoder.yudao.module.setting.service.depot.DepotService; + +@Tag(name = "管理后台 - 库房管理") +@RestController +@RequestMapping("/setting/depot") +@Validated +public class DepotController { + + @Resource + private DepotService depotService; + + @PostMapping("/create") + @Operation(summary = "创建库房管理") + @PreAuthorize("@ss.hasPermission('setting:depot:create')") + public CommonResult createDepot(@Valid @RequestBody DepotCreateReqVO createReqVO) { + DepotExportReqVO depotExportReqVO = new DepotExportReqVO(); + //不能重复 + depotExportReqVO.setCode(createReqVO.getCode()); + List depotList = depotService.getDepotList(depotExportReqVO); + if (depotList.size()>0){ + return error("库房编码不能重复!"); + } + //不能重复 + depotExportReqVO.setCode(null); + depotExportReqVO.setName(createReqVO.getName()); + List organizationList2 = depotService.getDepotList(depotExportReqVO); + if (organizationList2.size()>0){ + return error("库房名称不能重复!"); + } + return success(depotService.createDepot(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新库房管理") + @PreAuthorize("@ss.hasPermission('setting:depot:update')") + public CommonResult updateDepot(@Valid @RequestBody DepotUpdateReqVO updateReqVO) { + DepotExportReqVO depotExportReqVO = new DepotExportReqVO(); + //不能重复 + depotExportReqVO.setCode(updateReqVO.getCode()); + List depotList = depotService.getDepotList(depotExportReqVO); + if (depotList.size()>0){ + return error("库房编码不能重复!"); + } + //不能重复 + depotExportReqVO.setCode(null); + depotExportReqVO.setName(updateReqVO.getName()); + List organizationList2 = depotService.getDepotList(depotExportReqVO); + if (organizationList2.size()>0){ + return error("库房名称不能重复!"); + } + depotService.updateDepot(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除库房管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('setting:depot:delete')") + public CommonResult deleteDepot(@RequestParam("id") Long id) { + depotService.deleteDepot(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得库房管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('setting:depot:query')") + public CommonResult getDepot(@RequestParam("id") Long id) { + DepotDO depot = depotService.getDepot(id); + return success(DepotConvert.INSTANCE.convert(depot)); + } + + @GetMapping("/list") + @Operation(summary = "获得库房管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('setting:depot:query')") + public CommonResult> getDepotList(@RequestParam("ids") Collection ids) { + List list = depotService.getDepotList(ids); + return success(DepotConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得库房管理分页") + @PreAuthorize("@ss.hasPermission('setting:depot:query')") + @DataPermission + public CommonResult> getDepotPage(@Valid DepotPageReqVO pageVO) { + PageResult pageResult = depotService.getDepotPage(pageVO); + return success(DepotConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出库房管理 Excel") + @PreAuthorize("@ss.hasPermission('setting:depot:export')") + @OperateLog(type = EXPORT) + public void exportDepotExcel(@Valid DepotExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = depotService.getDepotList(exportReqVO); + // 导出 Excel + List datas = DepotConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "库房管理.xls", "数据", DepotExcelVO.class, datas); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotBaseVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotBaseVO.java new file mode 100644 index 00000000..a0061f50 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotBaseVO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 库房管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class DepotBaseVO { + + @Schema(description = "库房名称", example = "芋艿") + private String name; + + @Schema(description = "库房编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "立党单位id", example = "16975") + private Long organizationId; + + @Schema(description = "管理者ID", example = "4209") + private Long manegerId; + + @Schema(description = "管理者姓名", example = "赵六") + private String manegerName; + + @Schema(description = "所属部门ID", example = "4488") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "14016") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "用户ID", example = "2430") + private Long userId; + + @Schema(description = "立档单位名称", example = "赵六") + private String organizationName; + + @Schema(description = "立档单位编码") + private String organizationCode; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotCreateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotCreateReqVO.java new file mode 100644 index 00000000..9475af5a --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 库房管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotCreateReqVO extends DepotBaseVO { + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExcelVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExcelVO.java new file mode 100644 index 00000000..66d58eef --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExcelVO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 库房管理 Excel VO + * + * @author 芋道源码 + */ +@Data +public class DepotExcelVO { + + @ExcelProperty("主键ID") + private Long id; + + @ExcelProperty("库房名称") + private String name; + + @ExcelProperty("库房编号") + private String code; + + @ExcelProperty("库房地址") + private String address; + + @ExcelProperty("立党单位id") + private Long organizationId; + + @ExcelProperty("管理者ID") + private Long manegerId; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("管理者姓名") + private String manegerName; + + @ExcelProperty("所属部门ID") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + + @ExcelProperty("业务实体ID") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("用户ID") + private Long userId; + + @ExcelProperty("立档单位名称") + private String organizationName; + + @ExcelProperty("立档单位编码") + private String organizationCode; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExportReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExportReqVO.java new file mode 100644 index 00000000..a20823a8 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotExportReqVO.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 库房管理 Excel 导出 Request VO,参数和 DepotPageReqVO 是一致的") +@Data +public class DepotExportReqVO { + + @Schema(description = "库房名称", example = "芋艿") + private String name; + + @Schema(description = "库房编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "立党单位id", example = "16975") + private Long organizationId; + + @Schema(description = "管理者ID", example = "4209") + private Long manegerId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "管理者姓名", example = "赵六") + private String manegerName; + + @Schema(description = "所属部门ID", example = "4488") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "14016") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "用户ID", example = "2430") + private Long userId; + + @Schema(description = "立档单位名称", example = "赵六") + private String organizationName; + + @Schema(description = "立档单位编码") + private String organizationCode; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotPageReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotPageReqVO.java new file mode 100644 index 00000000..22f3daa2 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotPageReqVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.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 DepotPageReqVO extends PageParam { + + @Schema(description = "库房名称", example = "芋艿") + private String name; + + @Schema(description = "库房编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "立党单位id", example = "16975") + private Long organizationId; + + @Schema(description = "管理者ID", example = "4209") + private Long manegerId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "管理者姓名", example = "赵六") + private String manegerName; + + @Schema(description = "所属部门ID", example = "4488") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "14016") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "用户ID", example = "2430") + private Long userId; + + @Schema(description = "立档单位名称", example = "赵六") + private String organizationName; + + @Schema(description = "立档单位编码") + private String organizationCode; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotRespVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotRespVO.java new file mode 100644 index 00000000..595e678a --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 库房管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotRespVO extends DepotBaseVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19063") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotUpdateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotUpdateReqVO.java new file mode 100644 index 00000000..58c212c9 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 库房管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotUpdateReqVO extends DepotBaseVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19063") + @NotNull(message = "主键ID不能为空") + private Long id; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotVo.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotVo.java new file mode 100644 index 00000000..378c8960 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/DepotVo.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.DepotCabinetVo; +import lombok.Data; +import lombok.ToString; + +import java.util.List; + +@Data +@ToString +public class DepotVo { + private Long depotId; + private String depotName; + private String depotCode; + private List children; +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/OrganizationDepotVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/OrganizationDepotVO.java new file mode 100644 index 00000000..44ecf79b --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depot/vo/OrganizationDepotVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depot.vo; + +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.DepotCabinetVo; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Data +@ToString +public class OrganizationDepotVO { + private Long organizationId; + private String organizationName; + private String organizationCode; + private List children; +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/DepotCabinetController.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/DepotCabinetController.java new file mode 100644 index 00000000..f9f9f043 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/DepotCabinetController.java @@ -0,0 +1,136 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet; + +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.OrganizationExportReqVO; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +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.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.module.setting.convert.depotcabinet.DepotCabinetConvert; +import cn.iocoder.yudao.module.setting.service.depotcabinet.DepotCabinetService; + +@Tag(name = "管理后台 - 档案柜管理") +@RestController +@RequestMapping("/setting/depot-cabinet") +@Validated +public class DepotCabinetController { + + @Resource + private DepotCabinetService depotCabinetService; + + @PostMapping("/create") + @Operation(summary = "创建档案柜管理") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:create')") + public CommonResult createDepotCabinet(@Valid @RequestBody DepotCabinetCreateReqVO createReqVO) { + DepotCabinetExportReqVO depotCabinetExportReqVO = new DepotCabinetExportReqVO(); + //不能重复 + depotCabinetExportReqVO.setCode(createReqVO.getCode()); + List depotCabinetList = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO); + if (depotCabinetList.size()>0){ + return error("档案柜编码不能重复!"); + } + //不能重复 + depotCabinetExportReqVO.setCode(null); + depotCabinetExportReqVO.setName(createReqVO.getName()); + List organizationList2 = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO); + if (organizationList2.size()>0){ + return error("档案柜名称不能重复!"); + } + return success(depotCabinetService.createDepotCabinet(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新档案柜管理") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:update')") + public CommonResult updateDepotCabinet(@Valid @RequestBody DepotCabinetUpdateReqVO updateReqVO) { + DepotCabinetExportReqVO depotCabinetExportReqVO = new DepotCabinetExportReqVO(); + //不能重复 + depotCabinetExportReqVO.setCode(updateReqVO.getCode()); + List depotCabinetList = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO); + if (depotCabinetList.size()>0){ + return error("档案柜编码不能重复!"); + } + //不能重复 + depotCabinetExportReqVO.setCode(null); + depotCabinetExportReqVO.setName(updateReqVO.getName()); + List organizationList2 = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO); + if (organizationList2.size()>0){ + return error("档案柜名称不能重复!"); + } + depotCabinetService.updateDepotCabinet(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除档案柜管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:delete')") + public CommonResult deleteDepotCabinet(@RequestParam("id") Long id) { + depotCabinetService.deleteDepotCabinet(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得档案柜管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:query')") + public CommonResult getDepotCabinet(@RequestParam("id") Long id) { + DepotCabinetDO depotCabinet = depotCabinetService.getDepotCabinet(id); + return success(DepotCabinetConvert.INSTANCE.convert(depotCabinet)); + } + + @GetMapping("/list") + @Operation(summary = "获得档案柜管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:query')") + public CommonResult> getDepotCabinetList(@RequestParam("ids") Collection ids) { + List list = depotCabinetService.getDepotCabinetList(ids); + return success(DepotCabinetConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得档案柜管理分页") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:query')") + @DataPermission + public CommonResult> getDepotCabinetPage(@Valid DepotCabinetPageReqVO pageVO) { + PageResult pageResult = depotCabinetService.getDepotCabinetPage(pageVO); + return success(DepotCabinetConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出档案柜管理 Excel") + @PreAuthorize("@ss.hasPermission('setting:depot-cabinet:export')") + @OperateLog(type = EXPORT) + public void exportDepotCabinetExcel(@Valid DepotCabinetExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = depotCabinetService.getDepotCabinetList(exportReqVO); + // 导出 Excel + List datas = DepotCabinetConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "档案柜管理.xls", "数据", DepotCabinetExcelVO.class, datas); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetBaseVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetBaseVO.java new file mode 100644 index 00000000..74692a57 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetBaseVO.java @@ -0,0 +1,53 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 档案柜管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class DepotCabinetBaseVO { + + @Schema(description = "所属库房ID", example = "19347") + private Long depotId; + + @Schema(description = "柜子名称", example = "张三") + private String name; + + @Schema(description = "柜子编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "管理者ID", example = "9598") + private Long manegerId; + + @Schema(description = "管理者姓名", example = "张三") + private String manegerName; + + @Schema(description = "所属部门ID", example = "16027") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "30420") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "用户ID", example = "22208") + private Long userId; + + @Schema(description = "备注", example = "你猜") + private String remark; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetCreateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetCreateReqVO.java new file mode 100644 index 00000000..6608f67e --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 档案柜管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotCabinetCreateReqVO extends DepotCabinetBaseVO { + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExcelVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExcelVO.java new file mode 100644 index 00000000..8c837938 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExcelVO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 档案柜管理 Excel VO + * + * @author 芋道源码 + */ +@Data +public class DepotCabinetExcelVO { + + @ExcelProperty("主键ID") + private Long id; + + @ExcelProperty("所属库房ID") + private Long depotId; + + @ExcelProperty("柜子名称") + private String name; + + @ExcelProperty("柜子编号") + private String code; + + @ExcelProperty("库房地址") + private String address; + + @ExcelProperty("管理者ID") + private Long manegerId; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("管理者姓名") + private String manegerName; + + @ExcelProperty("所属部门ID") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + + @ExcelProperty("业务实体ID") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + + @ExcelProperty("用户ID") + private Long userId; + + @ExcelProperty("备注") + private String remark; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExportReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExportReqVO.java new file mode 100644 index 00000000..628555a9 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetExportReqVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 档案柜管理 Excel 导出 Request VO,参数和 DepotCabinetPageReqVO 是一致的") +@Data +public class DepotCabinetExportReqVO { + + @Schema(description = "所属库房ID", example = "19347") + private Long depotId; + + @Schema(description = "柜子名称", example = "张三") + private String name; + + @Schema(description = "柜子编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "管理者ID", example = "9598") + private Long manegerId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "管理者姓名", example = "张三") + private String manegerName; + + @Schema(description = "所属部门ID", example = "16027") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "30420") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "用户ID", example = "22208") + private Long userId; + + @Schema(description = "备注", example = "你猜") + private String remark; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetPageReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetPageReqVO.java new file mode 100644 index 00000000..57ef6c7f --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetPageReqVO.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.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 DepotCabinetPageReqVO extends PageParam { + + @Schema(description = "所属库房ID", example = "19347") + private Long depotId; + + @Schema(description = "柜子名称", example = "张三") + private String name; + + @Schema(description = "柜子编号") + private String code; + + @Schema(description = "库房地址") + private String address; + + @Schema(description = "管理者ID", example = "9598") + private Long manegerId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "管理者姓名", example = "张三") + private String manegerName; + + @Schema(description = "所属部门ID", example = "16027") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "业务实体ID", example = "30420") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "用户ID", example = "22208") + private Long userId; + + @Schema(description = "备注", example = "你猜") + private String remark; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetRespVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetRespVO.java new file mode 100644 index 00000000..95f2de90 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 档案柜管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotCabinetRespVO extends DepotCabinetBaseVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26621") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetUpdateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetUpdateReqVO.java new file mode 100644 index 00000000..4a608b77 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 档案柜管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DepotCabinetUpdateReqVO extends DepotCabinetBaseVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26621") + @NotNull(message = "主键ID不能为空") + private Long id; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetVo.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetVo.java new file mode 100644 index 00000000..f1e88d2a --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/depotcabinet/vo/DepotCabinetVo.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo; + +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +public class DepotCabinetVo { + private Long cabinetId; + private String cabinetName; + private String cabinetCode; +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/OrganizationController.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/OrganizationController.java new file mode 100644 index 00000000..fe8902af --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/OrganizationController.java @@ -0,0 +1,142 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization; + +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.OrganizationDepotVO; +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.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.module.setting.convert.organization.OrganizationConvert; +import cn.iocoder.yudao.module.setting.service.organization.OrganizationService; + +@Tag(name = "管理后台 - 立档单位") +@RestController +@RequestMapping("/setting/organization") +@Validated +public class OrganizationController { + + @Resource + private OrganizationService organizationService; + + @PostMapping("/create") + @Operation(summary = "创建立档单位") + @PreAuthorize("@ss.hasPermission('setting:organization:create')") + public CommonResult createOrganization(@Valid @RequestBody OrganizationCreateReqVO createReqVO) { + OrganizationExportReqVO organizationExportReqVO = new OrganizationExportReqVO(); + //立档单位编码不能重复 + organizationExportReqVO.setOrganizationCode(createReqVO.getOrganizationCode()); + List organizationList = organizationService.getOrganizationList(organizationExportReqVO); + if (organizationList.size()>0){ + return error("立档单位编码不能重复!"); + } + //立档单位名称不能重复 + organizationExportReqVO.setOrganizationCode(null); + organizationExportReqVO.setOrganizationName(createReqVO.getOrganizationName()); + List organizationList2 = organizationService.getOrganizationList(organizationExportReqVO); + if (organizationList2.size()>0){ + return error("立档单位名称不能重复!"); + } + return success(organizationService.createOrganization(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新立档单位") + @PreAuthorize("@ss.hasPermission('setting:organization:update')") + public CommonResult updateOrganization(@Valid @RequestBody OrganizationUpdateReqVO updateReqVO) { + OrganizationExportReqVO organizationExportReqVO = new OrganizationExportReqVO(); + //立档单位编码不能重复 + organizationExportReqVO.setOrganizationCode(updateReqVO.getOrganizationCode()); + List organizationList = organizationService.getOrganizationList(organizationExportReqVO); + if (organizationList.size()>0){ + return error("立档单位编码不能重复!"); + } + //立档单位名称不能重复 + organizationExportReqVO.setOrganizationCode(null); + organizationExportReqVO.setOrganizationName(updateReqVO.getOrganizationName()); + List organizationList2 = organizationService.getOrganizationList(organizationExportReqVO); + if (organizationList2.size()>0){ + return error("立档单位名称不能重复!"); + } + organizationService.updateOrganization(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除立档单位") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('setting:organization:delete')") + public CommonResult deleteOrganization(@RequestParam("id") Long id) { + organizationService.deleteOrganization(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得立档单位") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('setting:organization:query')") + public CommonResult getOrganization(@RequestParam("id") Long id) { + OrganizationDO organization = organizationService.getOrganization(id); + return success(OrganizationConvert.INSTANCE.convert(organization)); + } + + @GetMapping("/getTree") + @Operation(summary = "获得立档单位树") + @PreAuthorize("@ss.hasPermission('setting:organization:query')") + public CommonResult> getTree() { + return success(organizationService.getOrganizationTree()); + } + + @GetMapping("/list") + @Operation(summary = "获得立档单位列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('setting:organization:query')") + public CommonResult> getOrganizationList(@RequestParam("ids") Collection ids) { + List list = organizationService.getOrganizationList(ids); + return success(OrganizationConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得立档单位分页") + @PreAuthorize("@ss.hasPermission('setting:organization:query')") + @DataPermission + public CommonResult> getOrganizationPage(@Valid OrganizationPageReqVO pageVO) { + PageResult pageResult = organizationService.getOrganizationPage(pageVO); + return success(OrganizationConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出立档单位 Excel") + @PreAuthorize("@ss.hasPermission('setting:organization:export')") + @OperateLog(type = EXPORT) + public void exportOrganizationExcel(@Valid OrganizationExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = organizationService.getOrganizationList(exportReqVO); + // 导出 Excel + List datas = OrganizationConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "立档单位.xls", "数据", OrganizationExcelVO.class, datas); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationBaseVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationBaseVO.java new file mode 100644 index 00000000..893ae811 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationBaseVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 立档单位 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class OrganizationBaseVO { + + @Schema(description = "单位名称", example = "李四") + private String organizationName; + + @Schema(description = "单位编码") + private String organizationCode; + + @Schema(description = "全宗号") + private String caseNum; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "所属部门id", example = "13232") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "用户id", example = "22926") + private Long userId; + + @Schema(description = "业务实体id", example = "13170") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationCreateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationCreateReqVO.java new file mode 100644 index 00000000..46312416 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 立档单位创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OrganizationCreateReqVO extends OrganizationBaseVO { + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExcelVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExcelVO.java new file mode 100644 index 00000000..4f85a3bd --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExcelVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 立档单位 Excel VO + * + * @author 芋道源码 + */ +@Data +public class OrganizationExcelVO { + + @ExcelProperty("单位id") + private Long id; + + @ExcelProperty("单位名称") + private String organizationName; + + @ExcelProperty("单位编码") + private String organizationCode; + + @ExcelProperty("全宗号") + private String caseNum; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("所属部门id") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + + @ExcelProperty("用户id") + private Long userId; + + @ExcelProperty("业务实体id") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExportReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExportReqVO.java new file mode 100644 index 00000000..1aecf2b7 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationExportReqVO.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 立档单位 Excel 导出 Request VO,参数和 OrganizationPageReqVO 是一致的") +@Data +public class OrganizationExportReqVO { + + @Schema(description = "单位名称", example = "李四") + private String organizationName; + + @Schema(description = "单位编码") + private String organizationCode; + + @Schema(description = "全宗号") + private String caseNum; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "所属部门id", example = "13232") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "用户id", example = "22926") + private Long userId; + + @Schema(description = "业务实体id", example = "13170") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationPageReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationPageReqVO.java new file mode 100644 index 00000000..b0b398e0 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationPageReqVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.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 OrganizationPageReqVO extends PageParam { + + @Schema(description = "单位名称", example = "李四") + private String organizationName; + + @Schema(description = "单位编码") + private String organizationCode; + + @Schema(description = "全宗号") + private String caseNum; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "所属部门id", example = "13232") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "用户id", example = "22926") + private Long userId; + + @Schema(description = "业务实体id", example = "13170") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationRespVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationRespVO.java new file mode 100644 index 00000000..ccbfcb3c --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 立档单位 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OrganizationRespVO extends OrganizationBaseVO { + + @Schema(description = "单位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28076") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationUpdateReqVO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationUpdateReqVO.java new file mode 100644 index 00000000..8f749cb7 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/organization/vo/OrganizationUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.setting.controller.admin.organization.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 立档单位更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OrganizationUpdateReqVO extends OrganizationBaseVO { + + @Schema(description = "单位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28076") + @NotNull(message = "单位id不能为空") + private Long id; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depot/DepotConvert.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depot/DepotConvert.java new file mode 100644 index 00000000..8e99521d --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depot/DepotConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.setting.convert.depot; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; + +/** + * 库房管理 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface DepotConvert { + + DepotConvert INSTANCE = Mappers.getMapper(DepotConvert.class); + + DepotDO convert(DepotCreateReqVO bean); + + DepotDO convert(DepotUpdateReqVO bean); + + DepotRespVO convert(DepotDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depotcabinet/DepotCabinetConvert.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depotcabinet/DepotCabinetConvert.java new file mode 100644 index 00000000..3cb9d0ee --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/depotcabinet/DepotCabinetConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.setting.convert.depotcabinet; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; + +/** + * 档案柜管理 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface DepotCabinetConvert { + + DepotCabinetConvert INSTANCE = Mappers.getMapper(DepotCabinetConvert.class); + + DepotCabinetDO convert(DepotCabinetCreateReqVO bean); + + DepotCabinetDO convert(DepotCabinetUpdateReqVO bean); + + DepotCabinetRespVO convert(DepotCabinetDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/organization/OrganizationConvert.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/organization/OrganizationConvert.java new file mode 100644 index 00000000..2c1ea115 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/convert/organization/OrganizationConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.setting.convert.organization; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; + +/** + * 立档单位 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface OrganizationConvert { + + OrganizationConvert INSTANCE = Mappers.getMapper(OrganizationConvert.class); + + OrganizationDO convert(OrganizationCreateReqVO bean); + + OrganizationDO convert(OrganizationUpdateReqVO bean); + + OrganizationRespVO convert(OrganizationDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depot/DepotDO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depot/DepotDO.java new file mode 100644 index 00000000..f767c0f9 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depot/DepotDO.java @@ -0,0 +1,103 @@ +package cn.iocoder.yudao.module.setting.dal.dataobject.depot; + +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("setting_depot") +@KeySequence("setting_depot_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DepotDO extends BaseDO { + + /** + * 主键ID + */ + @TableId + private Long id; + /** + * 库房名称 + */ + private String name; + /** + * 库房编号 + */ + private String code; + /** + * 库房地址 + */ + private String address; + /** + * 立党单位id + */ + private Long organizationId; + /** + * 管理者ID + */ + private Long manegerId; + /** + * 管理者姓名 + */ + private String manegerName; + /** + * 所属部门ID + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + /** + * 业务实体ID + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + /** + * 备注 + */ + private String remark; + /** + * 用户ID + */ + private Long userId; + /** + * 预留字段1 + */ + private String attr1; + /** + * 预留字段2 + */ + private String attr2; + /** + * 预留字段3 + */ + private Integer attr3; + /** + * 预留字段4 + */ + private Integer attr4; + /** + * 立档单位名称 + */ + private String organizationName; + /** + * 立档单位编码 + */ + private String organizationCode; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depotcabinet/DepotCabinetDO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depotcabinet/DepotCabinetDO.java new file mode 100644 index 00000000..4a0adfc5 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/depotcabinet/DepotCabinetDO.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet; + +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("setting_depot_cabinet") +@KeySequence("setting_depot_cabinet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DepotCabinetDO extends BaseDO { + + /** + * 主键ID + */ + @TableId + private Long id; + /** + * 所属库房ID + */ + private Long depotId; + /** + * 柜子名称 + */ + private String name; + /** + * 柜子编号 + */ + private String code; + /** + * 库房地址 + */ + private String address; + /** + * 管理者ID + */ + private Long manegerId; + /** + * 管理者姓名 + */ + private String manegerName; + /** + * 所属部门ID + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + /** + * 业务实体ID + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + /** + * 用户ID + */ + private Long userId; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attr1; + /** + * 预留字段2 + */ + private String attr2; + /** + * 预留字段3 + */ + private Integer attr3; + /** + * 预留字段4 + */ + private Integer attr4; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/organization/OrganizationDO.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/organization/OrganizationDO.java new file mode 100644 index 00000000..ece956f8 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/dataobject/organization/OrganizationDO.java @@ -0,0 +1,83 @@ +package cn.iocoder.yudao.module.setting.dal.dataobject.organization; + +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("setting_organization") +@KeySequence("setting_organization_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationDO extends BaseDO { + + /** + * 单位id + */ + @TableId + private Long id; + /** + * 单位名称 + */ + private String organizationName; + /** + * 单位编码 + */ + private String organizationCode; + /** + * 全宗号 + */ + private String caseNum; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attr1; + /** + * 预留字段2 + */ + private String attr2; + /** + * 预留字段3 + */ + private Integer attr3; + /** + * 预留字段4 + */ + private Integer attr4; + /** + * 所属部门id + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + /** + * 用户id + */ + private Long userId; + /** + * 业务实体id + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depot/DepotMapper.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depot/DepotMapper.java new file mode 100644 index 00000000..4995a773 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depot/DepotMapper.java @@ -0,0 +1,73 @@ +package cn.iocoder.yudao.module.setting.dal.mysql.depot; + +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.setting.controller.admin.depotcabinet.vo.DepotCabinetVo; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import org.apache.ibatis.annotations.*; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; + +/** + * 库房管理 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DepotMapper extends BaseMapperX { + + default PageResult selectPage(DepotPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(DepotDO::getName, reqVO.getName()) + .eqIfPresent(DepotDO::getCode, reqVO.getCode()) + .eqIfPresent(DepotDO::getAddress, reqVO.getAddress()) + .eqIfPresent(DepotDO::getOrganizationId, reqVO.getOrganizationId()) + .eqIfPresent(DepotDO::getManegerId, reqVO.getManegerId()) + .betweenIfPresent(DepotDO::getCreateTime, reqVO.getCreateTime()) + .likeIfPresent(DepotDO::getManegerName, reqVO.getManegerName()) + .eqIfPresent(DepotDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(DepotDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(DepotDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(DepotDO::getCompany, reqVO.getCompany()) + .eqIfPresent(DepotDO::getRemark, reqVO.getRemark()) + .eqIfPresent(DepotDO::getUserId, reqVO.getUserId()) + .likeIfPresent(DepotDO::getOrganizationName, reqVO.getOrganizationName()) + .eqIfPresent(DepotDO::getOrganizationCode, reqVO.getOrganizationCode()) + .orderByDesc(DepotDO::getId)); + } + + default List selectList(DepotExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(DepotDO::getName, reqVO.getName()) + .eqIfPresent(DepotDO::getCode, reqVO.getCode()) + .eqIfPresent(DepotDO::getAddress, reqVO.getAddress()) + .eqIfPresent(DepotDO::getOrganizationId, reqVO.getOrganizationId()) + .eqIfPresent(DepotDO::getManegerId, reqVO.getManegerId()) + .betweenIfPresent(DepotDO::getCreateTime, reqVO.getCreateTime()) + .likeIfPresent(DepotDO::getManegerName, reqVO.getManegerName()) + .eqIfPresent(DepotDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(DepotDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(DepotDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(DepotDO::getCompany, reqVO.getCompany()) + .eqIfPresent(DepotDO::getRemark, reqVO.getRemark()) + .eqIfPresent(DepotDO::getUserId, reqVO.getUserId()) + .likeIfPresent(DepotDO::getOrganizationName, reqVO.getOrganizationName()) + .eqIfPresent(DepotDO::getOrganizationCode, reqVO.getOrganizationCode()) + .orderByDesc(DepotDO::getId)); + } + @Select("SELECT d.id AS depotId, d.name AS depotName, d.code AS depotCode, " + + "c.id AS cabinetId, c.name AS cabinetName, c.code AS cabinetCode " + + "FROM setting_depot d " + + "JOIN setting_depot_cabinet c ON d.id = c.depot_id " + + "WHERE d.organization_id = #{organizationId}") + @Results({ + @Result(property = "depotId", column = "depotId"), + @Result(property = "depotName", column = "depotName"), + @Result(property = "depotCode", column = "depotCode"), + @Result(property = "children", column = "depotId",javaType = List.class, + many=@Many(select="cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet.DepotCabinetMapper.getCabinetByDepot")) + }) + List getDepotCabinetByOrganization(Long organizationId); +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depotcabinet/DepotCabinetMapper.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depotcabinet/DepotCabinetMapper.java new file mode 100644 index 00000000..c4577b8d --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/depotcabinet/DepotCabinetMapper.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet; + +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.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import org.apache.ibatis.annotations.Select; + +/** + * 档案柜管理 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DepotCabinetMapper extends BaseMapperX { + + default PageResult selectPage(DepotCabinetPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DepotCabinetDO::getDepotId, reqVO.getDepotId()) + .likeIfPresent(DepotCabinetDO::getName, reqVO.getName()) + .eqIfPresent(DepotCabinetDO::getCode, reqVO.getCode()) + .eqIfPresent(DepotCabinetDO::getAddress, reqVO.getAddress()) + .eqIfPresent(DepotCabinetDO::getManegerId, reqVO.getManegerId()) + .betweenIfPresent(DepotCabinetDO::getCreateTime, reqVO.getCreateTime()) + .likeIfPresent(DepotCabinetDO::getManegerName, reqVO.getManegerName()) + .eqIfPresent(DepotCabinetDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(DepotCabinetDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(DepotCabinetDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(DepotCabinetDO::getCompany, reqVO.getCompany()) + .eqIfPresent(DepotCabinetDO::getUserId, reqVO.getUserId()) + .eqIfPresent(DepotCabinetDO::getRemark, reqVO.getRemark()) + .orderByDesc(DepotCabinetDO::getId)); + } + + default List selectList(DepotCabinetExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(DepotCabinetDO::getDepotId, reqVO.getDepotId()) + .likeIfPresent(DepotCabinetDO::getName, reqVO.getName()) + .eqIfPresent(DepotCabinetDO::getCode, reqVO.getCode()) + .eqIfPresent(DepotCabinetDO::getAddress, reqVO.getAddress()) + .eqIfPresent(DepotCabinetDO::getManegerId, reqVO.getManegerId()) + .betweenIfPresent(DepotCabinetDO::getCreateTime, reqVO.getCreateTime()) + .likeIfPresent(DepotCabinetDO::getManegerName, reqVO.getManegerName()) + .eqIfPresent(DepotCabinetDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(DepotCabinetDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(DepotCabinetDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(DepotCabinetDO::getCompany, reqVO.getCompany()) + .eqIfPresent(DepotCabinetDO::getUserId, reqVO.getUserId()) + .eqIfPresent(DepotCabinetDO::getRemark, reqVO.getRemark()) + .orderByDesc(DepotCabinetDO::getId)); + } + @Select("SELECT id AS cabinetId, name AS cabinetName, code AS cabinetCode " + + "FROM setting_depot_cabinet " + + "WHERE depot_id = #{depotId}") + List getCabinetByDepot(Long depotId); +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/organization/OrganizationMapper.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/organization/OrganizationMapper.java new file mode 100644 index 00000000..6b3ab6e3 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/dal/mysql/organization/OrganizationMapper.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.setting.dal.mysql.organization; + +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.setting.controller.admin.depot.vo.OrganizationDepotVO; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import org.apache.ibatis.annotations.*; +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; + +/** + * 立档单位 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface OrganizationMapper extends BaseMapperX { + + default PageResult selectPage(OrganizationPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(OrganizationDO::getOrganizationName, reqVO.getOrganizationName()) + .eqIfPresent(OrganizationDO::getOrganizationCode, reqVO.getOrganizationCode()) + .eqIfPresent(OrganizationDO::getCaseNum, reqVO.getCaseNum()) + .eqIfPresent(OrganizationDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(OrganizationDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(OrganizationDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(OrganizationDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(OrganizationDO::getUserId, reqVO.getUserId()) + .eqIfPresent(OrganizationDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(OrganizationDO::getCompany, reqVO.getCompany()) + .orderByDesc(OrganizationDO::getId)); + } + + default List selectList(OrganizationExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(OrganizationDO::getOrganizationName, reqVO.getOrganizationName()) + .eqIfPresent(OrganizationDO::getOrganizationCode, reqVO.getOrganizationCode()) + .eqIfPresent(OrganizationDO::getCaseNum, reqVO.getCaseNum()) + .eqIfPresent(OrganizationDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(OrganizationDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(OrganizationDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(OrganizationDO::getDeptName, reqVO.getDeptName()) + .eqIfPresent(OrganizationDO::getUserId, reqVO.getUserId()) + .eqIfPresent(OrganizationDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(OrganizationDO::getCompany, reqVO.getCompany()) + .orderByDesc(OrganizationDO::getId)); + } + + @Select("SELECT o.id AS organizationId, o.organization_name AS organizationName, o.organization_code AS organizationCode, " + + "d.id AS depotId, d.name AS depotName, d.code AS depotCode, " + + "c.id AS cabinetId, c.name AS cabinetName, c.code AS cabinetCode " + + "FROM setting_organization o " + + "LEFT JOIN setting_depot d ON o.id = d.organization_id " + + "LEFT JOIN setting_depot_cabinet c ON d.id = c.depot_id ") + @Results({ + @Result(property = "organizationId", column = "organizationId"), + @Result(property = "organizationName", column = "organizationName"), + @Result(property = "organizationCode", column = "organizationCode"), + @Result(property = "children", column = "organizationId",javaType = List.class, + many=@Many(select="cn.iocoder.yudao.module.setting.dal.mysql.depot.DepotMapper.getDepotCabinetByOrganization")) + }) + List getOrganizationDepotCabinets(); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/framework/datapermission/config/DataPermissionConfigurationSetting.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/framework/datapermission/config/DataPermissionConfigurationSetting.java new file mode 100644 index 00000000..3ec28b89 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/framework/datapermission/config/DataPermissionConfigurationSetting.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.setting.framework.datapermission.config; + +import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * archives 模块的数据权限 Configuration + * + * @author 芋道源码 + */ +@Configuration(proxyBeanMethods = false) +public class DataPermissionConfigurationSetting { + + @Bean + public DeptDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizerSetting() { + return rule -> { + // dept + rule.addDeptColumn(OrganizationDO.class); + rule.addDeptColumn(DeptDO.class, "id"); + + // user + rule.addUserColumn(OrganizationDO.class); + rule.addUserColumn(AdminUserDO.class,"id"); + }; + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotService.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotService.java new file mode 100644 index 00000000..d14751f2 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.setting.service.depot; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 库房管理 Service 接口 + * + * @author 芋道源码 + */ +public interface DepotService { + + /** + * 创建库房管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDepot(@Valid DepotCreateReqVO createReqVO); + + /** + * 更新库房管理 + * + * @param updateReqVO 更新信息 + */ + void updateDepot(@Valid DepotUpdateReqVO updateReqVO); + + /** + * 删除库房管理 + * + * @param id 编号 + */ + void deleteDepot(Long id); + + /** + * 获得库房管理 + * + * @param id 编号 + * @return 库房管理 + */ + DepotDO getDepot(Long id); + + /** + * 获得库房管理列表 + * + * @param ids 编号 + * @return 库房管理列表 + */ + List getDepotList(Collection ids); + + /** + * 获得库房管理分页 + * + * @param pageReqVO 分页查询 + * @return 库房管理分页 + */ + PageResult getDepotPage(DepotPageReqVO pageReqVO); + + /** + * 获得库房管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 库房管理列表 + */ + List getDepotList(DepotExportReqVO exportReqVO); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImpl.java new file mode 100644 index 00000000..56040c2a --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImpl.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.setting.service.depot; + +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.setting.convert.depot.DepotConvert; +import cn.iocoder.yudao.module.setting.dal.mysql.depot.DepotMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; + +/** + * 库房管理 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DepotServiceImpl implements DepotService { + + @Resource + private DepotMapper depotMapper; + @Resource + private AdminUserMapper userMapper; + + @Override + public Long createDepot(DepotCreateReqVO createReqVO) { + // 插入 + DepotDO depot = DepotConvert.INSTANCE.convert(createReqVO); + //添加数据userid + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + depot.setUserId(loginUser.getId()); + AdminUserDO adminUserDO = userMapper.selectById(loginUser.getId()); + //添加数据部门id,后续DataPermissionConfigurationRecord配置类中过滤数据 + depot.setDeptId(adminUserDO.getDeptId()); + depotMapper.insert(depot); + // 返回 + return depot.getId(); + } + + @Override + public void updateDepot(DepotUpdateReqVO updateReqVO) { + // 校验存在 + validateDepotExists(updateReqVO.getId()); + // 更新 + DepotDO updateObj = DepotConvert.INSTANCE.convert(updateReqVO); + depotMapper.updateById(updateObj); + } + + @Override + public void deleteDepot(Long id) { + // 校验存在 + validateDepotExists(id); + // 删除 + depotMapper.deleteById(id); + } + + private void validateDepotExists(Long id) { + if (depotMapper.selectById(id) == null) { + throw exception(DEPOT_NOT_EXISTS); + } + } + + @Override + public DepotDO getDepot(Long id) { + return depotMapper.selectById(id); + } + + @Override + public List getDepotList(Collection ids) { + return depotMapper.selectBatchIds(ids); + } + + @Override + public PageResult getDepotPage(DepotPageReqVO pageReqVO) { + return depotMapper.selectPage(pageReqVO); + } + + @Override + public List getDepotList(DepotExportReqVO exportReqVO) { + return depotMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetService.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetService.java new file mode 100644 index 00000000..7547891a --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.setting.service.depotcabinet; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 档案柜管理 Service 接口 + * + * @author 芋道源码 + */ +public interface DepotCabinetService { + + /** + * 创建档案柜管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDepotCabinet(@Valid DepotCabinetCreateReqVO createReqVO); + + /** + * 更新档案柜管理 + * + * @param updateReqVO 更新信息 + */ + void updateDepotCabinet(@Valid DepotCabinetUpdateReqVO updateReqVO); + + /** + * 删除档案柜管理 + * + * @param id 编号 + */ + void deleteDepotCabinet(Long id); + + /** + * 获得档案柜管理 + * + * @param id 编号 + * @return 档案柜管理 + */ + DepotCabinetDO getDepotCabinet(Long id); + + /** + * 获得档案柜管理列表 + * + * @param ids 编号 + * @return 档案柜管理列表 + */ + List getDepotCabinetList(Collection ids); + + /** + * 获得档案柜管理分页 + * + * @param pageReqVO 分页查询 + * @return 档案柜管理分页 + */ + PageResult getDepotCabinetPage(DepotCabinetPageReqVO pageReqVO); + + /** + * 获得档案柜管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 档案柜管理列表 + */ + List getDepotCabinetList(DepotCabinetExportReqVO exportReqVO); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImpl.java new file mode 100644 index 00000000..f7a3a9bc --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImpl.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.setting.service.depotcabinet; + +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.setting.convert.depotcabinet.DepotCabinetConvert; +import cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet.DepotCabinetMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; + +/** + * 档案柜管理 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DepotCabinetServiceImpl implements DepotCabinetService { + + @Resource + private DepotCabinetMapper depotCabinetMapper; + @Resource + private AdminUserMapper userMapper; + + @Override + public Long createDepotCabinet(DepotCabinetCreateReqVO createReqVO) { + // 插入 + DepotCabinetDO depotCabinet = DepotCabinetConvert.INSTANCE.convert(createReqVO); + //添加数据userid + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + depotCabinet.setUserId(loginUser.getId()); + AdminUserDO adminUserDO = userMapper.selectById(loginUser.getId()); + //添加数据部门id,后续DataPermissionConfigurationRecord配置类中过滤数据 + depotCabinet.setDeptId(adminUserDO.getDeptId()); + depotCabinetMapper.insert(depotCabinet); + // 返回 + return depotCabinet.getId(); + } + + @Override + public void updateDepotCabinet(DepotCabinetUpdateReqVO updateReqVO) { + // 校验存在 + validateDepotCabinetExists(updateReqVO.getId()); + // 更新 + DepotCabinetDO updateObj = DepotCabinetConvert.INSTANCE.convert(updateReqVO); + depotCabinetMapper.updateById(updateObj); + } + + @Override + public void deleteDepotCabinet(Long id) { + // 校验存在 + validateDepotCabinetExists(id); + // 删除 + depotCabinetMapper.deleteById(id); + } + + private void validateDepotCabinetExists(Long id) { + if (depotCabinetMapper.selectById(id) == null) { + throw exception(DEPOT_CABINET_NOT_EXISTS); + } + } + + @Override + public DepotCabinetDO getDepotCabinet(Long id) { + return depotCabinetMapper.selectById(id); + } + + @Override + public List getDepotCabinetList(Collection ids) { + return depotCabinetMapper.selectBatchIds(ids); + } + + @Override + public PageResult getDepotCabinetPage(DepotCabinetPageReqVO pageReqVO) { + return depotCabinetMapper.selectPage(pageReqVO); + } + + @Override + public List getDepotCabinetList(DepotCabinetExportReqVO exportReqVO) { + return depotCabinetMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationService.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationService.java new file mode 100644 index 00000000..8ae63540 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationService.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.setting.service.organization; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.OrganizationDepotVO; +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 立档单位 Service 接口 + * + * @author 芋道源码 + */ +public interface OrganizationService { + + List getOrganizationTree(); + + /** + * 创建立档单位 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createOrganization(@Valid OrganizationCreateReqVO createReqVO); + + /** + * 更新立档单位 + * + * @param updateReqVO 更新信息 + */ + void updateOrganization(@Valid OrganizationUpdateReqVO updateReqVO); + + /** + * 删除立档单位 + * + * @param id 编号 + */ + void deleteOrganization(Long id); + + /** + * 获得立档单位 + * + * @param id 编号 + * @return 立档单位 + */ + OrganizationDO getOrganization(Long id); + + /** + * 获得立档单位列表 + * + * @param ids 编号 + * @return 立档单位列表 + */ + List getOrganizationList(Collection ids); + + /** + * 获得立档单位分页 + * + * @param pageReqVO 分页查询 + * @return 立档单位分页 + */ + PageResult getOrganizationPage(OrganizationPageReqVO pageReqVO); + + /** + * 获得立档单位列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 立档单位列表 + */ + List getOrganizationList(OrganizationExportReqVO exportReqVO); + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java new file mode 100644 index 00000000..a8212a86 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java @@ -0,0 +1,157 @@ +package cn.iocoder.yudao.module.setting.service.organization; + +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.DepotVo; +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.OrganizationDepotVO; +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.DepotCabinetVo; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.setting.convert.organization.OrganizationConvert; +import cn.iocoder.yudao.module.setting.dal.mysql.organization.OrganizationMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; + +/** + * 立档单位 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class OrganizationServiceImpl implements OrganizationService { + + @Resource + private OrganizationMapper organizationMapper; + @Resource + private AdminUserMapper userMapper; + + @Override + public Long createOrganization(OrganizationCreateReqVO createReqVO) { + // 插入 + OrganizationDO organization = OrganizationConvert.INSTANCE.convert(createReqVO); + //添加数据userid + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + organization.setUserId(loginUser.getId()); + AdminUserDO adminUserDO = userMapper.selectById(loginUser.getId()); + //添加数据部门id,后续DataPermissionConfigurationRecord配置类中过滤数据 + organization.setDeptId(adminUserDO.getDeptId()); + organizationMapper.insert(organization); + // 返回 + return organization.getId(); + } + + @Override + public void updateOrganization(OrganizationUpdateReqVO updateReqVO) { + // 校验存在 + validateOrganizationExists(updateReqVO.getId()); + // 更新 + OrganizationDO updateObj = OrganizationConvert.INSTANCE.convert(updateReqVO); + organizationMapper.updateById(updateObj); + } + + @Override + public void deleteOrganization(Long id) { + // 校验存在 + validateOrganizationExists(id); + // 删除 + organizationMapper.deleteById(id); + } + + private void validateOrganizationExists(Long id) { + if (organizationMapper.selectById(id) == null) { + throw exception(ORGANIZATION_NOT_EXISTS); + } + } + + @Override + public OrganizationDO getOrganization(Long id) { + return organizationMapper.selectById(id); + } + + @Override + public List getOrganizationList(Collection ids) { + return organizationMapper.selectBatchIds(ids); + } + + @Override + public PageResult getOrganizationPage(OrganizationPageReqVO pageReqVO) { + return organizationMapper.selectPage(pageReqVO); + } + + @Override + public List getOrganizationList(OrganizationExportReqVO exportReqVO) { + return organizationMapper.selectList(exportReqVO); + } + + @Override + public List getOrganizationTree() { + List organizationDepotCabinets = organizationMapper.getOrganizationDepotCabinets(); + List merge = this.merge(organizationDepotCabinets); + return merge; + } + + public List merge(List list) { + List result = new ArrayList<>(); + Map map = new HashMap<>(); + for (OrganizationDepotVO vo : list) { + Long id = vo.getOrganizationId(); + if (!map.containsKey(id)) { + map.put(id, vo); + result.add(vo); + } else { + OrganizationDepotVO existing = map.get(id); + existing.getChildren().addAll(vo.getChildren()); + } + } + // 合并 children 中相同 depotId 的数据 + for (OrganizationDepotVO vo : result) { + mergeChildren(vo.getChildren()); + } + return result; + } + private void mergeChildren(List children) { + Map map = new HashMap<>(); + List newChildren = new ArrayList<>(); + for (DepotVo vo : children) { + Long id = vo.getDepotId(); + if (!map.containsKey(id)) { + map.put(id, vo); + newChildren.add(vo); + }else { + DepotVo existing = map.get(id); + existing.getChildren().addAll(vo.getChildren()); + } + } + children.clear(); + children.addAll(newChildren); + for (DepotVo depotVo : children){ + removeDuplicate(depotVo.getChildren()); + } + + } + + public List removeDuplicate(List list) { + Set set = new HashSet<>(); + Iterator it = list.iterator(); + while (it.hasNext()) { + DepotCabinetVo vo = it.next(); + if (!set.add(vo.getCabinetId())) { + it.remove(); + } + } + return list; + } + + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depot/DepotMapper.xml b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depot/DepotMapper.xml new file mode 100644 index 00000000..d6d5141f --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depot/DepotMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depotcabinet/DepotCabinetMapper.xml b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depotcabinet/DepotCabinetMapper.xml new file mode 100644 index 00000000..bbf425f2 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/depotcabinet/DepotCabinetMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/organization/OrganizationMapper.xml b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/organization/OrganizationMapper.xml new file mode 100644 index 00000000..857d6cd5 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/resources/mapper/organization/OrganizationMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImplTest.java b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImplTest.java new file mode 100644 index 00000000..5594178d --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depot/DepotServiceImplTest.java @@ -0,0 +1,263 @@ +package cn.iocoder.yudao.module.setting.service.depot; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.setting.controller.admin.depot.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.module.setting.dal.mysql.depot.DepotMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DepotServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DepotServiceImpl.class) +public class DepotServiceImplTest extends BaseDbUnitTest { + + @Resource + private DepotServiceImpl depotService; + + @Resource + private DepotMapper depotMapper; + + @Test + public void testCreateDepot_success() { + // 准备参数 + DepotCreateReqVO reqVO = randomPojo(DepotCreateReqVO.class); + + // 调用 + Long depotId = depotService.createDepot(reqVO); + // 断言 + assertNotNull(depotId); + // 校验记录的属性是否正确 + DepotDO depot = depotMapper.selectById(depotId); + assertPojoEquals(reqVO, depot); + } + + @Test + public void testUpdateDepot_success() { + // mock 数据 + DepotDO dbDepot = randomPojo(DepotDO.class); + depotMapper.insert(dbDepot);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DepotUpdateReqVO reqVO = randomPojo(DepotUpdateReqVO.class, o -> { + o.setId(dbDepot.getId()); // 设置更新的 ID + }); + + // 调用 + depotService.updateDepot(reqVO); + // 校验是否更新正确 + DepotDO depot = depotMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, depot); + } + + @Test + public void testUpdateDepot_notExists() { + // 准备参数 + DepotUpdateReqVO reqVO = randomPojo(DepotUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> depotService.updateDepot(reqVO), DEPOT_NOT_EXISTS); + } + + @Test + public void testDeleteDepot_success() { + // mock 数据 + DepotDO dbDepot = randomPojo(DepotDO.class); + depotMapper.insert(dbDepot);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDepot.getId(); + + // 调用 + depotService.deleteDepot(id); + // 校验数据不存在了 + assertNull(depotMapper.selectById(id)); + } + + @Test + public void testDeleteDepot_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> depotService.deleteDepot(id), DEPOT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDepotPage() { + // mock 数据 + DepotDO dbDepot = randomPojo(DepotDO.class, o -> { // 等会查询到 + o.setName(null); + o.setCode(null); + o.setAddress(null); + o.setOrganizationId(null); + o.setManegerId(null); + o.setCreateTime(null); + o.setManegerName(null); + o.setDeptId(null); + o.setDeptName(null); + o.setCompanyId(null); + o.setCompany(null); + o.setRemark(null); + o.setUserId(null); + o.setOrganizationName(null); + o.setOrganizationCode(null); + }); + depotMapper.insert(dbDepot); + // 测试 name 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setName(null))); + // 测试 code 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCode(null))); + // 测试 address 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setAddress(null))); + // 测试 organizationId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationId(null))); + // 测试 manegerId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setManegerId(null))); + // 测试 createTime 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCreateTime(null))); + // 测试 manegerName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setManegerName(null))); + // 测试 deptId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setDeptName(null))); + // 测试 companyId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCompany(null))); + // 测试 remark 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setRemark(null))); + // 测试 userId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setUserId(null))); + // 测试 organizationName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationName(null))); + // 测试 organizationCode 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationCode(null))); + // 准备参数 + DepotPageReqVO reqVO = new DepotPageReqVO(); + reqVO.setName(null); + reqVO.setCode(null); + reqVO.setAddress(null); + reqVO.setOrganizationId(null); + reqVO.setManegerId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setManegerName(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setRemark(null); + reqVO.setUserId(null); + reqVO.setOrganizationName(null); + reqVO.setOrganizationCode(null); + + // 调用 + PageResult pageResult = depotService.getDepotPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDepot, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDepotList() { + // mock 数据 + DepotDO dbDepot = randomPojo(DepotDO.class, o -> { // 等会查询到 + o.setName(null); + o.setCode(null); + o.setAddress(null); + o.setOrganizationId(null); + o.setManegerId(null); + o.setCreateTime(null); + o.setManegerName(null); + o.setDeptId(null); + o.setDeptName(null); + o.setCompanyId(null); + o.setCompany(null); + o.setRemark(null); + o.setUserId(null); + o.setOrganizationName(null); + o.setOrganizationCode(null); + }); + depotMapper.insert(dbDepot); + // 测试 name 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setName(null))); + // 测试 code 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCode(null))); + // 测试 address 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setAddress(null))); + // 测试 organizationId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationId(null))); + // 测试 manegerId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setManegerId(null))); + // 测试 createTime 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCreateTime(null))); + // 测试 manegerName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setManegerName(null))); + // 测试 deptId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setDeptName(null))); + // 测试 companyId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setCompany(null))); + // 测试 remark 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setRemark(null))); + // 测试 userId 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setUserId(null))); + // 测试 organizationName 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationName(null))); + // 测试 organizationCode 不匹配 + depotMapper.insert(cloneIgnoreId(dbDepot, o -> o.setOrganizationCode(null))); + // 准备参数 + DepotExportReqVO reqVO = new DepotExportReqVO(); + reqVO.setName(null); + reqVO.setCode(null); + reqVO.setAddress(null); + reqVO.setOrganizationId(null); + reqVO.setManegerId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setManegerName(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setRemark(null); + reqVO.setUserId(null); + reqVO.setOrganizationName(null); + reqVO.setOrganizationCode(null); + + // 调用 + List list = depotService.getDepotList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbDepot, list.get(0)); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImplTest.java b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImplTest.java new file mode 100644 index 00000000..4cd410c1 --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/depotcabinet/DepotCabinetServiceImplTest.java @@ -0,0 +1,247 @@ +package cn.iocoder.yudao.module.setting.service.depotcabinet; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.setting.controller.admin.depotcabinet.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet.DepotCabinetMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DepotCabinetServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DepotCabinetServiceImpl.class) +public class DepotCabinetServiceImplTest extends BaseDbUnitTest { + + @Resource + private DepotCabinetServiceImpl depotCabinetService; + + @Resource + private DepotCabinetMapper depotCabinetMapper; + + @Test + public void testCreateDepotCabinet_success() { + // 准备参数 + DepotCabinetCreateReqVO reqVO = randomPojo(DepotCabinetCreateReqVO.class); + + // 调用 + Long depotCabinetId = depotCabinetService.createDepotCabinet(reqVO); + // 断言 + assertNotNull(depotCabinetId); + // 校验记录的属性是否正确 + DepotCabinetDO depotCabinet = depotCabinetMapper.selectById(depotCabinetId); + assertPojoEquals(reqVO, depotCabinet); + } + + @Test + public void testUpdateDepotCabinet_success() { + // mock 数据 + DepotCabinetDO dbDepotCabinet = randomPojo(DepotCabinetDO.class); + depotCabinetMapper.insert(dbDepotCabinet);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DepotCabinetUpdateReqVO reqVO = randomPojo(DepotCabinetUpdateReqVO.class, o -> { + o.setId(dbDepotCabinet.getId()); // 设置更新的 ID + }); + + // 调用 + depotCabinetService.updateDepotCabinet(reqVO); + // 校验是否更新正确 + DepotCabinetDO depotCabinet = depotCabinetMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, depotCabinet); + } + + @Test + public void testUpdateDepotCabinet_notExists() { + // 准备参数 + DepotCabinetUpdateReqVO reqVO = randomPojo(DepotCabinetUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> depotCabinetService.updateDepotCabinet(reqVO), DEPOT_CABINET_NOT_EXISTS); + } + + @Test + public void testDeleteDepotCabinet_success() { + // mock 数据 + DepotCabinetDO dbDepotCabinet = randomPojo(DepotCabinetDO.class); + depotCabinetMapper.insert(dbDepotCabinet);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDepotCabinet.getId(); + + // 调用 + depotCabinetService.deleteDepotCabinet(id); + // 校验数据不存在了 + assertNull(depotCabinetMapper.selectById(id)); + } + + @Test + public void testDeleteDepotCabinet_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> depotCabinetService.deleteDepotCabinet(id), DEPOT_CABINET_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDepotCabinetPage() { + // mock 数据 + DepotCabinetDO dbDepotCabinet = randomPojo(DepotCabinetDO.class, o -> { // 等会查询到 + o.setDepotId(null); + o.setName(null); + o.setCode(null); + o.setAddress(null); + o.setManegerId(null); + o.setCreateTime(null); + o.setManegerName(null); + o.setDeptId(null); + o.setDeptName(null); + o.setCompanyId(null); + o.setCompany(null); + o.setUserId(null); + o.setRemark(null); + }); + depotCabinetMapper.insert(dbDepotCabinet); + // 测试 depotId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDepotId(null))); + // 测试 name 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setName(null))); + // 测试 code 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCode(null))); + // 测试 address 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setAddress(null))); + // 测试 manegerId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setManegerId(null))); + // 测试 createTime 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCreateTime(null))); + // 测试 manegerName 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setManegerName(null))); + // 测试 deptId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDeptName(null))); + // 测试 companyId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCompany(null))); + // 测试 userId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setUserId(null))); + // 测试 remark 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setRemark(null))); + // 准备参数 + DepotCabinetPageReqVO reqVO = new DepotCabinetPageReqVO(); + reqVO.setDepotId(null); + reqVO.setName(null); + reqVO.setCode(null); + reqVO.setAddress(null); + reqVO.setManegerId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setManegerName(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setUserId(null); + reqVO.setRemark(null); + + // 调用 + PageResult pageResult = depotCabinetService.getDepotCabinetPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDepotCabinet, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDepotCabinetList() { + // mock 数据 + DepotCabinetDO dbDepotCabinet = randomPojo(DepotCabinetDO.class, o -> { // 等会查询到 + o.setDepotId(null); + o.setName(null); + o.setCode(null); + o.setAddress(null); + o.setManegerId(null); + o.setCreateTime(null); + o.setManegerName(null); + o.setDeptId(null); + o.setDeptName(null); + o.setCompanyId(null); + o.setCompany(null); + o.setUserId(null); + o.setRemark(null); + }); + depotCabinetMapper.insert(dbDepotCabinet); + // 测试 depotId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDepotId(null))); + // 测试 name 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setName(null))); + // 测试 code 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCode(null))); + // 测试 address 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setAddress(null))); + // 测试 manegerId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setManegerId(null))); + // 测试 createTime 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCreateTime(null))); + // 测试 manegerName 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setManegerName(null))); + // 测试 deptId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setDeptName(null))); + // 测试 companyId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setCompany(null))); + // 测试 userId 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setUserId(null))); + // 测试 remark 不匹配 + depotCabinetMapper.insert(cloneIgnoreId(dbDepotCabinet, o -> o.setRemark(null))); + // 准备参数 + DepotCabinetExportReqVO reqVO = new DepotCabinetExportReqVO(); + reqVO.setDepotId(null); + reqVO.setName(null); + reqVO.setCode(null); + reqVO.setAddress(null); + reqVO.setManegerId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setManegerName(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setUserId(null); + reqVO.setRemark(null); + + // 调用 + List list = depotCabinetService.getDepotCabinetList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbDepotCabinet, list.get(0)); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImplTest.java b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImplTest.java new file mode 100644 index 00000000..793e7faf --- /dev/null +++ b/yudao-module-setting/yudao-module-setting-biz/src/test/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImplTest.java @@ -0,0 +1,223 @@ +package cn.iocoder.yudao.module.setting.service.organization; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.setting.controller.admin.organization.vo.*; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.module.setting.dal.mysql.organization.OrganizationMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link OrganizationServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(OrganizationServiceImpl.class) +public class OrganizationServiceImplTest extends BaseDbUnitTest { + + @Resource + private OrganizationServiceImpl organizationService; + + @Resource + private OrganizationMapper organizationMapper; + + @Test + public void testCreateOrganization_success() { + // 准备参数 + OrganizationCreateReqVO reqVO = randomPojo(OrganizationCreateReqVO.class); + + // 调用 + Long organizationId = organizationService.createOrganization(reqVO); + // 断言 + assertNotNull(organizationId); + // 校验记录的属性是否正确 + OrganizationDO organization = organizationMapper.selectById(organizationId); + assertPojoEquals(reqVO, organization); + } + + @Test + public void testUpdateOrganization_success() { + // mock 数据 + OrganizationDO dbOrganization = randomPojo(OrganizationDO.class); + organizationMapper.insert(dbOrganization);// @Sql: 先插入出一条存在的数据 + // 准备参数 + OrganizationUpdateReqVO reqVO = randomPojo(OrganizationUpdateReqVO.class, o -> { + o.setId(dbOrganization.getId()); // 设置更新的 ID + }); + + // 调用 + organizationService.updateOrganization(reqVO); + // 校验是否更新正确 + OrganizationDO organization = organizationMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, organization); + } + + @Test + public void testUpdateOrganization_notExists() { + // 准备参数 + OrganizationUpdateReqVO reqVO = randomPojo(OrganizationUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> organizationService.updateOrganization(reqVO), ORGANIZATION_NOT_EXISTS); + } + + @Test + public void testDeleteOrganization_success() { + // mock 数据 + OrganizationDO dbOrganization = randomPojo(OrganizationDO.class); + organizationMapper.insert(dbOrganization);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbOrganization.getId(); + + // 调用 + organizationService.deleteOrganization(id); + // 校验数据不存在了 + assertNull(organizationMapper.selectById(id)); + } + + @Test + public void testDeleteOrganization_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> organizationService.deleteOrganization(id), ORGANIZATION_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetOrganizationPage() { + // mock 数据 + OrganizationDO dbOrganization = randomPojo(OrganizationDO.class, o -> { // 等会查询到 + o.setOrganizationName(null); + o.setOrganizationCode(null); + o.setCaseNum(null); + o.setRemark(null); + o.setCreateTime(null); + o.setDeptId(null); + o.setDeptName(null); + o.setUserId(null); + o.setCompanyId(null); + o.setCompany(null); + }); + organizationMapper.insert(dbOrganization); + // 测试 organizationName 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setOrganizationName(null))); + // 测试 organizationCode 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setOrganizationCode(null))); + // 测试 caseNum 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCaseNum(null))); + // 测试 remark 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCreateTime(null))); + // 测试 deptId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setDeptName(null))); + // 测试 userId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setUserId(null))); + // 测试 companyId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCompany(null))); + // 准备参数 + OrganizationPageReqVO reqVO = new OrganizationPageReqVO(); + reqVO.setOrganizationName(null); + reqVO.setOrganizationCode(null); + reqVO.setCaseNum(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setUserId(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + + // 调用 + PageResult pageResult = organizationService.getOrganizationPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbOrganization, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetOrganizationList() { + // mock 数据 + OrganizationDO dbOrganization = randomPojo(OrganizationDO.class, o -> { // 等会查询到 + o.setOrganizationName(null); + o.setOrganizationCode(null); + o.setCaseNum(null); + o.setRemark(null); + o.setCreateTime(null); + o.setDeptId(null); + o.setDeptName(null); + o.setUserId(null); + o.setCompanyId(null); + o.setCompany(null); + }); + organizationMapper.insert(dbOrganization); + // 测试 organizationName 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setOrganizationName(null))); + // 测试 organizationCode 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setOrganizationCode(null))); + // 测试 caseNum 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCaseNum(null))); + // 测试 remark 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCreateTime(null))); + // 测试 deptId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setDeptName(null))); + // 测试 userId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setUserId(null))); + // 测试 companyId 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + organizationMapper.insert(cloneIgnoreId(dbOrganization, o -> o.setCompany(null))); + // 准备参数 + OrganizationExportReqVO reqVO = new OrganizationExportReqVO(); + reqVO.setOrganizationName(null); + reqVO.setOrganizationCode(null); + reqVO.setCaseNum(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setUserId(null); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + + // 调用 + List list = organizationService.getOrganizationList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbOrganization, list.get(0)); + } + +} diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index d2d0fa0b..fb9349d6 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -27,11 +27,18 @@ yudao-module-bs-biz ${revision} + cn.iocoder.boot yudao-module-archives-biz ${revision} + + + cn.iocoder.boot + yudao-module-setting-biz + ${revision} + cn.iocoder.boot yudao-module-member-biz