立档单位-库房-档案柜

new
JilingLee 1 year ago
parent 67ef100fe2
commit cdf5209581

@ -25,6 +25,7 @@
<!-- <module>yudao-example</module>-->
<module>yudao-module-bs</module>
<module>yudao-module-archives</module>
<module>yudao-module-setting</module>
</modules>
<name>${project.artifactId}</name>

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>yudao-module-setting-api</module>
<module>yudao-module-setting-biz</module>
</modules>
<artifactId>yudao-module-setting</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
档案设置业务模块
</description>
<dependencies>
<dependency>
<groupId>com.baidu.aip</groupId>
<artifactId>java-sdk</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.80</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-setting</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-setting-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
setting 模块 API暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

@ -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, "库房管理不存在");
}

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-setting</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-setting-biz</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
setting 模块,主要实现商品相关功能
例如品牌、商品分类、spu、sku等功能。
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-setting-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-api</artifactId>
<version>1.7.3-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>1.7.3-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

@ -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<Long> createDepot(@Valid @RequestBody DepotCreateReqVO createReqVO) {
DepotExportReqVO depotExportReqVO = new DepotExportReqVO();
//不能重复
depotExportReqVO.setCode(createReqVO.getCode());
List<DepotDO> depotList = depotService.getDepotList(depotExportReqVO);
if (depotList.size()>0){
return error("库房编码不能重复!");
}
//不能重复
depotExportReqVO.setCode(null);
depotExportReqVO.setName(createReqVO.getName());
List<DepotDO> 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<Boolean> updateDepot(@Valid @RequestBody DepotUpdateReqVO updateReqVO) {
DepotExportReqVO depotExportReqVO = new DepotExportReqVO();
//不能重复
depotExportReqVO.setCode(updateReqVO.getCode());
List<DepotDO> depotList = depotService.getDepotList(depotExportReqVO);
if (depotList.size()>0){
return error("库房编码不能重复!");
}
//不能重复
depotExportReqVO.setCode(null);
depotExportReqVO.setName(updateReqVO.getName());
List<DepotDO> 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<Boolean> 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<DepotRespVO> 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<List<DepotRespVO>> getDepotList(@RequestParam("ids") Collection<Long> ids) {
List<DepotDO> list = depotService.getDepotList(ids);
return success(DepotConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得库房管理分页")
@PreAuthorize("@ss.hasPermission('setting:depot:query')")
@DataPermission
public CommonResult<PageResult<DepotRespVO>> getDepotPage(@Valid DepotPageReqVO pageVO) {
PageResult<DepotDO> 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<DepotDO> list = depotService.getDepotList(exportReqVO);
// 导出 Excel
List<DepotExcelVO> datas = DepotConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "库房管理.xls", "数据", DepotExcelVO.class, datas);
}
}

@ -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;
}

@ -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 {
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<DepotCabinetVo> children;
}

@ -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<DepotVo> children;
}

@ -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<Long> createDepotCabinet(@Valid @RequestBody DepotCabinetCreateReqVO createReqVO) {
DepotCabinetExportReqVO depotCabinetExportReqVO = new DepotCabinetExportReqVO();
//不能重复
depotCabinetExportReqVO.setCode(createReqVO.getCode());
List<DepotCabinetDO> depotCabinetList = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO);
if (depotCabinetList.size()>0){
return error("档案柜编码不能重复!");
}
//不能重复
depotCabinetExportReqVO.setCode(null);
depotCabinetExportReqVO.setName(createReqVO.getName());
List<DepotCabinetDO> 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<Boolean> updateDepotCabinet(@Valid @RequestBody DepotCabinetUpdateReqVO updateReqVO) {
DepotCabinetExportReqVO depotCabinetExportReqVO = new DepotCabinetExportReqVO();
//不能重复
depotCabinetExportReqVO.setCode(updateReqVO.getCode());
List<DepotCabinetDO> depotCabinetList = depotCabinetService.getDepotCabinetList(depotCabinetExportReqVO);
if (depotCabinetList.size()>0){
return error("档案柜编码不能重复!");
}
//不能重复
depotCabinetExportReqVO.setCode(null);
depotCabinetExportReqVO.setName(updateReqVO.getName());
List<DepotCabinetDO> 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<Boolean> 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<DepotCabinetRespVO> 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<List<DepotCabinetRespVO>> getDepotCabinetList(@RequestParam("ids") Collection<Long> ids) {
List<DepotCabinetDO> list = depotCabinetService.getDepotCabinetList(ids);
return success(DepotCabinetConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得档案柜管理分页")
@PreAuthorize("@ss.hasPermission('setting:depot-cabinet:query')")
@DataPermission
public CommonResult<PageResult<DepotCabinetRespVO>> getDepotCabinetPage(@Valid DepotCabinetPageReqVO pageVO) {
PageResult<DepotCabinetDO> 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<DepotCabinetDO> list = depotCabinetService.getDepotCabinetList(exportReqVO);
// 导出 Excel
List<DepotCabinetExcelVO> datas = DepotCabinetConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "档案柜管理.xls", "数据", DepotCabinetExcelVO.class, datas);
}
}

@ -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;
}

@ -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 {
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<Long> createOrganization(@Valid @RequestBody OrganizationCreateReqVO createReqVO) {
OrganizationExportReqVO organizationExportReqVO = new OrganizationExportReqVO();
//立档单位编码不能重复
organizationExportReqVO.setOrganizationCode(createReqVO.getOrganizationCode());
List<OrganizationDO> organizationList = organizationService.getOrganizationList(organizationExportReqVO);
if (organizationList.size()>0){
return error("立档单位编码不能重复!");
}
//立档单位名称不能重复
organizationExportReqVO.setOrganizationCode(null);
organizationExportReqVO.setOrganizationName(createReqVO.getOrganizationName());
List<OrganizationDO> 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<Boolean> updateOrganization(@Valid @RequestBody OrganizationUpdateReqVO updateReqVO) {
OrganizationExportReqVO organizationExportReqVO = new OrganizationExportReqVO();
//立档单位编码不能重复
organizationExportReqVO.setOrganizationCode(updateReqVO.getOrganizationCode());
List<OrganizationDO> organizationList = organizationService.getOrganizationList(organizationExportReqVO);
if (organizationList.size()>0){
return error("立档单位编码不能重复!");
}
//立档单位名称不能重复
organizationExportReqVO.setOrganizationCode(null);
organizationExportReqVO.setOrganizationName(updateReqVO.getOrganizationName());
List<OrganizationDO> 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<Boolean> 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<OrganizationRespVO> 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<List<OrganizationDepotVO>> 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<List<OrganizationRespVO>> getOrganizationList(@RequestParam("ids") Collection<Long> ids) {
List<OrganizationDO> list = organizationService.getOrganizationList(ids);
return success(OrganizationConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得立档单位分页")
@PreAuthorize("@ss.hasPermission('setting:organization:query')")
@DataPermission
public CommonResult<PageResult<OrganizationRespVO>> getOrganizationPage(@Valid OrganizationPageReqVO pageVO) {
PageResult<OrganizationDO> 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<OrganizationDO> list = organizationService.getOrganizationList(exportReqVO);
// 导出 Excel
List<OrganizationExcelVO> datas = OrganizationConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "立档单位.xls", "数据", OrganizationExcelVO.class, datas);
}
}

@ -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;
}

@ -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 {
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<DepotRespVO> convertList(List<DepotDO> list);
PageResult<DepotRespVO> convertPage(PageResult<DepotDO> page);
List<DepotExcelVO> convertList02(List<DepotDO> list);
}

@ -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<DepotCabinetRespVO> convertList(List<DepotCabinetDO> list);
PageResult<DepotCabinetRespVO> convertPage(PageResult<DepotCabinetDO> page);
List<DepotCabinetExcelVO> convertList02(List<DepotCabinetDO> list);
}

@ -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<OrganizationRespVO> convertList(List<OrganizationDO> list);
PageResult<OrganizationRespVO> convertPage(PageResult<OrganizationDO> page);
List<OrganizationExcelVO> convertList02(List<OrganizationDO> list);
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<DepotDO> {
default PageResult<DepotDO> selectPage(DepotPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DepotDO>()
.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<DepotDO> selectList(DepotExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DepotDO>()
.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<DepotVo> getDepotCabinetByOrganization(Long organizationId);
}

@ -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<DepotCabinetDO> {
default PageResult<DepotCabinetDO> selectPage(DepotCabinetPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DepotCabinetDO>()
.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<DepotCabinetDO> selectList(DepotCabinetExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DepotCabinetDO>()
.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<DepotCabinetVo> getCabinetByDepot(Long depotId);
}

@ -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<OrganizationDO> {
default PageResult<OrganizationDO> selectPage(OrganizationPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<OrganizationDO>()
.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<OrganizationDO> selectList(OrganizationExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<OrganizationDO>()
.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<OrganizationDepotVO> getOrganizationDepotCabinets();
}

@ -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");
};
}
}

@ -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<DepotDO> getDepotList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<DepotDO> getDepotPage(DepotPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<DepotDO> getDepotList(DepotExportReqVO exportReqVO);
}

@ -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<DepotDO> getDepotList(Collection<Long> ids) {
return depotMapper.selectBatchIds(ids);
}
@Override
public PageResult<DepotDO> getDepotPage(DepotPageReqVO pageReqVO) {
return depotMapper.selectPage(pageReqVO);
}
@Override
public List<DepotDO> getDepotList(DepotExportReqVO exportReqVO) {
return depotMapper.selectList(exportReqVO);
}
}

@ -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<DepotCabinetDO> getDepotCabinetList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<DepotCabinetDO> getDepotCabinetPage(DepotCabinetPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<DepotCabinetDO> getDepotCabinetList(DepotCabinetExportReqVO exportReqVO);
}

@ -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<DepotCabinetDO> getDepotCabinetList(Collection<Long> ids) {
return depotCabinetMapper.selectBatchIds(ids);
}
@Override
public PageResult<DepotCabinetDO> getDepotCabinetPage(DepotCabinetPageReqVO pageReqVO) {
return depotCabinetMapper.selectPage(pageReqVO);
}
@Override
public List<DepotCabinetDO> getDepotCabinetList(DepotCabinetExportReqVO exportReqVO) {
return depotCabinetMapper.selectList(exportReqVO);
}
}

@ -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<OrganizationDepotVO> 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<OrganizationDO> getOrganizationList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<OrganizationDO> getOrganizationPage(OrganizationPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<OrganizationDO> getOrganizationList(OrganizationExportReqVO exportReqVO);
}

@ -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<OrganizationDO> getOrganizationList(Collection<Long> ids) {
return organizationMapper.selectBatchIds(ids);
}
@Override
public PageResult<OrganizationDO> getOrganizationPage(OrganizationPageReqVO pageReqVO) {
return organizationMapper.selectPage(pageReqVO);
}
@Override
public List<OrganizationDO> getOrganizationList(OrganizationExportReqVO exportReqVO) {
return organizationMapper.selectList(exportReqVO);
}
@Override
public List<OrganizationDepotVO> getOrganizationTree() {
List<OrganizationDepotVO> organizationDepotCabinets = organizationMapper.getOrganizationDepotCabinets();
List<OrganizationDepotVO> merge = this.merge(organizationDepotCabinets);
return merge;
}
public List<OrganizationDepotVO> merge(List<OrganizationDepotVO> list) {
List<OrganizationDepotVO> result = new ArrayList<>();
Map<Long, OrganizationDepotVO> 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<DepotVo> children) {
Map<Long, DepotVo> map = new HashMap<>();
List<DepotVo> 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<DepotCabinetVo> removeDuplicate(List<DepotCabinetVo> list) {
Set<Long> set = new HashSet<>();
Iterator<DepotCabinetVo> it = list.iterator();
while (it.hasNext()) {
DepotCabinetVo vo = it.next();
if (!set.add(vo.getCabinetId())) {
it.remove();
}
}
return list;
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.setting.dal.mysql.depot.DepotMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet.DepotCabinetMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.setting.dal.mysql.organization.OrganizationMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -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<DepotDO> 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<DepotDO> list = depotService.getDepotList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbDepot, list.get(0));
}
}

@ -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<DepotCabinetDO> 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<DepotCabinetDO> list = depotCabinetService.getDepotCabinetList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbDepotCabinet, list.get(0));
}
}

@ -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<OrganizationDO> 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<OrganizationDO> list = organizationService.getOrganizationList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbOrganization, list.get(0));
}
}

@ -27,11 +27,18 @@
<artifactId>yudao-module-bs-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- 档案管理 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-archives-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- 档案设置 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-setting-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-biz</artifactId>

Loading…
Cancel
Save