diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/BusinessWarehouseController.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/BusinessWarehouseController.java new file mode 100644 index 0000000..abf091e --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/BusinessWarehouseController.java @@ -0,0 +1,102 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse; + +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 com.yunxi.scm.framework.common.pojo.PageResult; +import com.yunxi.scm.framework.common.pojo.CommonResult; +import static com.yunxi.scm.framework.common.pojo.CommonResult.success; + +import com.yunxi.scm.framework.excel.core.util.ExcelUtils; + +import com.yunxi.scm.framework.operatelog.core.annotations.OperateLog; +import static com.yunxi.scm.framework.operatelog.core.enums.OperateTypeEnum.*; + +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; +import com.yunxi.scm.module.xxjj.convert.businesswarehouse.BusinessWarehouseConvert; +import com.yunxi.scm.module.xxjj.service.businesswarehouse.BusinessWarehouseService; + +@Tag(name = "管理后台 - 业务线/仓库") +@RestController +@RequestMapping("/xxjj/business-warehouse") +@Validated +public class BusinessWarehouseController { + + @Resource + private BusinessWarehouseService businessWarehouseService; + + @PostMapping("/create") + @Operation(summary = "创建业务线/仓库") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:create')") + public CommonResult createBusinessWarehouse(@Valid @RequestBody BusinessWarehouseCreateReqVO createReqVO) { + return success(businessWarehouseService.createBusinessWarehouse(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新业务线/仓库") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:update')") + public CommonResult updateBusinessWarehouse(@Valid @RequestBody BusinessWarehouseUpdateReqVO updateReqVO) { + businessWarehouseService.updateBusinessWarehouse(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除业务线/仓库") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:delete')") + public CommonResult deleteBusinessWarehouse(@RequestParam("id") Long id) { + businessWarehouseService.deleteBusinessWarehouse(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得业务线/仓库") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')") + public CommonResult getBusinessWarehouse(@RequestParam("id") Long id) { + BusinessWarehouseDO businessWarehouse = businessWarehouseService.getBusinessWarehouse(id); + return success(BusinessWarehouseConvert.INSTANCE.convert(businessWarehouse)); + } + + @GetMapping("/list") + @Operation(summary = "获得业务线/仓库列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')") + public CommonResult> getBusinessWarehouseList(@RequestParam("ids") Collection ids) { + List list = businessWarehouseService.getBusinessWarehouseList(ids); + return success(BusinessWarehouseConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得业务线/仓库分页") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')") + public CommonResult> getBusinessWarehousePage(@Valid BusinessWarehousePageReqVO pageVO) { + PageResult pageResult = businessWarehouseService.getBusinessWarehousePage(pageVO); + return success(BusinessWarehouseConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出业务线/仓库 Excel") + @PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:export')") + @OperateLog(type = EXPORT) + public void exportBusinessWarehouseExcel(@Valid BusinessWarehouseExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = businessWarehouseService.getBusinessWarehouseList(exportReqVO); + // 导出 Excel + List datas = BusinessWarehouseConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "业务线/仓库.xls", "数据", BusinessWarehouseExcelVO.class, datas); + } + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseBaseVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseBaseVO.java new file mode 100644 index 0000000..7249b34 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseBaseVO.java @@ -0,0 +1,72 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 业务线/仓库 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class BusinessWarehouseBaseVO { + + @Schema(description = "业务线编号", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "业务线编号不能为空") + private String businessCode; + + @Schema(description = "业务线名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @NotNull(message = "业务线名称不能为空") + private String name; + + @Schema(description = "业务线简称") + private String businessSimple; + + @Schema(description = "业务线LOGO") + private String businessLogo; + + @Schema(description = "父id") + private Long parentId; + + @Schema(description = "类型") + private String type; + + @Schema(description = "所属行业") + private String industry; + + @Schema(description = "所在城市") + private String city; + + @Schema(description = "成立时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime establishDate; + + @Schema(description = "归属人员") + private Long belongUserId; + + @Schema(description = "品牌/业务线/事业群名称") + private String brandName; + + @Schema(description = "电话") + private Integer phone; + + @Schema(description = "传真") + private String fax; + + @Schema(description = "网址", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "介绍", example = "你猜") + private String description; + + @Schema(description = "介绍", example = "你猜") + private String diffFlag; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseCreateReqVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseCreateReqVO.java new file mode 100644 index 0000000..18dd2d9 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseCreateReqVO.java @@ -0,0 +1,14 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.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 BusinessWarehouseCreateReqVO extends BusinessWarehouseBaseVO { + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExcelVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExcelVO.java new file mode 100644 index 0000000..712cd68 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExcelVO.java @@ -0,0 +1,78 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.yunxi.scm.framework.excel.core.annotations.DictFormat; +import com.yunxi.scm.framework.excel.core.convert.DictConvert; + + +/** + * 业务线/仓库 Excel VO + * + * @author 长江云息 + */ +@Data +public class BusinessWarehouseExcelVO { + + @ExcelProperty("业务id") + private Long id; + + @ExcelProperty("业务线编号") + private String businessCode; + + @ExcelProperty("业务线名称") + private String name; + + @ExcelProperty("业务线简称") + private String businessSimple; + + @ExcelProperty("业务线LOGO") + private String businessLogo; + + @ExcelProperty("父id") + private Long parentId; + + @ExcelProperty("类型") + private String type; + + @ExcelProperty(value = "所属行业", converter = DictConvert.class) + @DictFormat("duty_type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String industry; + + @ExcelProperty("所在城市") + private String city; + + @ExcelProperty("成立时间") + private LocalDateTime establishDate; + + @ExcelProperty("归属人员") + private Long belongUserId; + + @ExcelProperty("品牌/业务线/事业群名称") + private String brandName; + + @ExcelProperty("电话") + private Integer phone; + + @ExcelProperty("传真") + private String fax; + + @ExcelProperty("网址") + private String url; + + @ExcelProperty("介绍") + private String description; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("区分标志") + private String diffFlag; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExportReqVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExportReqVO.java new file mode 100644 index 0000000..7a7379d --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseExportReqVO.java @@ -0,0 +1,69 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.yunxi.scm.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 业务线/仓库 Excel 导出 Request VO,参数和 BusinessWarehousePageReqVO 是一致的") +@Data +public class BusinessWarehouseExportReqVO { + + @Schema(description = "业务线编号") + private String businessCode; + + @Schema(description = "业务线名称", example = "张三") + private String name; + + @Schema(description = "业务线简称") + private String businessSimple; + + @Schema(description = "业务线LOGO") + private String businessLogo; + + @Schema(description = "父id", example = "6675") + private Long parentId; + + @Schema(description = "类型", example = "1") + private String type; + + @Schema(description = "所属行业") + private String industry; + + @Schema(description = "所在城市") + private String city; + + @Schema(description = "成立时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] establishDate; + + @Schema(description = "归属人员", example = "19777") + private Long belongUserId; + + @Schema(description = "品牌/业务线/事业群名称", example = "王五") + private String brandName; + + @Schema(description = "电话") + private Integer phone; + + @Schema(description = "传真") + private String fax; + + @Schema(description = "网址", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "介绍", example = "你猜") + private String description; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "区分标志", example = "你猜") + private String diffFlag; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehousePageReqVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehousePageReqVO.java new file mode 100644 index 0000000..f14c7eb --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehousePageReqVO.java @@ -0,0 +1,71 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.yunxi.scm.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.yunxi.scm.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 BusinessWarehousePageReqVO extends PageParam { + + @Schema(description = "业务线编号") + private String businessCode; + + @Schema(description = "业务线名称", example = "张三") + private String name; + + @Schema(description = "业务线简称") + private String businessSimple; + + @Schema(description = "业务线LOGO") + private String businessLogo; + + @Schema(description = "父id", example = "6675") + private Long parentId; + + @Schema(description = "类型", example = "1") + private String type; + + @Schema(description = "所属行业") + private String industry; + + @Schema(description = "所在城市") + private String city; + + @Schema(description = "成立时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] establishDate; + + @Schema(description = "归属人员", example = "19777") + private Long belongUserId; + + @Schema(description = "品牌/业务线/事业群名称", example = "王五") + private String brandName; + + @Schema(description = "电话") + private Integer phone; + + @Schema(description = "传真") + private String fax; + + @Schema(description = "网址", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "介绍", example = "你猜") + private String description; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "区分标志", example = "你猜") + private String diffFlag; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseRespVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseRespVO.java new file mode 100644 index 0000000..279a688 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseRespVO.java @@ -0,0 +1,19 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.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 BusinessWarehouseRespVO extends BusinessWarehouseBaseVO { + + @Schema(description = "业务id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27714") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseUpdateReqVO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseUpdateReqVO.java new file mode 100644 index 0000000..1051779 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/controller/admin/businesswarehouse/vo/BusinessWarehouseUpdateReqVO.java @@ -0,0 +1,18 @@ +package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.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 BusinessWarehouseUpdateReqVO extends BusinessWarehouseBaseVO { + + @Schema(description = "业务id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27714") + @NotNull(message = "业务id不能为空") + private Long id; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/convert/businesswarehouse/BusinessWarehouseConvert.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/convert/businesswarehouse/BusinessWarehouseConvert.java new file mode 100644 index 0000000..93423df --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/convert/businesswarehouse/BusinessWarehouseConvert.java @@ -0,0 +1,34 @@ +package com.yunxi.scm.module.xxjj.convert.businesswarehouse; + +import java.util.*; + +import com.yunxi.scm.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; + +/** + * 业务线/仓库 Convert + * + * @author 长江云息 + */ +@Mapper +public interface BusinessWarehouseConvert { + + BusinessWarehouseConvert INSTANCE = Mappers.getMapper(BusinessWarehouseConvert.class); + + BusinessWarehouseDO convert(BusinessWarehouseCreateReqVO bean); + + BusinessWarehouseDO convert(BusinessWarehouseUpdateReqVO bean); + + BusinessWarehouseRespVO convert(BusinessWarehouseDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/dataobject/businesswarehouse/BusinessWarehouseDO.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/dataobject/businesswarehouse/BusinessWarehouseDO.java new file mode 100644 index 0000000..eda440d --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/dataobject/businesswarehouse/BusinessWarehouseDO.java @@ -0,0 +1,98 @@ +package com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.yunxi.scm.framework.mybatis.core.dataobject.BaseDO; + +/** + * 业务线/仓库 DO + * + * @author 长江云息 + */ +@TableName("xxjj_business_warehouse") +@KeySequence("xxjj_business_warehouse_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BusinessWarehouseDO extends BaseDO { + + /** + * 业务id + */ + @TableId + private Long id; + /** + * 业务线编号 + */ + private String businessCode; + /** + * 业务线名称 + */ + private String name; + /** + * 业务线简称 + */ + private String businessSimple; + /** + * 业务线LOGO + */ + private String businessLogo; + /** + * 父id + */ + private Long parentId; + /** + * 类型 + */ + private String type; + /** + * 所属行业 + * + * 枚举 {@link TODO duty_type 对应的类} + */ + private String industry; + /** + * 所在城市 + */ + private String city; + /** + * 成立时间 + */ + private LocalDateTime establishDate; + /** + * 归属人员 + */ + private Long belongUserId; + /** + * 品牌/业务线/事业群名称 + */ + private String brandName; + /** + * 电话 + */ + private Integer phone; + /** + * 传真 + */ + private String fax; + /** + * 网址 + */ + private String url; + /** + * 介绍 + */ + private String description; + /** + * 区分标志 + */ + private String diffFlag; + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/mysql/businesswarehouse/BusinessWarehouseMapper.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/mysql/businesswarehouse/BusinessWarehouseMapper.java new file mode 100644 index 0000000..8f26c81 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/dal/mysql/businesswarehouse/BusinessWarehouseMapper.java @@ -0,0 +1,62 @@ +package com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse; + +import java.util.*; + +import com.yunxi.scm.framework.common.pojo.PageResult; +import com.yunxi.scm.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.yunxi.scm.framework.mybatis.core.mapper.BaseMapperX; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; +import org.apache.ibatis.annotations.Mapper; +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; + +/** + * 业务线/仓库 Mapper + * + * @author 长江云息 + */ +@Mapper +public interface BusinessWarehouseMapper extends BaseMapperX { + + default PageResult selectPage(BusinessWarehousePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(BusinessWarehouseDO::getBusinessCode, reqVO.getBusinessCode()) + .likeIfPresent(BusinessWarehouseDO::getName, reqVO.getName()) + .eqIfPresent(BusinessWarehouseDO::getBusinessSimple, reqVO.getBusinessSimple()) + .eqIfPresent(BusinessWarehouseDO::getBusinessLogo, reqVO.getBusinessLogo()) + .eqIfPresent(BusinessWarehouseDO::getParentId, reqVO.getParentId()) + .eqIfPresent(BusinessWarehouseDO::getType, reqVO.getType()) + .eqIfPresent(BusinessWarehouseDO::getIndustry, reqVO.getIndustry()) + .eqIfPresent(BusinessWarehouseDO::getCity, reqVO.getCity()) + .betweenIfPresent(BusinessWarehouseDO::getEstablishDate, reqVO.getEstablishDate()) + .eqIfPresent(BusinessWarehouseDO::getBelongUserId, reqVO.getBelongUserId()) + .likeIfPresent(BusinessWarehouseDO::getBrandName, reqVO.getBrandName()) + .eqIfPresent(BusinessWarehouseDO::getPhone, reqVO.getPhone()) + .eqIfPresent(BusinessWarehouseDO::getFax, reqVO.getFax()) + .eqIfPresent(BusinessWarehouseDO::getUrl, reqVO.getUrl()) + .eqIfPresent(BusinessWarehouseDO::getDescription, reqVO.getDescription()) + .betweenIfPresent(BusinessWarehouseDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BusinessWarehouseDO::getId)); + } + + default List selectList(BusinessWarehouseExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(BusinessWarehouseDO::getBusinessCode, reqVO.getBusinessCode()) + .likeIfPresent(BusinessWarehouseDO::getName, reqVO.getName()) + .eqIfPresent(BusinessWarehouseDO::getBusinessSimple, reqVO.getBusinessSimple()) + .eqIfPresent(BusinessWarehouseDO::getBusinessLogo, reqVO.getBusinessLogo()) + .eqIfPresent(BusinessWarehouseDO::getParentId, reqVO.getParentId()) + .eqIfPresent(BusinessWarehouseDO::getType, reqVO.getType()) + .eqIfPresent(BusinessWarehouseDO::getIndustry, reqVO.getIndustry()) + .eqIfPresent(BusinessWarehouseDO::getCity, reqVO.getCity()) + .betweenIfPresent(BusinessWarehouseDO::getEstablishDate, reqVO.getEstablishDate()) + .eqIfPresent(BusinessWarehouseDO::getBelongUserId, reqVO.getBelongUserId()) + .likeIfPresent(BusinessWarehouseDO::getBrandName, reqVO.getBrandName()) + .eqIfPresent(BusinessWarehouseDO::getPhone, reqVO.getPhone()) + .eqIfPresent(BusinessWarehouseDO::getFax, reqVO.getFax()) + .eqIfPresent(BusinessWarehouseDO::getUrl, reqVO.getUrl()) + .eqIfPresent(BusinessWarehouseDO::getDescription, reqVO.getDescription()) + .betweenIfPresent(BusinessWarehouseDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BusinessWarehouseDO::getId)); + } + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/enums/ErrorCodeConstants.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/enums/ErrorCodeConstants.java index d68ba57..502c1dc 100644 --- a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/enums/ErrorCodeConstants.java +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/enums/ErrorCodeConstants.java @@ -41,6 +41,8 @@ public interface ErrorCodeConstants { // ========== 质检报告 TODO 补充编号 ========== ErrorCode QUALITY_INSPECTION_NOT_EXISTS = new ErrorCode(1002025114, "质检报告不存在"); + // ========== 业务线/仓库 TODO 补充编号 ========== + ErrorCode BUSINESS_WAREHOUSE_NOT_EXISTS = new ErrorCode(1002025019, "业务线/仓库不存在"); // ========== 部门模块 1002004000 ========== diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseService.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseService.java new file mode 100644 index 0000000..97a1b9d --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseService.java @@ -0,0 +1,70 @@ +package com.yunxi.scm.module.xxjj.service.businesswarehouse; + +import java.util.*; +import javax.validation.*; +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; +import com.yunxi.scm.framework.common.pojo.PageResult; + +/** + * 业务线/仓库 Service 接口 + * + * @author 长江云息 + */ +public interface BusinessWarehouseService { + + /** + * 创建业务线/仓库 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBusinessWarehouse(@Valid BusinessWarehouseCreateReqVO createReqVO); + + /** + * 更新业务线/仓库 + * + * @param updateReqVO 更新信息 + */ + void updateBusinessWarehouse(@Valid BusinessWarehouseUpdateReqVO updateReqVO); + + /** + * 删除业务线/仓库 + * + * @param id 编号 + */ + void deleteBusinessWarehouse(Long id); + + /** + * 获得业务线/仓库 + * + * @param id 编号 + * @return 业务线/仓库 + */ + BusinessWarehouseDO getBusinessWarehouse(Long id); + + /** + * 获得业务线/仓库列表 + * + * @param ids 编号 + * @return 业务线/仓库列表 + */ + List getBusinessWarehouseList(Collection ids); + + /** + * 获得业务线/仓库分页 + * + * @param pageReqVO 分页查询 + * @return 业务线/仓库分页 + */ + PageResult getBusinessWarehousePage(BusinessWarehousePageReqVO pageReqVO); + + /** + * 获得业务线/仓库列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 业务线/仓库列表 + */ + List getBusinessWarehouseList(BusinessWarehouseExportReqVO exportReqVO); + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImpl.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImpl.java new file mode 100644 index 0000000..c5b56c4 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImpl.java @@ -0,0 +1,82 @@ +package com.yunxi.scm.module.xxjj.service.businesswarehouse; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; +import com.yunxi.scm.framework.common.pojo.PageResult; + +import com.yunxi.scm.module.xxjj.convert.businesswarehouse.BusinessWarehouseConvert; +import com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse.BusinessWarehouseMapper; + +import static com.yunxi.scm.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.yunxi.scm.module.xxjj.enums.ErrorCodeConstants.*; + +/** + * 业务线/仓库 Service 实现类 + * + * @author 长江云息 + */ +@Service +@Validated +public class BusinessWarehouseServiceImpl implements BusinessWarehouseService { + + @Resource + private BusinessWarehouseMapper businessWarehouseMapper; + + @Override + public Long createBusinessWarehouse(BusinessWarehouseCreateReqVO createReqVO) { + // 插入 + BusinessWarehouseDO businessWarehouse = BusinessWarehouseConvert.INSTANCE.convert(createReqVO); + businessWarehouseMapper.insert(businessWarehouse); + // 返回 + return businessWarehouse.getId(); + } + + @Override + public void updateBusinessWarehouse(BusinessWarehouseUpdateReqVO updateReqVO) { + // 校验存在 + validateBusinessWarehouseExists(updateReqVO.getId()); + // 更新 + BusinessWarehouseDO updateObj = BusinessWarehouseConvert.INSTANCE.convert(updateReqVO); + businessWarehouseMapper.updateById(updateObj); + } + + @Override + public void deleteBusinessWarehouse(Long id) { + // 校验存在 + validateBusinessWarehouseExists(id); + // 删除 + businessWarehouseMapper.deleteById(id); + } + + private void validateBusinessWarehouseExists(Long id) { + if (businessWarehouseMapper.selectById(id) == null) { + throw exception(BUSINESS_WAREHOUSE_NOT_EXISTS); + } + } + + @Override + public BusinessWarehouseDO getBusinessWarehouse(Long id) { + return businessWarehouseMapper.selectById(id); + } + + @Override + public List getBusinessWarehouseList(Collection ids) { + return businessWarehouseMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBusinessWarehousePage(BusinessWarehousePageReqVO pageReqVO) { + return businessWarehouseMapper.selectPage(pageReqVO); + } + + @Override + public List getBusinessWarehouseList(BusinessWarehouseExportReqVO exportReqVO) { + return businessWarehouseMapper.selectList(exportReqVO); + } + +} diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/resources/mapper/businesswarehouse/BusinessWarehouseMapper.xml b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/resources/mapper/businesswarehouse/BusinessWarehouseMapper.xml new file mode 100644 index 0000000..ab94ac8 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/main/resources/mapper/businesswarehouse/BusinessWarehouseMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/test/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImplTest.java b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/test/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImplTest.java new file mode 100644 index 0000000..de89295 --- /dev/null +++ b/yunxi-module-xxjj/yunxi-module-xxjj-biz/src/test/java/com/yunxi/scm/module/xxjj/service/businesswarehouse/BusinessWarehouseServiceImplTest.java @@ -0,0 +1,278 @@ +package com.yunxi.scm.module.xxjj.service.businesswarehouse; + +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 com.yunxi.scm.framework.test.core.ut.BaseDbUnitTest; + +import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*; +import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO; +import com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse.BusinessWarehouseMapper; +import com.yunxi.scm.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 com.yunxi.scm.module.xxjj.enums.ErrorCodeConstants.*; +import static com.yunxi.scm.framework.test.core.util.AssertUtils.*; +import static com.yunxi.scm.framework.test.core.util.RandomUtils.*; +import static com.yunxi.scm.framework.common.util.date.LocalDateTimeUtils.*; +import static com.yunxi.scm.framework.common.util.object.ObjectUtils.*; +import static com.yunxi.scm.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link BusinessWarehouseServiceImpl} 的单元测试类 + * + * @author 长江云息 + */ +@Import(BusinessWarehouseServiceImpl.class) +public class BusinessWarehouseServiceImplTest extends BaseDbUnitTest { + + @Resource + private BusinessWarehouseServiceImpl businessWarehouseService; + + @Resource + private BusinessWarehouseMapper businessWarehouseMapper; + + @Test + public void testCreateBusinessWarehouse_success() { + // 准备参数 + BusinessWarehouseCreateReqVO reqVO = randomPojo(BusinessWarehouseCreateReqVO.class); + + // 调用 + Long businessWarehouseId = businessWarehouseService.createBusinessWarehouse(reqVO); + // 断言 + assertNotNull(businessWarehouseId); + // 校验记录的属性是否正确 + BusinessWarehouseDO businessWarehouse = businessWarehouseMapper.selectById(businessWarehouseId); + assertPojoEquals(reqVO, businessWarehouse); + } + + @Test + public void testUpdateBusinessWarehouse_success() { + // mock 数据 + BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class); + businessWarehouseMapper.insert(dbBusinessWarehouse);// @Sql: 先插入出一条存在的数据 + // 准备参数 + BusinessWarehouseUpdateReqVO reqVO = randomPojo(BusinessWarehouseUpdateReqVO.class, o -> { + o.setId(dbBusinessWarehouse.getId()); // 设置更新的 ID + }); + + // 调用 + businessWarehouseService.updateBusinessWarehouse(reqVO); + // 校验是否更新正确 + BusinessWarehouseDO businessWarehouse = businessWarehouseMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, businessWarehouse); + } + + @Test + public void testUpdateBusinessWarehouse_notExists() { + // 准备参数 + BusinessWarehouseUpdateReqVO reqVO = randomPojo(BusinessWarehouseUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> businessWarehouseService.updateBusinessWarehouse(reqVO), BUSINESS_WAREHOUSE_NOT_EXISTS); + } + + @Test + public void testDeleteBusinessWarehouse_success() { + // mock 数据 + BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class); + businessWarehouseMapper.insert(dbBusinessWarehouse);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbBusinessWarehouse.getId(); + + // 调用 + businessWarehouseService.deleteBusinessWarehouse(id); + // 校验数据不存在了 + assertNull(businessWarehouseMapper.selectById(id)); + } + + @Test + public void testDeleteBusinessWarehouse_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> businessWarehouseService.deleteBusinessWarehouse(id), BUSINESS_WAREHOUSE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessWarehousePage() { + // mock 数据 + BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class, o -> { // 等会查询到 + o.setBusinessCode(null); + o.setName(null); + o.setBusinessSimple(null); + o.setBusinessLogo(null); + o.setParentId(null); + o.setType(null); + o.setIndustry(null); + o.setCity(null); + o.setEstablishDate(null); + o.setBelongUserId(null); + o.setBrandName(null); + o.setPhone(null); + o.setFax(null); + o.setUrl(null); + o.setDescription(null); + o.setCreateTime(null); + o.setDiffFlag(null); + }); + businessWarehouseMapper.insert(dbBusinessWarehouse); + // 测试 businessCode 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessCode(null))); + // 测试 businessName 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setName(null))); + // 测试 businessSimple 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessSimple(null))); + // 测试 businessLogo 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessLogo(null))); + // 测试 parentId 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setParentId(null))); + // 测试 type 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setType(null))); + // 测试 industry 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setIndustry(null))); + // 测试 city 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCity(null))); + // 测试 establishDate 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setEstablishDate(null))); + // 测试 belongUserId 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBelongUserId(null))); + // 测试 brandName 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBrandName(null))); + // 测试 phone 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setPhone(null))); + // 测试 fax 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setFax(null))); + // 测试 url 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setUrl(null))); + // 测试 description 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDescription(null))); + // 测试 createTime 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCreateTime(null))); + // 测试 diffFlag 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDiffFlag(null))); + // 准备参数 + BusinessWarehousePageReqVO reqVO = new BusinessWarehousePageReqVO(); + reqVO.setBusinessCode(null); + reqVO.setName(null); + reqVO.setBusinessSimple(null); + reqVO.setBusinessLogo(null); + reqVO.setParentId(null); + reqVO.setType(null); + reqVO.setIndustry(null); + reqVO.setCity(null); + reqVO.setEstablishDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setBelongUserId(null); + reqVO.setBrandName(null); + reqVO.setPhone(null); + reqVO.setFax(null); + reqVO.setUrl(null); + reqVO.setDescription(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDiffFlag(null); + // 调用 + PageResult pageResult = businessWarehouseService.getBusinessWarehousePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBusinessWarehouse, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessWarehouseList() { + // mock 数据 + BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class, o -> { // 等会查询到 + o.setBusinessCode(null); + o.setName(null); + o.setBusinessSimple(null); + o.setBusinessLogo(null); + o.setParentId(null); + o.setType(null); + o.setIndustry(null); + o.setCity(null); + o.setEstablishDate(null); + o.setBelongUserId(null); + o.setBrandName(null); + o.setPhone(null); + o.setFax(null); + o.setUrl(null); + o.setDescription(null); + o.setCreateTime(null); + o.setDiffFlag(null); + }); + businessWarehouseMapper.insert(dbBusinessWarehouse); + // 测试 businessCode 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessCode(null))); + // 测试 businessName 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setName(null))); + // 测试 businessSimple 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessSimple(null))); + // 测试 businessLogo 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessLogo(null))); + // 测试 parentId 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setParentId(null))); + // 测试 type 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setType(null))); + // 测试 industry 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setIndustry(null))); + // 测试 city 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCity(null))); + // 测试 establishDate 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setEstablishDate(null))); + // 测试 belongUserId 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBelongUserId(null))); + // 测试 brandName 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBrandName(null))); + // 测试 phone 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setPhone(null))); + // 测试 fax 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setFax(null))); + // 测试 url 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setUrl(null))); + // 测试 description 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDescription(null))); + // 测试 createTime 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCreateTime(null))); + // 测试 diffFlag 不匹配 + businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDiffFlag(null))); + // 准备参数 + BusinessWarehouseExportReqVO reqVO = new BusinessWarehouseExportReqVO(); + reqVO.setBusinessCode(null); + reqVO.setName(null); + reqVO.setBusinessSimple(null); + reqVO.setBusinessLogo(null); + reqVO.setParentId(null); + reqVO.setType(null); + reqVO.setIndustry(null); + reqVO.setCity(null); + reqVO.setEstablishDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setBelongUserId(null); + reqVO.setBrandName(null); + reqVO.setPhone(null); + reqVO.setFax(null); + reqVO.setUrl(null); + reqVO.setDescription(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDiffFlag(null); + + // 调用 + List list = businessWarehouseService.getBusinessWarehouseList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbBusinessWarehouse, list.get(0)); + } + +} diff --git a/yunxi-ui-admin/src/api/xxjj/businessWarehouse.js b/yunxi-ui-admin/src/api/xxjj/businessWarehouse.js new file mode 100644 index 0000000..3dce853 --- /dev/null +++ b/yunxi-ui-admin/src/api/xxjj/businessWarehouse.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建业务线/仓库 +export function createBusinessWarehouse(data) { + return request({ + url: '/xxjj/business-warehouse/create', + method: 'post', + data: data + }) +} + +// 更新业务线/仓库 +export function updateBusinessWarehouse(data) { + return request({ + url: '/xxjj/business-warehouse/update', + method: 'put', + data: data + }) +} + +// 删除业务线/仓库 +export function deleteBusinessWarehouse(id) { + return request({ + url: '/xxjj/business-warehouse/delete?id=' + id, + method: 'delete' + }) +} + +// 获得业务线/仓库 +export function getBusinessWarehouse(id) { + return request({ + url: '/xxjj/business-warehouse/get?id=' + id, + method: 'get' + }) +} + +// 获得业务线/仓库分页 +export function getBusinessWarehousePage(query) { + return request({ + url: '/xxjj/business-warehouse/page', + method: 'get', + params: query + }) +} + +// 导出业务线/仓库 Excel +export function exportBusinessWarehouseExcel(query) { + return request({ + url: '/xxjj/business-warehouse/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/yunxi-ui-admin/src/utils/dict.js b/yunxi-ui-admin/src/utils/dict.js index c6a4ef8..8bda124 100644 --- a/yunxi-ui-admin/src/utils/dict.js +++ b/yunxi-ui-admin/src/utils/dict.js @@ -105,6 +105,7 @@ export const DICT_TYPE = { // ============= BUSINESSLINE 模块================= BUSINESS_TYPE: 'business_type', //业务线类型 + DIFF_FLAG: 'diff_flag', // ============= WAREHOUSE 模块================= WAREHOUSE_TYPE: 'warehouse_type', //仓库类型 diff --git a/yunxi-ui-admin/src/views/system/user/index.vue b/yunxi-ui-admin/src/views/system/user/index.vue index 1ad8996..8717d0b 100644 --- a/yunxi-ui-admin/src/views/system/user/index.vue +++ b/yunxi-ui-admin/src/views/system/user/index.vue @@ -2,99 +2,275 @@
- +
- +
- +
- + - + - + - - + + - + - 搜索 - 重置 + 搜索 + 重置 - 新增 + 新增 - 导入 + 导入 - 导出 + 导出 - + - - - - - - + + + + + + - + - + - +
@@ -109,32 +285,59 @@ - + - + - + - + - - + + @@ -142,7 +345,12 @@ - + @@ -150,10 +358,10 @@ @@ -162,7 +370,11 @@ - + @@ -174,18 +386,39 @@ - - + +
将文件拖到此处,或点击上传
- 是否更新已经存在的用户数据 + + 是否更新已经存在的用户数据
仅允许导入xls、xlsx格式文件。 - 下载模板 + 下载模板
-
@@ -233,19 +470,19 @@ import { importTemplate, listUser, resetUserPwd, - updateUser + updateUser, } from "@/api/system/user"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; -import {listSimpleDepts} from "@/api/system/dept"; -import {listSimplePosts} from "@/api/system/post"; +import { listSimpleDepts } from "@/api/system/dept"; +import { listSimplePosts } from "@/api/system/post"; -import {CommonStatusEnum} from "@/utils/constants"; -import {DICT_TYPE, getDictDatas} from "@/utils/dict"; -import {assignUserRole, listUserRoles} from "@/api/system/permission"; -import {listSimpleRoles} from "@/api/system/role"; -import {getBaseHeader} from "@/utils/request"; +import { CommonStatusEnum } from "@/utils/constants"; +import { DICT_TYPE, getDictDatas } from "@/utils/dict"; +import { assignUserRole, listUserRoles } from "@/api/system/permission"; +import { listSimpleRoles } from "@/api/system/role"; +import { getBaseHeader } from "@/utils/request"; export default { name: "SystemUser", @@ -282,7 +519,7 @@ export default { form: {}, defaultProps: { children: "children", - label: "name" + label: "name", }, // 用户导入参数 upload: { @@ -297,7 +534,7 @@ export default { // 设置上传的请求头部 headers: getBaseHeader(), // 上传的地址 - url: process.env.VUE_APP_BASE_API + '/admin-api/system/user/import' + url: process.env.VUE_APP_BASE_API + "/admin-api/system/user/import", }, // 查询参数 queryParams: { @@ -307,7 +544,7 @@ export default { mobile: undefined, status: undefined, deptId: undefined, - createTime: [] + createTime: [], }, // 列信息 columns: [ @@ -317,33 +554,34 @@ export default { { key: 3, label: `部门`, visible: true }, { key: 4, label: `手机号码`, visible: true }, { key: 5, label: `状态`, visible: true }, - { key: 6, label: `创建时间`, visible: true } + { key: 6, label: `创建时间`, visible: true }, ], // 表单校验 rules: { username: [ - { required: true, message: "用户名称不能为空", trigger: "blur" } + { required: true, message: "用户名称不能为空", trigger: "blur" }, ], nickname: [ - { required: true, message: "用户昵称不能为空", trigger: "blur" } + { required: true, message: "用户昵称不能为空", trigger: "blur" }, ], password: [ - { required: true, message: "用户密码不能为空", trigger: "blur" } + { required: true, message: "用户密码不能为空", trigger: "blur" }, ], email: [ { type: "email", message: "'请输入正确的邮箱地址", - trigger: ["blur", "change"] - } + trigger: ["blur", "change"], + }, ], mobile: [ { - pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/, + pattern: + /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/, message: "请输入正确的手机号码", - trigger: "blur" - } - ] + trigger: "blur", + }, + ], }, // 是否显示弹出层(角色权限) openRole: false, @@ -359,7 +597,7 @@ export default { // 根据名称筛选部门树 deptName(val) { this.$refs.tree.filter(val); - } + }, }, created() { this.getList(); @@ -372,16 +610,16 @@ export default { // 更多操作 handleCommand(command, index, row) { switch (command) { - case 'handleUpdate': - this.handleUpdate(row);//修改客户信息 + case "handleUpdate": + this.handleUpdate(row); //修改客户信息 break; - case 'handleDelete': - this.handleDelete(row);//红号变更 + case "handleDelete": + this.handleDelete(row); //红号变更 break; - case 'handleResetPwd': + case "handleResetPwd": this.handleResetPwd(row); break; - case 'handleRole': + case "handleRole": this.handleRole(row); break; default: @@ -391,21 +629,21 @@ export default { /** 查询用户列表 */ getList() { this.loading = true; - listUser(this.queryParams).then(response => { - this.userList = response.data.list; - this.total = response.data.total; - this.loading = false; - } - ); + listUser(this.queryParams).then((response) => { + this.userList = response.data.list; + this.total = response.data.total; + this.loading = false; + }); }, /** 查询部门下拉树结构 + 岗位下拉 */ getTreeselect() { - listSimpleDepts().then(response => { + listSimpleDepts().then((response) => { // 处理 deptOptions 参数 this.deptOptions = []; this.deptOptions.push(...this.handleTree(response.data, "id")); + debugger; }); - listSimplePosts().then(response => { + listSimplePosts().then((response) => { // 处理 postOptions 参数 this.postOptions = []; this.postOptions.push(...response.data); @@ -424,12 +662,18 @@ export default { // 用户状态修改 handleStatusChange(row) { let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用"; - this.$modal.confirm('确认要"' + text + '""' + row.username + '"用户吗?').then(function() { + this.$modal + .confirm('确认要"' + text + '""' + row.username + '"用户吗?') + .then(function () { return changeUserStatus(row.id, row.status); - }).then(() => { + }) + .then(() => { this.$modal.msgSuccess(text + "成功"); - }).catch(function() { - row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE + }) + .catch(function () { + row.status = + row.status === CommonStatusEnum.ENABLE + ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE; }); }, @@ -457,7 +701,7 @@ export default { status: "0", remark: undefined, postIds: [], - roleIds: [] + roleIds: [], }; this.resetForm("form"); }, @@ -486,7 +730,7 @@ export default { this.reset(); this.getTreeselect(); const id = row.id; - getUser(id).then(response => { + getUser(id).then((response) => { this.form = response.data; this.open = true; this.title = "修改用户"; @@ -497,17 +741,19 @@ export default { handleResetPwd(row) { this.$prompt('请输入"' + row.username + '"的新密码', "提示", { confirmButtonText: "确定", - cancelButtonText: "取消" - }).then(({ value }) => { - resetUserPwd(row.id, value).then(response => { + cancelButtonText: "取消", + }) + .then(({ value }) => { + resetUserPwd(row.id, value).then((response) => { this.$modal.msgSuccess("修改成功,新密码是:" + value); }); - }).catch(() => {}); + }) + .catch(() => {}); }, /** 分配用户角色操作 */ handleRole(row) { this.reset(); - const id = row.id + const id = row.id; // 处理了 form 的用户 username 和 nickname 的展示 this.form.id = id; this.form.username = row.username; @@ -515,29 +761,29 @@ export default { // 打开弹窗 this.openRole = true; // 获得角色列表 - listSimpleRoles().then(response => { + listSimpleRoles().then((response) => { // 处理 roleOptions 参数 this.roleOptions = []; this.roleOptions.push(...response.data); }); // 获得角色拥有的菜单集合 - listUserRoles(id).then(response => { + listUserRoles(id).then((response) => { // 设置选中 this.form.roleIds = response.data; - }) + }); }, /** 提交按钮 */ - submitForm: function() { - this.$refs["form"].validate(valid => { + submitForm: function () { + this.$refs["form"].validate((valid) => { if (valid) { if (this.form.id !== undefined) { - updateUser(this.form).then(response => { + updateUser(this.form).then((response) => { this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { - addUser(this.form).then(response => { + addUser(this.form).then((response) => { this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -547,12 +793,12 @@ export default { }); }, /** 提交按钮(角色权限) */ - submitRole: function() { + submitRole: function () { if (this.form.id !== undefined) { assignUserRole({ userId: this.form.id, roleIds: this.form.roleIds, - }).then(response => { + }).then((response) => { this.$modal.msgSuccess("分配角色成功"); this.openRole = false; this.getList(); @@ -562,26 +808,34 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const ids = row.id || this.ids; - this.$modal.confirm('是否确认删除用户编号为"' + ids + '"的数据项?').then(function() { + this.$modal + .confirm('是否确认删除用户编号为"' + ids + '"的数据项?') + .then(function () { return delUser(ids); - }).then(() => { + }) + .then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + }) + .catch(() => {}); }, /** 导出按钮操作 */ handleExport() { - this.$modal.confirm('是否确认导出所有用户数据项?').then(() => { + this.$modal + .confirm("是否确认导出所有用户数据项?") + .then(() => { // 处理查询参数 - let params = {...this.queryParams}; + let params = { ...this.queryParams }; params.pageNo = undefined; params.pageSize = undefined; this.exportLoading = true; return exportUser(params); - }).then(response => { - this.$download.excel(response, '用户数据.xls'); + }) + .then((response) => { + this.$download.excel(response, "用户数据.xls"); this.exportLoading = false; - }).catch(() => {}); + }) + .catch(() => {}); }, /** 导入按钮操作 */ handleImport() { @@ -590,8 +844,8 @@ export default { }, /** 下载模板操作 */ importTemplate() { - importTemplate().then(response => { - this.$download.excel(response, '用户导入模板.xls'); + importTemplate().then((response) => { + this.$download.excel(response, "用户导入模板.xls"); }); }, // 文件上传中处理 @@ -601,7 +855,7 @@ export default { // 文件上传成功处理 handleFileSuccess(response, file, fileList) { if (response.code !== 0) { - this.$modal.msgError(response.msg) + this.$modal.msgError(response.msg); return; } this.upload.open = false; @@ -609,17 +863,22 @@ export default { this.$refs.upload.clearFiles(); // 拼接提示语 let data = response.data; - let text = '创建成功数量:' + data.createUsernames.length; + let text = "创建成功数量:" + data.createUsernames.length; for (const username of data.createUsernames) { - text += '
    ' + username; + text += "
    " + username; } - text += '
更新成功数量:' + data.updateUsernames.length; + text += "
更新成功数量:" + data.updateUsernames.length; for (const username of data.updateUsernames) { - text += '
    ' + username; + text += "
    " + username; } - text += '
更新失败数量:' + Object.keys(data.failureUsernames).length; + text += + "
更新失败数量:" + Object.keys(data.failureUsernames).length; for (const username in data.failureUsernames) { - text += '
    ' + username + ':' + data.failureUsernames[username]; + text += + "
    " + + username + + ":" + + data.failureUsernames[username]; } this.$alert(text, "导入结果", { dangerouslyUseHTMLString: true }); this.getList(); @@ -633,9 +892,9 @@ export default { return { id: node.id, label: node.name, - children: node.children - } - } - } + children: node.children, + }; + }, + }, }; diff --git a/yunxi-ui-admin/src/views/xxjj/businessWarehouse/index.vue b/yunxi-ui-admin/src/views/xxjj/businessWarehouse/index.vue new file mode 100644 index 0000000..15fb1ed --- /dev/null +++ b/yunxi-ui-admin/src/views/xxjj/businessWarehouse/index.vue @@ -0,0 +1,994 @@ + + + + +