forked from sfms3.0/sfms3.0
20 changed files with 1474 additions and 10 deletions
@ -0,0 +1,14 @@ |
|||
package com.win.module.wms.enums.itembasic; |
|||
|
|||
import com.win.framework.common.exception.ErrorCode; |
|||
|
|||
/** |
|||
* System 错误码枚举类 |
|||
* |
|||
* system 系统,使用 1-002-000-000 段 |
|||
*/ |
|||
public interface ErrorCodeConstants { |
|||
|
|||
ErrorCode ITEMBASIC_NOT_EXISTS = new ErrorCode(1_020_000_000, "物品基本信息不存在"); |
|||
|
|||
} |
@ -0,0 +1,102 @@ |
|||
package com.win.module.wms.controller.admin.itembasic; |
|||
|
|||
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.win.framework.common.pojo.PageResult; |
|||
import com.win.framework.common.pojo.CommonResult; |
|||
import static com.win.framework.common.pojo.CommonResult.success; |
|||
|
|||
import com.win.framework.excel.core.util.ExcelUtils; |
|||
|
|||
import com.win.framework.operatelog.core.annotations.OperateLog; |
|||
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; |
|||
|
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
import com.win.module.wms.convert.itembasic.ItembasicConvert; |
|||
import com.win.module.wms.service.itembasic.ItembasicService; |
|||
|
|||
@Tag(name = "管理后台 - 物品基本信息") |
|||
@RestController |
|||
@RequestMapping("/wms/itembasic") |
|||
@Validated |
|||
public class ItembasicController { |
|||
|
|||
@Resource |
|||
private ItembasicService itembasicService; |
|||
|
|||
@PostMapping("/create") |
|||
@Operation(summary = "创建物品基本信息") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:create')") |
|||
public CommonResult<Long> createItembasic(@Valid @RequestBody ItembasicCreateReqVO createReqVO) { |
|||
return success(itembasicService.createItembasic(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新物品基本信息") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:update')") |
|||
public CommonResult<Boolean> updateItembasic(@Valid @RequestBody ItembasicUpdateReqVO updateReqVO) { |
|||
itembasicService.updateItembasic(updateReqVO); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete") |
|||
@Operation(summary = "删除物品基本信息") |
|||
@Parameter(name = "id", description = "编号", required = true) |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:delete')") |
|||
public CommonResult<Boolean> deleteItembasic(@RequestParam("id") Long id) { |
|||
itembasicService.deleteItembasic(id); |
|||
return success(true); |
|||
} |
|||
|
|||
@GetMapping("/get") |
|||
@Operation(summary = "获得物品基本信息") |
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:query')") |
|||
public CommonResult<ItembasicRespVO> getItembasic(@RequestParam("id") Long id) { |
|||
ItembasicDO itembasic = itembasicService.getItembasic(id); |
|||
return success(ItembasicConvert.INSTANCE.convert(itembasic)); |
|||
} |
|||
|
|||
@GetMapping("/list") |
|||
@Operation(summary = "获得物品基本信息列表") |
|||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:query')") |
|||
public CommonResult<List<ItembasicRespVO>> getItembasicList(@RequestParam("ids") Collection<Long> ids) { |
|||
List<ItembasicDO> list = itembasicService.getItembasicList(ids); |
|||
return success(ItembasicConvert.INSTANCE.convertList(list)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得物品基本信息分页") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:query')") |
|||
public CommonResult<PageResult<ItembasicRespVO>> getItembasicPage(@Valid ItembasicPageReqVO pageVO) { |
|||
PageResult<ItembasicDO> pageResult = itembasicService.getItembasicPage(pageVO); |
|||
return success(ItembasicConvert.INSTANCE.convertPage(pageResult)); |
|||
} |
|||
|
|||
@GetMapping("/export-excel") |
|||
@Operation(summary = "导出物品基本信息 Excel") |
|||
@PreAuthorize("@ss.hasPermission('wms:itembasic:export')") |
|||
@OperateLog(type = EXPORT) |
|||
public void exportItembasicExcel(@Valid ItembasicExportReqVO exportReqVO, |
|||
HttpServletResponse response) throws IOException { |
|||
List<ItembasicDO> list = itembasicService.getItembasicList(exportReqVO); |
|||
// 导出 Excel
|
|||
List<ItembasicExcelVO> datas = ItembasicConvert.INSTANCE.convertList02(list); |
|||
ExcelUtils.write(response, "物品基本信息.xls", "数据", ItembasicExcelVO.class, datas); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,119 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.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 java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import javax.validation.constraints.*; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
|||
|
|||
/** |
|||
* 物品基本信息 Base VO,提供给添加、修改、详细的子 VO 使用 |
|||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
|||
*/ |
|||
@Data |
|||
public class ItembasicBaseVO { |
|||
|
|||
@Schema(description = "id", example = "id") |
|||
private Long id; |
|||
|
|||
@Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "代码不能为空") |
|||
private String code; |
|||
|
|||
@Schema(description = "名称", example = "李四") |
|||
private String name; |
|||
|
|||
@Schema(description = "描述1") |
|||
private String desc1; |
|||
|
|||
@Schema(description = "描述2") |
|||
private String desc2; |
|||
|
|||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
|||
@NotNull(message = "状态不能为空") |
|||
private String status; |
|||
|
|||
@Schema(description = "计量单位", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "计量单位不能为空") |
|||
private String uom; |
|||
|
|||
@Schema(description = "替代计量单位") |
|||
private String altUom; |
|||
|
|||
@Schema(description = "是否标包", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "是否标包不能为空") |
|||
private Integer isStdPack; |
|||
|
|||
@Schema(description = "可采购", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "可采购不能为空") |
|||
private Integer enableBuy; |
|||
|
|||
@Schema(description = "可制造", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "可制造不能为空") |
|||
private Integer enableMake; |
|||
|
|||
@Schema(description = "可委外加工", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "可委外加工不能为空") |
|||
private Integer enableOutsourcing; |
|||
|
|||
@Schema(description = "回收件", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "回收件不能为空") |
|||
private Integer isRecycled; |
|||
|
|||
@Schema(description = "虚零件", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "虚零件不能为空") |
|||
private Integer isPhantom; |
|||
|
|||
@Schema(description = "ABC类", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "ABC类不能为空") |
|||
private String abcClass; |
|||
|
|||
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|||
@NotNull(message = "类型不能为空") |
|||
private String type; |
|||
|
|||
@Schema(description = "种类") |
|||
private String category; |
|||
|
|||
@Schema(description = "分组") |
|||
private String itemGroup; |
|||
|
|||
@Schema(description = "颜色") |
|||
private String color; |
|||
|
|||
@Schema(description = "配置") |
|||
private String configuration; |
|||
|
|||
@Schema(description = "项目") |
|||
private String project; |
|||
|
|||
@Schema(description = "质量等级") |
|||
private String eqLevel; |
|||
|
|||
@Schema(description = "有效天数", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "有效天数不能为空") |
|||
private Integer validityDays; |
|||
|
|||
@Schema(description = "是否可用", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@NotNull(message = "是否可用不能为空") |
|||
private Integer available; |
|||
|
|||
@Schema(description = "生效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime activeTime; |
|||
|
|||
@Schema(description = "失效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime expireTime; |
|||
|
|||
@Schema(description = "备注", example = "你猜") |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.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 ItembasicCreateReqVO extends ItembasicBaseVO { |
|||
|
|||
} |
@ -0,0 +1,125 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.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 java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.win.framework.excel.core.annotations.DictFormat; |
|||
import com.win.framework.excel.core.convert.DictConvert; |
|||
|
|||
|
|||
/** |
|||
* 物品基本信息 Excel VO |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Data |
|||
public class ItembasicExcelVO { |
|||
|
|||
@ExcelProperty("代码") |
|||
private String code; |
|||
|
|||
@ExcelProperty("名称") |
|||
private String name; |
|||
|
|||
@ExcelProperty("描述1") |
|||
private String desc1; |
|||
|
|||
@ExcelProperty("描述2") |
|||
private String desc2; |
|||
|
|||
@ExcelProperty(value = "状态", converter = DictConvert.class) |
|||
@DictFormat("item_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String status; |
|||
|
|||
@ExcelProperty(value = "计量单位", converter = DictConvert.class) |
|||
@DictFormat("uom") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String uom; |
|||
|
|||
@ExcelProperty(value = "替代计量单位", converter = DictConvert.class) |
|||
@DictFormat("uom") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String altUom; |
|||
|
|||
@ExcelProperty(value = "是否标包", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer isStdPack; |
|||
|
|||
@ExcelProperty(value = "可采购", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer enableBuy; |
|||
|
|||
@ExcelProperty(value = "可制造", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer enableMake; |
|||
|
|||
@ExcelProperty(value = "可委外加工", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer enableOutsourcing; |
|||
|
|||
@ExcelProperty(value = "回收件", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer isRecycled; |
|||
|
|||
@ExcelProperty(value = "虚零件", converter = DictConvert.class) |
|||
@DictFormat("true_false") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private Integer isPhantom; |
|||
|
|||
@ExcelProperty(value = "ABC类", converter = DictConvert.class) |
|||
@DictFormat("abc_class") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String abcClass; |
|||
|
|||
@ExcelProperty(value = "类型", converter = DictConvert.class) |
|||
@DictFormat("item_type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String type; |
|||
|
|||
@ExcelProperty(value = "种类", converter = DictConvert.class) |
|||
@DictFormat("Item_category") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String category; |
|||
|
|||
@ExcelProperty(value = "分组", converter = DictConvert.class) |
|||
@DictFormat("item_group") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String itemGroup; |
|||
|
|||
@ExcelProperty(value = "颜色", converter = DictConvert.class) |
|||
@DictFormat("item_color") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String color; |
|||
|
|||
@ExcelProperty(value = "配置", converter = DictConvert.class) |
|||
@DictFormat("item_configuration") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String configuration; |
|||
|
|||
@ExcelProperty("项目") |
|||
private String project; |
|||
|
|||
@ExcelProperty(value = "质量等级", converter = DictConvert.class) |
|||
@DictFormat("eq_level") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
|
|||
private String eqLevel; |
|||
|
|||
@ExcelProperty("有效天数") |
|||
private Integer validityDays; |
|||
|
|||
@ExcelProperty("是否可用") |
|||
private Integer available; |
|||
|
|||
@ExcelProperty("生效时间") |
|||
private LocalDateTime activeTime; |
|||
|
|||
@ExcelProperty("失效时间") |
|||
private LocalDateTime expireTime; |
|||
|
|||
@ExcelProperty("备注") |
|||
private String remark; |
|||
|
|||
@ExcelProperty("创建时间") |
|||
private LocalDateTime createTime; |
|||
|
|||
@ExcelProperty("创建者ID") |
|||
private String creator; |
|||
|
|||
} |
@ -0,0 +1,103 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import com.win.framework.common.pojo.PageParam; |
|||
import java.time.LocalDateTime; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
|||
|
|||
@Schema(description = "管理后台 - 物品基本信息 Excel 导出 Request VO,参数和 ItembasicPageReqVO 是一致的") |
|||
@Data |
|||
public class ItembasicExportReqVO { |
|||
|
|||
@Schema(description = "代码") |
|||
private String code; |
|||
|
|||
@Schema(description = "名称", example = "李四") |
|||
private String name; |
|||
|
|||
@Schema(description = "描述1") |
|||
private String desc1; |
|||
|
|||
@Schema(description = "描述2") |
|||
private String desc2; |
|||
|
|||
@Schema(description = "状态", example = "2") |
|||
private String status; |
|||
|
|||
@Schema(description = "计量单位") |
|||
private String uom; |
|||
|
|||
@Schema(description = "替代计量单位") |
|||
private String altUom; |
|||
|
|||
@Schema(description = "是否标包") |
|||
private Integer isStdPack; |
|||
|
|||
@Schema(description = "可采购") |
|||
private Integer enableBuy; |
|||
|
|||
@Schema(description = "可制造") |
|||
private Integer enableMake; |
|||
|
|||
@Schema(description = "可委外加工") |
|||
private Integer enableOutsourcing; |
|||
|
|||
@Schema(description = "回收件") |
|||
private Integer isRecycled; |
|||
|
|||
@Schema(description = "虚零件") |
|||
private Integer isPhantom; |
|||
|
|||
@Schema(description = "ABC类") |
|||
private String abcClass; |
|||
|
|||
@Schema(description = "类型", example = "1") |
|||
private String type; |
|||
|
|||
@Schema(description = "种类") |
|||
private String category; |
|||
|
|||
@Schema(description = "分组") |
|||
private String itemGroup; |
|||
|
|||
@Schema(description = "颜色") |
|||
private String color; |
|||
|
|||
@Schema(description = "配置") |
|||
private String configuration; |
|||
|
|||
@Schema(description = "项目") |
|||
private String project; |
|||
|
|||
@Schema(description = "质量等级") |
|||
private String eqLevel; |
|||
|
|||
@Schema(description = "有效天数") |
|||
private Integer validityDays; |
|||
|
|||
@Schema(description = "是否可用") |
|||
private Integer available; |
|||
|
|||
@Schema(description = "生效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] activeTime; |
|||
|
|||
@Schema(description = "失效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] expireTime; |
|||
|
|||
@Schema(description = "备注", example = "你猜") |
|||
private String remark; |
|||
|
|||
@Schema(description = "创建时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] createTime; |
|||
|
|||
@Schema(description = "创建者ID") |
|||
private String creator; |
|||
|
|||
} |
@ -0,0 +1,105 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import com.win.framework.common.pojo.PageParam; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import static com.win.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 ItembasicPageReqVO extends PageParam { |
|||
|
|||
@Schema(description = "代码") |
|||
private String code; |
|||
|
|||
@Schema(description = "名称", example = "李四") |
|||
private String name; |
|||
|
|||
@Schema(description = "描述1") |
|||
private String desc1; |
|||
|
|||
@Schema(description = "描述2") |
|||
private String desc2; |
|||
|
|||
@Schema(description = "状态", example = "2") |
|||
private String status; |
|||
|
|||
@Schema(description = "计量单位") |
|||
private String uom; |
|||
|
|||
@Schema(description = "替代计量单位") |
|||
private String altUom; |
|||
|
|||
@Schema(description = "是否标包") |
|||
private Integer isStdPack; |
|||
|
|||
@Schema(description = "可采购") |
|||
private Integer enableBuy; |
|||
|
|||
@Schema(description = "可制造") |
|||
private Integer enableMake; |
|||
|
|||
@Schema(description = "可委外加工") |
|||
private Integer enableOutsourcing; |
|||
|
|||
@Schema(description = "回收件") |
|||
private Integer isRecycled; |
|||
|
|||
@Schema(description = "虚零件") |
|||
private Integer isPhantom; |
|||
|
|||
@Schema(description = "ABC类") |
|||
private String abcClass; |
|||
|
|||
@Schema(description = "类型", example = "1") |
|||
private String type; |
|||
|
|||
@Schema(description = "种类") |
|||
private String category; |
|||
|
|||
@Schema(description = "分组") |
|||
private String itemGroup; |
|||
|
|||
@Schema(description = "颜色") |
|||
private String color; |
|||
|
|||
@Schema(description = "配置") |
|||
private String configuration; |
|||
|
|||
@Schema(description = "项目") |
|||
private String project; |
|||
|
|||
@Schema(description = "质量等级") |
|||
private String eqLevel; |
|||
|
|||
@Schema(description = "有效天数") |
|||
private Integer validityDays; |
|||
|
|||
@Schema(description = "是否可用") |
|||
private Integer available; |
|||
|
|||
@Schema(description = "生效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] activeTime; |
|||
|
|||
@Schema(description = "失效时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] expireTime; |
|||
|
|||
@Schema(description = "备注", example = "你猜") |
|||
private String remark; |
|||
|
|||
@Schema(description = "创建时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] createTime; |
|||
|
|||
@Schema(description = "创建者ID") |
|||
private String creator; |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.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 ItembasicRespVO extends ItembasicBaseVO { |
|||
|
|||
@Schema(description = "创建时间") |
|||
private LocalDateTime createTime; |
|||
|
|||
@Schema(description = "创建者ID") |
|||
private String creator; |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.win.module.wms.controller.admin.itembasic.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 ItembasicUpdateReqVO extends ItembasicBaseVO { |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.win.module.wms.convert.itembasic; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.factory.Mappers; |
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
|
|||
/** |
|||
* 物品基本信息 Convert |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface ItembasicConvert { |
|||
|
|||
ItembasicConvert INSTANCE = Mappers.getMapper(ItembasicConvert.class); |
|||
|
|||
ItembasicDO convert(ItembasicCreateReqVO bean); |
|||
|
|||
ItembasicDO convert(ItembasicUpdateReqVO bean); |
|||
|
|||
ItembasicRespVO convert(ItembasicDO bean); |
|||
|
|||
List<ItembasicRespVO> convertList(List<ItembasicDO> list); |
|||
|
|||
PageResult<ItembasicRespVO> convertPage(PageResult<ItembasicDO> page); |
|||
|
|||
List<ItembasicExcelVO> convertList02(List<ItembasicDO> list); |
|||
|
|||
} |
@ -0,0 +1,194 @@ |
|||
package com.win.module.wms.dal.dataobject.itembasic; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import com.win.framework.mybatis.core.dataobject.BaseDO; |
|||
|
|||
/** |
|||
* 物品基本信息 DO |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@TableName("basic_itembasic") |
|||
@KeySequence("basic_itembasic_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class ItembasicDO extends BaseDO { |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
@TableId |
|||
private Long id; |
|||
/** |
|||
* 代码 |
|||
*/ |
|||
private String code; |
|||
/** |
|||
* 名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 描述1 |
|||
*/ |
|||
private String desc1; |
|||
/** |
|||
* 描述2 |
|||
*/ |
|||
private String desc2; |
|||
/** |
|||
* 状态 |
|||
* |
|||
* 枚举 {@link TODO item_status 对应的类} |
|||
*/ |
|||
private String status; |
|||
/** |
|||
* 计量单位 |
|||
* |
|||
* 枚举 {@link TODO uom 对应的类} |
|||
*/ |
|||
private String uom; |
|||
/** |
|||
* 替代计量单位 |
|||
* |
|||
* 枚举 {@link TODO uom 对应的类} |
|||
*/ |
|||
private String altUom; |
|||
/** |
|||
* 是否标包 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer isStdPack; |
|||
/** |
|||
* 可采购 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer enableBuy; |
|||
/** |
|||
* 可制造 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer enableMake; |
|||
/** |
|||
* 可委外加工 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer enableOutsourcing; |
|||
/** |
|||
* 回收件 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer isRecycled; |
|||
/** |
|||
* 虚零件 |
|||
* |
|||
* 枚举 {@link TODO true_false 对应的类} |
|||
*/ |
|||
private Integer isPhantom; |
|||
/** |
|||
* ABC类 |
|||
* |
|||
* 枚举 {@link TODO abc_class 对应的类} |
|||
*/ |
|||
private String abcClass; |
|||
/** |
|||
* 类型 |
|||
* |
|||
* 枚举 {@link TODO item_type 对应的类} |
|||
*/ |
|||
private String type; |
|||
/** |
|||
* 种类 |
|||
* |
|||
* 枚举 {@link TODO Item_category 对应的类} |
|||
*/ |
|||
private String category; |
|||
/** |
|||
* 分组 |
|||
* |
|||
* 枚举 {@link TODO item_group 对应的类} |
|||
*/ |
|||
private String itemGroup; |
|||
/** |
|||
* 颜色 |
|||
* |
|||
* 枚举 {@link TODO item_color 对应的类} |
|||
*/ |
|||
private String color; |
|||
/** |
|||
* 配置 |
|||
* |
|||
* 枚举 {@link TODO item_configuration 对应的类} |
|||
*/ |
|||
private String configuration; |
|||
/** |
|||
* 项目 |
|||
*/ |
|||
private String project; |
|||
/** |
|||
* 质量等级 |
|||
* |
|||
* 枚举 {@link TODO eq_level 对应的类} |
|||
*/ |
|||
private String eqLevel; |
|||
/** |
|||
* 有效天数 |
|||
*/ |
|||
private Integer validityDays; |
|||
/** |
|||
* 用户组代码 |
|||
*/ |
|||
private String userGroupCode; |
|||
/** |
|||
* 是否可用 |
|||
*/ |
|||
private Integer available; |
|||
/** |
|||
* 生效时间 |
|||
*/ |
|||
private LocalDateTime activeTime; |
|||
/** |
|||
* 失效时间 |
|||
*/ |
|||
private LocalDateTime expireTime; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
/** |
|||
* 删除时间 |
|||
*/ |
|||
private LocalDateTime deletionTime; |
|||
/** |
|||
* 删除者ID |
|||
*/ |
|||
private String deleterId; |
|||
/** |
|||
* 扩展属性 |
|||
*/ |
|||
private String extraProperties; |
|||
/** |
|||
* 并发乐观锁 |
|||
*/ |
|||
private String concurrencyStamp; |
|||
/** |
|||
* 地点ID |
|||
*/ |
|||
private String siteId; |
|||
|
|||
} |
@ -0,0 +1,86 @@ |
|||
package com.win.module.wms.dal.mysql.itembasic; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
|
|||
/** |
|||
* 物品基本信息 Mapper |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface ItembasicMapper extends BaseMapperX<ItembasicDO> { |
|||
|
|||
default PageResult<ItembasicDO> selectPage(ItembasicPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<ItembasicDO>() |
|||
.eqIfPresent(ItembasicDO::getCode, reqVO.getCode()) |
|||
.likeIfPresent(ItembasicDO::getName, reqVO.getName()) |
|||
.likeIfPresent(ItembasicDO::getDesc1, reqVO.getDesc1()) |
|||
.likeIfPresent(ItembasicDO::getDesc2, reqVO.getDesc2()) |
|||
.eqIfPresent(ItembasicDO::getStatus, reqVO.getStatus()) |
|||
.eqIfPresent(ItembasicDO::getUom, reqVO.getUom()) |
|||
.eqIfPresent(ItembasicDO::getAltUom, reqVO.getAltUom()) |
|||
.eqIfPresent(ItembasicDO::getIsStdPack, reqVO.getIsStdPack()) |
|||
.eqIfPresent(ItembasicDO::getEnableBuy, reqVO.getEnableBuy()) |
|||
.eqIfPresent(ItembasicDO::getEnableMake, reqVO.getEnableMake()) |
|||
.eqIfPresent(ItembasicDO::getEnableOutsourcing, reqVO.getEnableOutsourcing()) |
|||
.eqIfPresent(ItembasicDO::getIsRecycled, reqVO.getIsRecycled()) |
|||
.eqIfPresent(ItembasicDO::getIsPhantom, reqVO.getIsPhantom()) |
|||
.eqIfPresent(ItembasicDO::getAbcClass, reqVO.getAbcClass()) |
|||
.eqIfPresent(ItembasicDO::getType, reqVO.getType()) |
|||
.eqIfPresent(ItembasicDO::getCategory, reqVO.getCategory()) |
|||
.eqIfPresent(ItembasicDO::getItemGroup, reqVO.getItemGroup()) |
|||
.eqIfPresent(ItembasicDO::getColor, reqVO.getColor()) |
|||
.eqIfPresent(ItembasicDO::getConfiguration, reqVO.getConfiguration()) |
|||
.eqIfPresent(ItembasicDO::getProject, reqVO.getProject()) |
|||
.eqIfPresent(ItembasicDO::getEqLevel, reqVO.getEqLevel()) |
|||
.eqIfPresent(ItembasicDO::getValidityDays, reqVO.getValidityDays()) |
|||
.eqIfPresent(ItembasicDO::getAvailable, reqVO.getAvailable()) |
|||
.betweenIfPresent(ItembasicDO::getActiveTime, reqVO.getActiveTime()) |
|||
.betweenIfPresent(ItembasicDO::getExpireTime, reqVO.getExpireTime()) |
|||
.eqIfPresent(ItembasicDO::getRemark, reqVO.getRemark()) |
|||
.betweenIfPresent(ItembasicDO::getCreateTime, reqVO.getCreateTime()) |
|||
.eqIfPresent(ItembasicDO::getCreator, reqVO.getCreator()) |
|||
.orderByDesc(ItembasicDO::getId)); |
|||
} |
|||
|
|||
default List<ItembasicDO> selectList(ItembasicExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<ItembasicDO>() |
|||
.eqIfPresent(ItembasicDO::getCode, reqVO.getCode()) |
|||
.likeIfPresent(ItembasicDO::getName, reqVO.getName()) |
|||
.likeIfPresent(ItembasicDO::getDesc1, reqVO.getDesc1()) |
|||
.likeIfPresent(ItembasicDO::getDesc2, reqVO.getDesc2()) |
|||
.eqIfPresent(ItembasicDO::getStatus, reqVO.getStatus()) |
|||
.eqIfPresent(ItembasicDO::getUom, reqVO.getUom()) |
|||
.eqIfPresent(ItembasicDO::getAltUom, reqVO.getAltUom()) |
|||
.eqIfPresent(ItembasicDO::getIsStdPack, reqVO.getIsStdPack()) |
|||
.eqIfPresent(ItembasicDO::getEnableBuy, reqVO.getEnableBuy()) |
|||
.eqIfPresent(ItembasicDO::getEnableMake, reqVO.getEnableMake()) |
|||
.eqIfPresent(ItembasicDO::getEnableOutsourcing, reqVO.getEnableOutsourcing()) |
|||
.eqIfPresent(ItembasicDO::getIsRecycled, reqVO.getIsRecycled()) |
|||
.eqIfPresent(ItembasicDO::getIsPhantom, reqVO.getIsPhantom()) |
|||
.eqIfPresent(ItembasicDO::getAbcClass, reqVO.getAbcClass()) |
|||
.eqIfPresent(ItembasicDO::getType, reqVO.getType()) |
|||
.eqIfPresent(ItembasicDO::getCategory, reqVO.getCategory()) |
|||
.eqIfPresent(ItembasicDO::getItemGroup, reqVO.getItemGroup()) |
|||
.eqIfPresent(ItembasicDO::getColor, reqVO.getColor()) |
|||
.eqIfPresent(ItembasicDO::getConfiguration, reqVO.getConfiguration()) |
|||
.eqIfPresent(ItembasicDO::getProject, reqVO.getProject()) |
|||
.eqIfPresent(ItembasicDO::getEqLevel, reqVO.getEqLevel()) |
|||
.eqIfPresent(ItembasicDO::getValidityDays, reqVO.getValidityDays()) |
|||
.eqIfPresent(ItembasicDO::getAvailable, reqVO.getAvailable()) |
|||
.betweenIfPresent(ItembasicDO::getActiveTime, reqVO.getActiveTime()) |
|||
.betweenIfPresent(ItembasicDO::getExpireTime, reqVO.getExpireTime()) |
|||
.eqIfPresent(ItembasicDO::getRemark, reqVO.getRemark()) |
|||
.betweenIfPresent(ItembasicDO::getCreateTime, reqVO.getCreateTime()) |
|||
.eqIfPresent(ItembasicDO::getCreator, reqVO.getCreator()) |
|||
.orderByDesc(ItembasicDO::getId)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.win.module.wms.service.itembasic; |
|||
|
|||
import java.util.*; |
|||
import javax.validation.*; |
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
/** |
|||
* 物品基本信息 Service 接口 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
public interface ItembasicService { |
|||
|
|||
/** |
|||
* 创建物品基本信息 |
|||
* |
|||
* @param createReqVO 创建信息 |
|||
* @return 编号 |
|||
*/ |
|||
Long createItembasic(@Valid ItembasicCreateReqVO createReqVO); |
|||
|
|||
/** |
|||
* 更新物品基本信息 |
|||
* |
|||
* @param updateReqVO 更新信息 |
|||
*/ |
|||
void updateItembasic(@Valid ItembasicUpdateReqVO updateReqVO); |
|||
|
|||
/** |
|||
* 删除物品基本信息 |
|||
* |
|||
* @param id 编号 |
|||
*/ |
|||
void deleteItembasic(Long id); |
|||
|
|||
/** |
|||
* 获得物品基本信息 |
|||
* |
|||
* @param id 编号 |
|||
* @return 物品基本信息 |
|||
*/ |
|||
ItembasicDO getItembasic(Long id); |
|||
|
|||
/** |
|||
* 获得物品基本信息列表 |
|||
* |
|||
* @param ids 编号 |
|||
* @return 物品基本信息列表 |
|||
*/ |
|||
List<ItembasicDO> getItembasicList(Collection<Long> ids); |
|||
|
|||
/** |
|||
* 获得物品基本信息分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 物品基本信息分页 |
|||
*/ |
|||
PageResult<ItembasicDO> getItembasicPage(ItembasicPageReqVO pageReqVO); |
|||
|
|||
/** |
|||
* 获得物品基本信息列表, 用于 Excel 导出 |
|||
* |
|||
* @param exportReqVO 查询条件 |
|||
* @return 物品基本信息列表 |
|||
*/ |
|||
List<ItembasicDO> getItembasicList(ItembasicExportReqVO exportReqVO); |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.win.module.wms.service.itembasic; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import javax.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
|
|||
import java.util.*; |
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import com.win.module.wms.convert.itembasic.ItembasicConvert; |
|||
import com.win.module.wms.dal.mysql.itembasic.ItembasicMapper; |
|||
|
|||
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.ITEMBASIC_NOT_EXISTS; |
|||
|
|||
/** |
|||
* 物品基本信息 Service 实现类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Service |
|||
@Validated |
|||
public class ItembasicServiceImpl implements ItembasicService { |
|||
|
|||
@Resource |
|||
private ItembasicMapper itembasicMapper; |
|||
|
|||
@Override |
|||
public Long createItembasic(ItembasicCreateReqVO createReqVO) { |
|||
// 插入
|
|||
ItembasicDO itembasic = ItembasicConvert.INSTANCE.convert(createReqVO); |
|||
itembasicMapper.insert(itembasic); |
|||
// 返回
|
|||
return itembasic.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public void updateItembasic(ItembasicUpdateReqVO updateReqVO) { |
|||
// 校验存在
|
|||
validateItembasicExists(updateReqVO.getId()); |
|||
// 更新
|
|||
ItembasicDO updateObj = ItembasicConvert.INSTANCE.convert(updateReqVO); |
|||
itembasicMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteItembasic(Long id) { |
|||
// 校验存在
|
|||
validateItembasicExists(id); |
|||
// 删除
|
|||
itembasicMapper.deleteById(id); |
|||
} |
|||
|
|||
private void validateItembasicExists(Long id) { |
|||
if (itembasicMapper.selectById(id) == null) { |
|||
throw exception(ITEMBASIC_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public ItembasicDO getItembasic(Long id) { |
|||
return itembasicMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<ItembasicDO> getItembasicList(Collection<Long> ids) { |
|||
return itembasicMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<ItembasicDO> getItembasicPage(ItembasicPageReqVO pageReqVO) { |
|||
return itembasicMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<ItembasicDO> getItembasicList(ItembasicExportReqVO exportReqVO) { |
|||
return itembasicMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
} |
@ -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="com.win.module.wms.dal.mysql.itembasic.ItembasicMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
@ -0,0 +1,367 @@ |
|||
package com.win.module.wms.service.itembasic; |
|||
|
|||
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.win.framework.test.core.ut.BaseDbUnitTest; |
|||
|
|||
import com.win.module.wms.controller.admin.itembasic.vo.*; |
|||
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|||
import com.win.module.wms.dal.mysql.itembasic.ItembasicMapper; |
|||
import com.win.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.win.framework.test.core.util.AssertUtils.*; |
|||
import static com.win.framework.test.core.util.RandomUtils.*; |
|||
import static com.win.framework.common.util.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static com.win.framework.common.util.date.DateUtils.*; |
|||
import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.ITEMBASIC_NOT_EXISTS; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
import static org.mockito.Mockito.*; |
|||
|
|||
/** |
|||
* {@link ItembasicServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(ItembasicServiceImpl.class) |
|||
public class ItembasicServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private ItembasicServiceImpl itembasicService; |
|||
|
|||
@Resource |
|||
private ItembasicMapper itembasicMapper; |
|||
|
|||
@Test |
|||
public void testCreateItembasic_success() { |
|||
// 准备参数
|
|||
ItembasicCreateReqVO reqVO = randomPojo(ItembasicCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long itembasicId = itembasicService.createItembasic(reqVO); |
|||
// 断言
|
|||
assertNotNull(itembasicId); |
|||
// 校验记录的属性是否正确
|
|||
ItembasicDO itembasic = itembasicMapper.selectById(itembasicId); |
|||
assertPojoEquals(reqVO, itembasic); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateItembasic_success() { |
|||
// mock 数据
|
|||
ItembasicDO dbItembasic = randomPojo(ItembasicDO.class); |
|||
itembasicMapper.insert(dbItembasic);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
ItembasicUpdateReqVO reqVO = randomPojo(ItembasicUpdateReqVO.class, o -> { |
|||
o.setId(dbItembasic.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
itembasicService.updateItembasic(reqVO); |
|||
// 校验是否更新正确
|
|||
ItembasicDO itembasic = itembasicMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, itembasic); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateItembasic_notExists() { |
|||
// 准备参数
|
|||
ItembasicUpdateReqVO reqVO = randomPojo(ItembasicUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> itembasicService.updateItembasic(reqVO), ITEMBASIC_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteItembasic_success() { |
|||
// mock 数据
|
|||
ItembasicDO dbItembasic = randomPojo(ItembasicDO.class); |
|||
itembasicMapper.insert(dbItembasic);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbItembasic.getId(); |
|||
|
|||
// 调用
|
|||
itembasicService.deleteItembasic(id); |
|||
// 校验数据不存在了
|
|||
assertNull(itembasicMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteItembasic_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> itembasicService.deleteItembasic(id), ITEMBASIC_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetItembasicPage() { |
|||
// mock 数据
|
|||
ItembasicDO dbItembasic = randomPojo(ItembasicDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDesc1(null); |
|||
o.setDesc2(null); |
|||
o.setStatus(null); |
|||
o.setUom(null); |
|||
o.setAltUom(null); |
|||
o.setIsStdPack(null); |
|||
o.setEnableBuy(null); |
|||
o.setEnableMake(null); |
|||
o.setEnableOutsourcing(null); |
|||
o.setIsRecycled(null); |
|||
o.setIsPhantom(null); |
|||
o.setAbcClass(null); |
|||
o.setType(null); |
|||
o.setCategory(null); |
|||
o.setItemGroup(null); |
|||
o.setColor(null); |
|||
o.setConfiguration(null); |
|||
o.setProject(null); |
|||
o.setEqLevel(null); |
|||
o.setValidityDays(null); |
|||
o.setAvailable(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
}); |
|||
itembasicMapper.insert(dbItembasic); |
|||
// 测试 code 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setName(null))); |
|||
// 测试 desc1 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setDesc1(null))); |
|||
// 测试 desc2 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setDesc2(null))); |
|||
// 测试 status 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setStatus(null))); |
|||
// 测试 uom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setUom(null))); |
|||
// 测试 altUom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAltUom(null))); |
|||
// 测试 isStdPack 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsStdPack(null))); |
|||
// 测试 enableBuy 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableBuy(null))); |
|||
// 测试 enableMake 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableMake(null))); |
|||
// 测试 enableOutsourcing 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableOutsourcing(null))); |
|||
// 测试 isRecycled 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsRecycled(null))); |
|||
// 测试 isPhantom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsPhantom(null))); |
|||
// 测试 abcClass 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAbcClass(null))); |
|||
// 测试 type 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setType(null))); |
|||
// 测试 category 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCategory(null))); |
|||
// 测试 itemGroup 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setItemGroup(null))); |
|||
// 测试 color 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setColor(null))); |
|||
// 测试 configuration 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setConfiguration(null))); |
|||
// 测试 project 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setProject(null))); |
|||
// 测试 eqLevel 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEqLevel(null))); |
|||
// 测试 validityDays 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setValidityDays(null))); |
|||
// 测试 available 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAvailable(null))); |
|||
// 测试 activeTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCreator(null))); |
|||
// 准备参数
|
|||
ItembasicPageReqVO reqVO = new ItembasicPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDesc1(null); |
|||
reqVO.setDesc2(null); |
|||
reqVO.setStatus(null); |
|||
reqVO.setUom(null); |
|||
reqVO.setAltUom(null); |
|||
reqVO.setIsStdPack(null); |
|||
reqVO.setEnableBuy(null); |
|||
reqVO.setEnableMake(null); |
|||
reqVO.setEnableOutsourcing(null); |
|||
reqVO.setIsRecycled(null); |
|||
reqVO.setIsPhantom(null); |
|||
reqVO.setAbcClass(null); |
|||
reqVO.setType(null); |
|||
reqVO.setCategory(null); |
|||
reqVO.setItemGroup(null); |
|||
reqVO.setColor(null); |
|||
reqVO.setConfiguration(null); |
|||
reqVO.setProject(null); |
|||
reqVO.setEqLevel(null); |
|||
reqVO.setValidityDays(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
|
|||
// 调用
|
|||
PageResult<ItembasicDO> pageResult = itembasicService.getItembasicPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbItembasic, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetItembasicList() { |
|||
// mock 数据
|
|||
ItembasicDO dbItembasic = randomPojo(ItembasicDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDesc1(null); |
|||
o.setDesc2(null); |
|||
o.setStatus(null); |
|||
o.setUom(null); |
|||
o.setAltUom(null); |
|||
o.setIsStdPack(null); |
|||
o.setEnableBuy(null); |
|||
o.setEnableMake(null); |
|||
o.setEnableOutsourcing(null); |
|||
o.setIsRecycled(null); |
|||
o.setIsPhantom(null); |
|||
o.setAbcClass(null); |
|||
o.setType(null); |
|||
o.setCategory(null); |
|||
o.setItemGroup(null); |
|||
o.setColor(null); |
|||
o.setConfiguration(null); |
|||
o.setProject(null); |
|||
o.setEqLevel(null); |
|||
o.setValidityDays(null); |
|||
o.setAvailable(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
}); |
|||
itembasicMapper.insert(dbItembasic); |
|||
// 测试 code 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setName(null))); |
|||
// 测试 desc1 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setDesc1(null))); |
|||
// 测试 desc2 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setDesc2(null))); |
|||
// 测试 status 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setStatus(null))); |
|||
// 测试 uom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setUom(null))); |
|||
// 测试 altUom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAltUom(null))); |
|||
// 测试 isStdPack 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsStdPack(null))); |
|||
// 测试 enableBuy 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableBuy(null))); |
|||
// 测试 enableMake 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableMake(null))); |
|||
// 测试 enableOutsourcing 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEnableOutsourcing(null))); |
|||
// 测试 isRecycled 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsRecycled(null))); |
|||
// 测试 isPhantom 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setIsPhantom(null))); |
|||
// 测试 abcClass 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAbcClass(null))); |
|||
// 测试 type 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setType(null))); |
|||
// 测试 category 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCategory(null))); |
|||
// 测试 itemGroup 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setItemGroup(null))); |
|||
// 测试 color 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setColor(null))); |
|||
// 测试 configuration 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setConfiguration(null))); |
|||
// 测试 project 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setProject(null))); |
|||
// 测试 eqLevel 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setEqLevel(null))); |
|||
// 测试 validityDays 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setValidityDays(null))); |
|||
// 测试 available 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setAvailable(null))); |
|||
// 测试 activeTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
itembasicMapper.insert(cloneIgnoreId(dbItembasic, o -> o.setCreator(null))); |
|||
// 准备参数
|
|||
ItembasicExportReqVO reqVO = new ItembasicExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDesc1(null); |
|||
reqVO.setDesc2(null); |
|||
reqVO.setStatus(null); |
|||
reqVO.setUom(null); |
|||
reqVO.setAltUom(null); |
|||
reqVO.setIsStdPack(null); |
|||
reqVO.setEnableBuy(null); |
|||
reqVO.setEnableMake(null); |
|||
reqVO.setEnableOutsourcing(null); |
|||
reqVO.setIsRecycled(null); |
|||
reqVO.setIsPhantom(null); |
|||
reqVO.setAbcClass(null); |
|||
reqVO.setType(null); |
|||
reqVO.setCategory(null); |
|||
reqVO.setItemGroup(null); |
|||
reqVO.setColor(null); |
|||
reqVO.setConfiguration(null); |
|||
reqVO.setProject(null); |
|||
reqVO.setEqLevel(null); |
|||
reqVO.setValidityDays(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
|
|||
// 调用
|
|||
List<ItembasicDO> list = itembasicService.getItembasicList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbItembasic, list.get(0)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue