1. 新增物料相关接口
2. 修复部分服务因为包名设置错误导致无法采集日志的错误
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryDataDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypePageReqDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeRespDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeSaveReqDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 业务字典类型")
|
||||
public interface BusinessDictionaryTypeApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/business-dictionary-type";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建业务字典类型")
|
||||
CommonResult<BusinessDictionaryTypeRespDTO> createBusinessDictionaryType(@Valid @RequestBody BusinessDictionaryTypeSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新业务字典类型")
|
||||
CommonResult<Boolean> updateBusinessDictionaryType(@Valid @RequestBody BusinessDictionaryTypeSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除业务字典类型")
|
||||
CommonResult<Boolean> deleteBusinessDictionaryType(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除业务字典类型")
|
||||
CommonResult<Boolean> deleteBusinessDictionaryTypeList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得业务字典类型")
|
||||
CommonResult<BusinessDictionaryTypeRespDTO> getBusinessDictionaryType(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得业务字典类型分页")
|
||||
CommonResult<PageResult<BusinessDictionaryTypeRespDTO>> getBusinessDictionaryTypePage(@Valid BusinessDictionaryTypePageReqDTO pageReqDTO);
|
||||
|
||||
@GetMapping(PREFIX + "/business-dictionary-data/list-by-dictionary-type-id")
|
||||
@Operation(summary = "获得业务字典数据列表")
|
||||
CommonResult<List<BusinessDictionaryDataDTO>> getBusinessDictionaryDataListByDictionaryTypeId(@RequestParam("dictionaryTypeId") Long dictionaryTypeId);
|
||||
|
||||
@GetMapping(PREFIX + "/business-dictionary-data/list-by-type")
|
||||
@Operation(summary = "根据字典类型编码获取业务字典数据列表")
|
||||
CommonResult<List<BusinessDictionaryDataDTO>> getBusinessDictionaryDataListByType(@RequestParam("type") String type);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 业务字典数据 DTO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDictionaryDataDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "1001")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "上级字典", example = "2001")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "字典类型", example = "3001")
|
||||
private Long dictionaryTypeId;
|
||||
|
||||
@Schema(description = "排序号", example = "10")
|
||||
private Long sort;
|
||||
|
||||
@Schema(description = "字典标签", example = "状态")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典值", example = "ENABLE")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "0")
|
||||
private Long status;
|
||||
|
||||
@Schema(description = "备注", example = "同义词")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 业务字典类型分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDictionaryTypePageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "字典名称", example = "物料状态")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典类型", example = "base_material_status")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "0")
|
||||
private Long status;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 业务字典类型 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDictionaryTypeRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "11771")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字典名称", example = "物料状态")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典类型", example = "base_material_status")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "0")
|
||||
private Long status;
|
||||
|
||||
@Schema(description = "备注", example = "基础物料状态")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务字典类型新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDictionaryTypeSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "11771")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字典名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "物料状态")
|
||||
@NotEmpty(message = "字典名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "base_material_status")
|
||||
@NotEmpty(message = "字典类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "0")
|
||||
private Long status;
|
||||
|
||||
@Schema(description = "备注", example = "基础物料状态")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "删除时间")
|
||||
private LocalDateTime delTime;
|
||||
|
||||
@Schema(description = "业务字典数据列表")
|
||||
private List<BusinessDictionaryDataDTO> businessDictionaryDatas;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialPageReqDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialRespDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialSaveReqDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 组织架构物料")
|
||||
public interface DepartmentMaterialApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/department-material";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建组织架构物料")
|
||||
CommonResult<DepartmentMaterialRespDTO> createDepartmentMaterial(@Valid @RequestBody DepartmentMaterialSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新组织架构物料")
|
||||
CommonResult<Boolean> updateDepartmentMaterial(@Valid @RequestBody DepartmentMaterialSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除组织架构物料")
|
||||
CommonResult<Boolean> deleteDepartmentMaterial(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除组织架构物料")
|
||||
CommonResult<Boolean> deleteDepartmentMaterialList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得组织架构物料")
|
||||
CommonResult<DepartmentMaterialRespDTO> getDepartmentMaterial(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得组织架构物料分页")
|
||||
CommonResult<PageResult<DepartmentMaterialRespDTO>> getDepartmentMaterialPage(@Valid DepartmentMaterialPageReqDTO pageReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 组织架构物料分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentMaterialPageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "物料信息ID", example = "3923")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "物料信息ID集合(内部使用)")
|
||||
private List<Long> infomationIds;
|
||||
|
||||
@Schema(description = "物料分类ID", example = "30114")
|
||||
private Long classesId;
|
||||
|
||||
@Schema(description = "部门ID", example = "1001")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "字典数据值-物料类型")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "状态编码", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
private String materialNumber;
|
||||
|
||||
@Schema(description = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 组织架构物料 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentMaterialRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "5674")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "物料信息ID", example = "3923")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "物料分类ID", example = "30114")
|
||||
private Long classesId;
|
||||
|
||||
@Schema(description = "字典数据值-物料类型")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
private String materialNumber;
|
||||
|
||||
@Schema(description = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
@Schema(description = "物料大类名称")
|
||||
private String categoryLargeName;
|
||||
|
||||
@Schema(description = "物料中类名称")
|
||||
private String categoryMediumName;
|
||||
|
||||
@Schema(description = "物料小类名称")
|
||||
private String categorySmallName;
|
||||
|
||||
@Schema(description = "物料分类路径")
|
||||
private String categoryPath;
|
||||
|
||||
@Schema(description = "组织物料类型名称")
|
||||
private String dictionaryDataLabel;
|
||||
|
||||
@Schema(description = "状态编码")
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织架构物料新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentMaterialSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "5674")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
|
||||
@NotNull(message = "部门ID不能为空")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3923")
|
||||
@NotNull(message = "物料信息ID不能为空")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "物料分类ID", example = "30114")
|
||||
private Long classesId;
|
||||
|
||||
@Schema(description = "字典数据值-物料类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "字典数据值-物料类型不能为空")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "状态编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zt.plat.module.base.api.materialclasses;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesSaveReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesTreeRespDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 物料分类")
|
||||
public interface MaterialClassesApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/material-classes";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建物料分类")
|
||||
CommonResult<MaterialClassesRespDTO> createMaterialClasses(@Valid @RequestBody MaterialClassesSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新物料分类")
|
||||
CommonResult<Boolean> updateMaterialClasses(@Valid @RequestBody MaterialClassesSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除物料分类")
|
||||
CommonResult<Boolean> deleteMaterialClasses(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除物料分类")
|
||||
CommonResult<Boolean> deleteMaterialClassesList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得物料分类")
|
||||
CommonResult<MaterialClassesRespDTO> getMaterialClasses(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得物料分类分页")
|
||||
CommonResult<PageResult<MaterialClassesRespDTO>> getMaterialClassesPage(@Valid MaterialClassesPageReqDTO pageReqDTO);
|
||||
|
||||
@GetMapping(PREFIX + "/tree")
|
||||
@Operation(summary = "获得物料分类树")
|
||||
CommonResult<List<MaterialClassesTreeRespDTO>> getMaterialClassesTree();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.zt.plat.module.base.api.materialclasses.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 物料分类分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialClassesPageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "父级ID", example = "20706")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "分类编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "分类名称", example = "原材料")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类级别-用于类别层级(大/中/小类)")
|
||||
private Long level;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zt.plat.module.base.api.materialclasses.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 物料分类 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialClassesRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "4051")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父级ID", example = "20706")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "分类编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "分类名称", example = "原材料")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类级别-用于类别层级(大/中/小类)")
|
||||
private Long level;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.base.api.materialclasses.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料分类新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialClassesSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "4051")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父级ID", example = "20706")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "分类编码不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "原材料")
|
||||
@NotEmpty(message = "分类名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类级别-用于类别层级(大/中/小类)")
|
||||
private Long level;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zt.plat.module.base.api.materialclasses.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料分类树 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialClassesTreeRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "1001")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父级ID", example = "0")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "分类编码", example = "CL-001")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "分类名称", example = "原材料")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类级别")
|
||||
private Long level;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "子节点")
|
||||
private List<MaterialClassesTreeRespDTO> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zt.plat.module.base.api.materialhasclasses;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.materialhasclasses.dto.MaterialHasClassesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialhasclasses.dto.MaterialHasClassesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialhasclasses.dto.MaterialHasClassesSaveReqDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 物料持有分类")
|
||||
public interface MaterialHasClassesApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/material-has-classes";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建物料持有分类")
|
||||
CommonResult<MaterialHasClassesRespDTO> createMaterialHasClasses(@Valid @RequestBody MaterialHasClassesSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新物料持有分类")
|
||||
CommonResult<Boolean> updateMaterialHasClasses(@Valid @RequestBody MaterialHasClassesSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除物料持有分类")
|
||||
CommonResult<Boolean> deleteMaterialHasClasses(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除物料持有分类")
|
||||
CommonResult<Boolean> deleteMaterialHasClassesList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得物料持有分类")
|
||||
CommonResult<MaterialHasClassesRespDTO> getMaterialHasClasses(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得物料持有分类分页")
|
||||
CommonResult<PageResult<MaterialHasClassesRespDTO>> getMaterialHasClassesPage(@Valid MaterialHasClassesPageReqDTO pageReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zt.plat.module.base.api.materialhasclasses.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 物料持有分类分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasClassesPageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "物料信息ID", example = "31031")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "分类ID", example = "5914")
|
||||
private Long classesId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zt.plat.module.base.api.materialhasclasses.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 物料持有分类 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasClassesRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "16228")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "物料信息ID", example = "31031")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "分类ID", example = "5914")
|
||||
private Long classesId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zt.plat.module.base.api.materialhasclasses.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料持有分类新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasClassesSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "16228")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31031")
|
||||
@NotNull(message = "物料信息ID不能为空")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5914")
|
||||
@NotNull(message = "分类ID不能为空")
|
||||
private Long classesId;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zt.plat.module.base.api.materialhasproperties;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.materialhasproperties.dto.MaterialHasPropertiesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialhasproperties.dto.MaterialHasPropertiesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialhasproperties.dto.MaterialHasPropertiesSaveReqDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 物料持有属性")
|
||||
public interface MaterialHasPropertiesApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/material-has-properties";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建物料持有属性")
|
||||
CommonResult<MaterialHasPropertiesRespDTO> createMaterialHasProperties(@Valid @RequestBody MaterialHasPropertiesSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新物料持有属性")
|
||||
CommonResult<Boolean> updateMaterialHasProperties(@Valid @RequestBody MaterialHasPropertiesSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除物料持有属性")
|
||||
CommonResult<Boolean> deleteMaterialHasProperties(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除物料持有属性")
|
||||
CommonResult<Boolean> deleteMaterialHasPropertiesList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得物料持有属性")
|
||||
CommonResult<MaterialHasPropertiesRespDTO> getMaterialHasProperties(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得物料持有属性分页")
|
||||
CommonResult<PageResult<MaterialHasPropertiesRespDTO>> getMaterialHasPropertiesPage(@Valid MaterialHasPropertiesPageReqDTO pageReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zt.plat.module.base.api.materialhasproperties.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 物料持有属性分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasPropertiesPageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "物料信息ID", example = "2614")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "属性ID", example = "8607")
|
||||
private Long propertiesId;
|
||||
|
||||
@Schema(description = "计量单位ID-默认计量单位", example = "23731")
|
||||
private Long unitId;
|
||||
|
||||
@Schema(description = "属性值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否关键属性-关键属性表示物料唯一性")
|
||||
private Integer isKey;
|
||||
|
||||
@Schema(description = "是否计量定价")
|
||||
private Integer isMetering;
|
||||
|
||||
@Schema(description = "排序号")
|
||||
private Long sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.base.api.materialhasproperties.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 物料持有属性 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasPropertiesRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "6800")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "物料信息ID", example = "2614")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "属性ID", example = "8607")
|
||||
private Long propertiesId;
|
||||
|
||||
@Schema(description = "计量单位ID-默认计量单位", example = "23731")
|
||||
private Long unitId;
|
||||
|
||||
@Schema(description = "属性值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否关键属性-关键属性表示物料唯一性")
|
||||
private Integer isKey;
|
||||
|
||||
@Schema(description = "是否计量定价")
|
||||
private Integer isMetering;
|
||||
|
||||
@Schema(description = "排序号")
|
||||
private Long sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.base.api.materialhasproperties.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料持有属性新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHasPropertiesSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "6800")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2614")
|
||||
@NotNull(message = "物料信息ID不能为空")
|
||||
private Long infomationId;
|
||||
|
||||
@Schema(description = "属性ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8607")
|
||||
@NotNull(message = "属性ID不能为空")
|
||||
private Long propertiesId;
|
||||
|
||||
@Schema(description = "计量单位ID-默认计量单位", example = "23731")
|
||||
private Long unitId;
|
||||
|
||||
@Schema(description = "属性值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "属性值不能为空")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否关键属性-关键属性表示物料唯一性")
|
||||
private Integer isKey;
|
||||
|
||||
@Schema(description = "是否计量定价")
|
||||
private Integer isMetering;
|
||||
|
||||
@Schema(description = "排序号")
|
||||
private Long sort;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zt.plat.module.base.api.materialproperties;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.materialproperties.dto.MaterialPropertiesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialproperties.dto.MaterialPropertiesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialproperties.dto.MaterialPropertiesSaveReqDTO;
|
||||
import com.zt.plat.module.base.api.materialproperties.dto.MaterialPropertiesSimplePageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialproperties.dto.MaterialPropertiesSimpleRespDTO;
|
||||
import com.zt.plat.module.base.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 物料属性")
|
||||
public interface MaterialPropertiesApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/material-properties";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建物料属性")
|
||||
CommonResult<MaterialPropertiesRespDTO> createMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqDTO createReqDTO);
|
||||
|
||||
@PutMapping(PREFIX + "/update")
|
||||
@Operation(summary = "更新物料属性")
|
||||
CommonResult<Boolean> updateMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqDTO updateReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除物料属性")
|
||||
CommonResult<Boolean> deleteMaterialProperties(@RequestParam("id") Long id);
|
||||
|
||||
@DeleteMapping(PREFIX + "/delete-list")
|
||||
@Operation(summary = "批量删除物料属性")
|
||||
CommonResult<Boolean> deleteMaterialPropertiesList(@RequestBody List<Long> ids);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "获得物料属性")
|
||||
CommonResult<MaterialPropertiesRespDTO> getMaterialProperties(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/page")
|
||||
@Operation(summary = "获得物料属性分页")
|
||||
CommonResult<PageResult<MaterialPropertiesRespDTO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqDTO pageReqDTO);
|
||||
|
||||
@GetMapping(PREFIX + "/simple-page")
|
||||
@Operation(summary = "获得物料属性精简分页")
|
||||
CommonResult<PageResult<MaterialPropertiesSimpleRespDTO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqDTO pageReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zt.plat.module.base.api.materialproperties.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 物料属性分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialPropertiesPageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "属性编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "属性名称", example = "含量")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "计量单位量ID", example = "30468")
|
||||
private Long unitQuantityId;
|
||||
|
||||
@Schema(description = "属性类型")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "数据类型", example = "1")
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.zt.plat.module.base.api.materialproperties.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 物料属性 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialPropertiesRespDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "10591")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "属性编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "属性名称", example = "含量")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "计量单位量ID", example = "30468")
|
||||
private Long unitQuantityId;
|
||||
|
||||
@Schema(description = "属性类型")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "属性类型名称")
|
||||
private String dictionaryDataLabel;
|
||||
|
||||
@Schema(description = "数据类型", example = "1")
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "量纲名称")
|
||||
private String unitQuantityName;
|
||||
|
||||
@Schema(description = "计量单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Schema(description = "计量单位符号")
|
||||
private String unitSymbol;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.zt.plat.module.base.api.materialproperties.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料属性新增/修改 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialPropertiesSaveReqDTO {
|
||||
|
||||
@Schema(description = "主键ID", example = "10591")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "属性编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "属性编码不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "属性名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "含量")
|
||||
@NotEmpty(message = "属性名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "计量单位量ID", example = "30468")
|
||||
private Long unitQuantityId;
|
||||
|
||||
@Schema(description = "属性类型(业务字典数据值)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "属性类型不能为空")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "数据类型不能为空")
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zt.plat.module.base.api.materialproperties.dto;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料属性精简分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialPropertiesSimplePageReqDTO extends PageParam {
|
||||
|
||||
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "属性类型")
|
||||
private String dictionaryDataValue;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zt.plat.module.base.api.materialproperties.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料属性精简 Response DTO
|
||||
*/
|
||||
@Data
|
||||
public class MaterialPropertiesSimpleRespDTO {
|
||||
|
||||
@Schema(description = "物料属性ID", example = "1001")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "属性编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "属性名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据类型")
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Schema(description = "单位符号")
|
||||
private String unitSymbol;
|
||||
|
||||
@Schema(description = "属性类型")
|
||||
private String dictionaryDataValue;
|
||||
|
||||
@Schema(description = "属性类型名称")
|
||||
private String dictionaryDataLabel;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryDataDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypePageReqDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeRespDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeSaveReqDTO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypePageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypeRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypeSaveReqVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
|
||||
import com.zt.plat.module.base.service.businessdictionarytype.BusinessDictionaryTypeService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
public class BusinessDictionaryTypeApiImpl implements BusinessDictionaryTypeApi {
|
||||
|
||||
@Resource
|
||||
private BusinessDictionaryTypeService businessDictionaryTypeService;
|
||||
|
||||
@Override
|
||||
public CommonResult<BusinessDictionaryTypeRespDTO> createBusinessDictionaryType(BusinessDictionaryTypeSaveReqDTO createReqDTO) {
|
||||
BusinessDictionaryTypeRespVO respVO = businessDictionaryTypeService.createBusinessDictionaryType(convertSaveReq(createReqDTO));
|
||||
return success(BeanUtils.toBean(respVO, BusinessDictionaryTypeRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateBusinessDictionaryType(BusinessDictionaryTypeSaveReqDTO updateReqDTO) {
|
||||
businessDictionaryTypeService.updateBusinessDictionaryType(convertSaveReq(updateReqDTO));
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteBusinessDictionaryType(Long id) {
|
||||
businessDictionaryTypeService.deleteBusinessDictionaryType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteBusinessDictionaryTypeList(List<Long> ids) {
|
||||
businessDictionaryTypeService.deleteBusinessDictionaryTypeListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<BusinessDictionaryTypeRespDTO> getBusinessDictionaryType(Long id) {
|
||||
BusinessDictionaryTypeDO typeDO = businessDictionaryTypeService.getBusinessDictionaryType(id);
|
||||
return success(BeanUtils.toBean(typeDO, BusinessDictionaryTypeRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<BusinessDictionaryTypeRespDTO>> getBusinessDictionaryTypePage(BusinessDictionaryTypePageReqDTO pageReqDTO) {
|
||||
BusinessDictionaryTypePageReqVO pageReqVO = BeanUtils.toBean(pageReqDTO, BusinessDictionaryTypePageReqVO.class);
|
||||
PageResult<BusinessDictionaryTypeDO> pageResult = businessDictionaryTypeService.getBusinessDictionaryTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BusinessDictionaryTypeRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<BusinessDictionaryDataDTO>> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId) {
|
||||
List<BusinessDictionaryDataDO> list = businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId);
|
||||
return success(BeanUtils.toBean(list, BusinessDictionaryDataDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<BusinessDictionaryDataDTO>> getBusinessDictionaryDataListByType(String type) {
|
||||
List<BusinessDictionaryDataDO> list = businessDictionaryTypeService.getBusinessDictionaryDataListByType(type);
|
||||
return success(BeanUtils.toBean(list, BusinessDictionaryDataDTO.class));
|
||||
}
|
||||
|
||||
private BusinessDictionaryTypeSaveReqVO convertSaveReq(BusinessDictionaryTypeSaveReqDTO dto) {
|
||||
BusinessDictionaryTypeSaveReqVO reqVO = BeanUtils.toBean(dto, BusinessDictionaryTypeSaveReqVO.class);
|
||||
if (dto.getBusinessDictionaryDatas() != null && !dto.getBusinessDictionaryDatas().isEmpty()) {
|
||||
reqVO.setBusinessDictionaryDatas(BeanUtils.toBean(dto.getBusinessDictionaryDatas(), BusinessDictionaryDataDO.class));
|
||||
}
|
||||
return reqVO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialPageReqDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialRespDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialSaveReqDTO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialPageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialSaveReqVO;
|
||||
import com.zt.plat.module.base.service.departmentmaterial.DepartmentMaterialService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
public class DepartmentMaterialApiImpl implements DepartmentMaterialApi {
|
||||
|
||||
@Resource
|
||||
private DepartmentMaterialService departmentMaterialService;
|
||||
|
||||
@Override
|
||||
public CommonResult<DepartmentMaterialRespDTO> createDepartmentMaterial(DepartmentMaterialSaveReqDTO createReqDTO) {
|
||||
DepartmentMaterialRespVO respVO = departmentMaterialService.createDepartmentMaterial(BeanUtils.toBean(createReqDTO, DepartmentMaterialSaveReqVO.class));
|
||||
return success(BeanUtils.toBean(respVO, DepartmentMaterialRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateDepartmentMaterial(DepartmentMaterialSaveReqDTO updateReqDTO) {
|
||||
departmentMaterialService.updateDepartmentMaterial(BeanUtils.toBean(updateReqDTO, DepartmentMaterialSaveReqVO.class));
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteDepartmentMaterial(Long id) {
|
||||
departmentMaterialService.deleteDepartmentMaterial(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteDepartmentMaterialList(List<Long> ids) {
|
||||
departmentMaterialService.deleteDepartmentMaterialListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<DepartmentMaterialRespDTO> getDepartmentMaterial(Long id) {
|
||||
DepartmentMaterialRespVO respVO = departmentMaterialService.getDepartmentMaterial(id);
|
||||
return success(BeanUtils.toBean(respVO, DepartmentMaterialRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<DepartmentMaterialRespDTO>> getDepartmentMaterialPage(DepartmentMaterialPageReqDTO pageReqDTO) {
|
||||
DepartmentMaterialPageReqVO pageReqVO = BeanUtils.toBean(pageReqDTO, DepartmentMaterialPageReqVO.class);
|
||||
PageResult<DepartmentMaterialRespVO> pageResult = departmentMaterialService.getDepartmentMaterialPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DepartmentMaterialRespDTO.class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.zt.plat.module.base.api.materialclasses;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesSaveReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesTreeRespDTO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesPageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesSaveReqVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||
import com.zt.plat.module.base.service.materialclasses.MaterialClassesService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
public class MaterialClassesApiImpl implements MaterialClassesApi {
|
||||
|
||||
@Resource
|
||||
private MaterialClassesService materialClassesService;
|
||||
|
||||
@Override
|
||||
public CommonResult<MaterialClassesRespDTO> createMaterialClasses(MaterialClassesSaveReqDTO createReqDTO) {
|
||||
MaterialClassesRespVO respVO = materialClassesService.createMaterialClasses(BeanUtils.toBean(createReqDTO, MaterialClassesSaveReqVO.class));
|
||||
return success(BeanUtils.toBean(respVO, MaterialClassesRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateMaterialClasses(MaterialClassesSaveReqDTO updateReqDTO) {
|
||||
materialClassesService.updateMaterialClasses(BeanUtils.toBean(updateReqDTO, MaterialClassesSaveReqVO.class));
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteMaterialClasses(Long id) {
|
||||
materialClassesService.deleteMaterialClasses(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteMaterialClassesList(List<Long> ids) {
|
||||
materialClassesService.deleteMaterialClassesListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<MaterialClassesRespDTO> getMaterialClasses(Long id) {
|
||||
MaterialClassesDO classesDO = materialClassesService.getMaterialClasses(id);
|
||||
return success(BeanUtils.toBean(classesDO, MaterialClassesRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<MaterialClassesRespDTO>> getMaterialClassesPage(MaterialClassesPageReqDTO pageReqDTO) {
|
||||
MaterialClassesPageReqVO pageReqVO = BeanUtils.toBean(pageReqDTO, MaterialClassesPageReqVO.class);
|
||||
PageResult<MaterialClassesDO> pageResult = materialClassesService.getMaterialClassesPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MaterialClassesRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<MaterialClassesTreeRespDTO>> getMaterialClassesTree() {
|
||||
List<MaterialClassesDO> list = materialClassesService.getMaterialClassesList();
|
||||
return success(buildTree(list));
|
||||
}
|
||||
|
||||
private List<MaterialClassesTreeRespDTO> buildTree(List<MaterialClassesDO> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Map<Long, MaterialClassesTreeRespDTO> nodeMap = new LinkedHashMap<>();
|
||||
list.stream()
|
||||
.sorted(Comparator.comparing(MaterialClassesDO::getId))
|
||||
.forEach(item -> nodeMap.put(item.getId(), BeanUtils.toBean(item, MaterialClassesTreeRespDTO.class)));
|
||||
List<MaterialClassesTreeRespDTO> roots = new ArrayList<>();
|
||||
nodeMap.values().forEach(node -> {
|
||||
Long parentId = node.getParentId();
|
||||
if (parentId == null || parentId == 0 || !nodeMap.containsKey(parentId)) {
|
||||
roots.add(node);
|
||||
} else {
|
||||
nodeMap.get(parentId).getChildren().add(node);
|
||||
}
|
||||
});
|
||||
return roots;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<configuration>
|
||||
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<!-- 变量 yudao.info.base-package,基础业务包 -->
|
||||
<springProperty scope="context" name="yudao.info.base-package" source="yudao.info.base-package"/>
|
||||
<!-- 变量 zt.info.base-package,基础业务包 -->
|
||||
<springProperty scope="context" name="zt.info.base-package" source="zt.info.base-package"/>
|
||||
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 -->
|
||||
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.zt.plat.module.base.api.businessdictionarytype;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryDataDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypePageReqDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeRespDTO;
|
||||
import com.zt.plat.module.base.api.businessdictionarytype.dto.BusinessDictionaryTypeSaveReqDTO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypePageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypeRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.BusinessDictionaryTypeSaveReqVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
|
||||
import com.zt.plat.module.base.service.businessdictionarytype.BusinessDictionaryTypeService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class BusinessDictionaryTypeApiImplTest {
|
||||
|
||||
@InjectMocks
|
||||
private BusinessDictionaryTypeApiImpl api;
|
||||
|
||||
@Mock
|
||||
private BusinessDictionaryTypeService businessDictionaryTypeService;
|
||||
|
||||
private BusinessDictionaryTypeSaveReqDTO buildSaveReqDTO() {
|
||||
BusinessDictionaryDataDTO dataDTO = new BusinessDictionaryDataDTO();
|
||||
dataDTO.setId(10L);
|
||||
dataDTO.setLabel("启用");
|
||||
dataDTO.setValue("ENABLE");
|
||||
dataDTO.setRemark("默认状态");
|
||||
BusinessDictionaryTypeSaveReqDTO dto = new BusinessDictionaryTypeSaveReqDTO();
|
||||
dto.setId(1L);
|
||||
dto.setName("状态字典");
|
||||
dto.setType("base_material_status");
|
||||
dto.setStatus(0L);
|
||||
dto.setRemark("备注");
|
||||
dto.setBusinessDictionaryDatas(List.of(dataDTO));
|
||||
return dto;
|
||||
}
|
||||
|
||||
private BusinessDictionaryTypeRespVO buildRespVO() {
|
||||
BusinessDictionaryTypeRespVO respVO = new BusinessDictionaryTypeRespVO();
|
||||
respVO.setId(1L);
|
||||
respVO.setName("状态字典");
|
||||
respVO.setType("base_material_status");
|
||||
respVO.setStatus(0L);
|
||||
respVO.setRemark("备注");
|
||||
respVO.setCreateTime(LocalDateTime.now());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Test
|
||||
void createBusinessDictionaryType_shouldForwardToServiceAndReturnConvertedDto() {
|
||||
BusinessDictionaryTypeSaveReqDTO reqDTO = buildSaveReqDTO();
|
||||
BusinessDictionaryTypeRespVO serviceResp = buildRespVO();
|
||||
when(businessDictionaryTypeService.createBusinessDictionaryType(any(BusinessDictionaryTypeSaveReqVO.class)))
|
||||
.thenReturn(serviceResp);
|
||||
|
||||
CommonResult<BusinessDictionaryTypeRespDTO> result = api.createBusinessDictionaryType(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).usingRecursiveComparison()
|
||||
.ignoringFields("createTime")
|
||||
.isEqualTo(BeanAssertHelper.toRespDTO(serviceResp));
|
||||
|
||||
ArgumentCaptor<BusinessDictionaryTypeSaveReqVO> captor = ArgumentCaptor.forClass(BusinessDictionaryTypeSaveReqVO.class);
|
||||
verify(businessDictionaryTypeService).createBusinessDictionaryType(captor.capture());
|
||||
BusinessDictionaryTypeSaveReqVO passed = captor.getValue();
|
||||
assertThat(passed.getName()).isEqualTo(reqDTO.getName());
|
||||
assertThat(passed.getBusinessDictionaryDatas()).hasSize(1);
|
||||
BusinessDictionaryDataDO dataDO = passed.getBusinessDictionaryDatas().get(0);
|
||||
assertThat(dataDO.getLabel()).isEqualTo("启用");
|
||||
assertThat(dataDO.getValue()).isEqualTo("ENABLE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateBusinessDictionaryType_shouldInvokeServiceWithConvertedPayload() {
|
||||
BusinessDictionaryTypeSaveReqDTO reqDTO = buildSaveReqDTO();
|
||||
|
||||
CommonResult<Boolean> result = api.updateBusinessDictionaryType(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
ArgumentCaptor<BusinessDictionaryTypeSaveReqVO> captor = ArgumentCaptor.forClass(BusinessDictionaryTypeSaveReqVO.class);
|
||||
verify(businessDictionaryTypeService).updateBusinessDictionaryType(captor.capture());
|
||||
assertThat(captor.getValue().getName()).isEqualTo(reqDTO.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteBusinessDictionaryType_shouldInvokeService() {
|
||||
CommonResult<Boolean> result = api.deleteBusinessDictionaryType(123L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(businessDictionaryTypeService).deleteBusinessDictionaryType(123L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteBusinessDictionaryTypeList_shouldInvokeService() {
|
||||
List<Long> ids = List.of(1L, 2L);
|
||||
|
||||
CommonResult<Boolean> result = api.deleteBusinessDictionaryTypeList(ids);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(businessDictionaryTypeService).deleteBusinessDictionaryTypeListByIds(ids);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBusinessDictionaryType_shouldConvertDoToDto() {
|
||||
BusinessDictionaryTypeDO typeDO = new BusinessDictionaryTypeDO();
|
||||
typeDO.setId(55L);
|
||||
typeDO.setName("状态字典");
|
||||
when(businessDictionaryTypeService.getBusinessDictionaryType(55L)).thenReturn(typeDO);
|
||||
|
||||
CommonResult<BusinessDictionaryTypeRespDTO> result = api.getBusinessDictionaryType(55L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getId()).isEqualTo(55L);
|
||||
assertThat(result.getData().getName()).isEqualTo("状态字典");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBusinessDictionaryTypePage_shouldConvertPageResult() {
|
||||
BusinessDictionaryTypeDO typeDO = new BusinessDictionaryTypeDO();
|
||||
typeDO.setId(11L);
|
||||
typeDO.setName("状态");
|
||||
PageResult<BusinessDictionaryTypeDO> page = new PageResult<>(List.of(typeDO), 1L);
|
||||
when(businessDictionaryTypeService.getBusinessDictionaryTypePage(any(BusinessDictionaryTypePageReqVO.class)))
|
||||
.thenReturn(page);
|
||||
|
||||
BusinessDictionaryTypePageReqDTO reqDTO = new BusinessDictionaryTypePageReqDTO();
|
||||
reqDTO.setName("状态");
|
||||
CommonResult<PageResult<BusinessDictionaryTypeRespDTO>> result = api.getBusinessDictionaryTypePage(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getList()).hasSize(1);
|
||||
assertThat(result.getData().getList().get(0).getName()).isEqualTo("状态");
|
||||
assertThat(result.getData().getTotal()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBusinessDictionaryDataListByDictionaryTypeId_shouldConvertList() {
|
||||
BusinessDictionaryDataDO dataDO = new BusinessDictionaryDataDO();
|
||||
dataDO.setId(9L);
|
||||
dataDO.setLabel("启用");
|
||||
when(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(8L))
|
||||
.thenReturn(List.of(dataDO));
|
||||
|
||||
CommonResult<List<BusinessDictionaryDataDTO>> result = api.getBusinessDictionaryDataListByDictionaryTypeId(8L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).hasSize(1);
|
||||
assertThat(result.getData().get(0).getLabel()).isEqualTo("启用");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBusinessDictionaryDataListByType_shouldConvertList() {
|
||||
BusinessDictionaryDataDO dataDO = new BusinessDictionaryDataDO();
|
||||
dataDO.setId(9L);
|
||||
dataDO.setValue("ENABLE");
|
||||
when(businessDictionaryTypeService.getBusinessDictionaryDataListByType("base_material_status"))
|
||||
.thenReturn(List.of(dataDO));
|
||||
|
||||
CommonResult<List<BusinessDictionaryDataDTO>> result = api.getBusinessDictionaryDataListByType("base_material_status");
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).hasSize(1);
|
||||
assertThat(result.getData().get(0).getValue()).isEqualTo("ENABLE");
|
||||
}
|
||||
|
||||
private static final class BeanAssertHelper {
|
||||
private BeanAssertHelper() {
|
||||
}
|
||||
|
||||
static BusinessDictionaryTypeRespDTO toRespDTO(BusinessDictionaryTypeRespVO respVO) {
|
||||
BusinessDictionaryTypeRespDTO dto = new BusinessDictionaryTypeRespDTO();
|
||||
dto.setId(respVO.getId());
|
||||
dto.setName(respVO.getName());
|
||||
dto.setType(respVO.getType());
|
||||
dto.setStatus(respVO.getStatus());
|
||||
dto.setRemark(respVO.getRemark());
|
||||
dto.setCreateTime(respVO.getCreateTime());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.zt.plat.module.base.api.departmentmaterial;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialPageReqDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialRespDTO;
|
||||
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialSaveReqDTO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialPageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialSaveReqVO;
|
||||
import com.zt.plat.module.base.service.departmentmaterial.DepartmentMaterialService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DepartmentMaterialApiImplTest {
|
||||
|
||||
@InjectMocks
|
||||
private DepartmentMaterialApiImpl api;
|
||||
|
||||
@Mock
|
||||
private DepartmentMaterialService departmentMaterialService;
|
||||
|
||||
private DepartmentMaterialSaveReqDTO buildSaveReq() {
|
||||
DepartmentMaterialSaveReqDTO dto = new DepartmentMaterialSaveReqDTO();
|
||||
dto.setId(100L);
|
||||
dto.setDeptId(200L);
|
||||
dto.setInfomationId(300L);
|
||||
dto.setClassesId(400L);
|
||||
dto.setDictionaryDataValue("TYPE");
|
||||
dto.setStatus("ENABLE");
|
||||
dto.setRemark("备注");
|
||||
return dto;
|
||||
}
|
||||
|
||||
private DepartmentMaterialRespVO buildRespVO() {
|
||||
DepartmentMaterialRespVO respVO = new DepartmentMaterialRespVO();
|
||||
respVO.setId(100L);
|
||||
respVO.setDeptId(200L);
|
||||
respVO.setInfomationId(300L);
|
||||
respVO.setClassesId(400L);
|
||||
respVO.setDictionaryDataValue("TYPE");
|
||||
respVO.setRemark("备注");
|
||||
respVO.setStatus("ENABLE");
|
||||
respVO.setMaterialName("原材料");
|
||||
respVO.setCreateTime(LocalDateTime.now());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDepartmentMaterial_shouldForwardToServiceAndReturnConvertedDto() {
|
||||
DepartmentMaterialSaveReqDTO reqDTO = buildSaveReq();
|
||||
DepartmentMaterialRespVO serviceResp = buildRespVO();
|
||||
when(departmentMaterialService.createDepartmentMaterial(any(DepartmentMaterialSaveReqVO.class)))
|
||||
.thenReturn(serviceResp);
|
||||
|
||||
CommonResult<DepartmentMaterialRespDTO> result = api.createDepartmentMaterial(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
DepartmentMaterialRespDTO data = result.getData();
|
||||
assertThat(data.getId()).isEqualTo(serviceResp.getId());
|
||||
assertThat(data.getMaterialName()).isEqualTo("原材料");
|
||||
|
||||
ArgumentCaptor<DepartmentMaterialSaveReqVO> captor = ArgumentCaptor.forClass(DepartmentMaterialSaveReqVO.class);
|
||||
verify(departmentMaterialService).createDepartmentMaterial(captor.capture());
|
||||
DepartmentMaterialSaveReqVO passed = captor.getValue();
|
||||
assertThat(passed.getDeptId()).isEqualTo(reqDTO.getDeptId());
|
||||
assertThat(passed.getInfomationId()).isEqualTo(reqDTO.getInfomationId());
|
||||
assertThat(passed.getDictionaryDataValue()).isEqualTo(reqDTO.getDictionaryDataValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDepartmentMaterial_shouldInvokeService() {
|
||||
DepartmentMaterialSaveReqDTO reqDTO = buildSaveReq();
|
||||
|
||||
CommonResult<Boolean> result = api.updateDepartmentMaterial(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
ArgumentCaptor<DepartmentMaterialSaveReqVO> captor = ArgumentCaptor.forClass(DepartmentMaterialSaveReqVO.class);
|
||||
verify(departmentMaterialService).updateDepartmentMaterial(captor.capture());
|
||||
assertThat(captor.getValue().getDeptId()).isEqualTo(reqDTO.getDeptId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteDepartmentMaterial_shouldInvokeService() {
|
||||
CommonResult<Boolean> result = api.deleteDepartmentMaterial(99L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(departmentMaterialService).deleteDepartmentMaterial(99L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteDepartmentMaterialList_shouldInvokeService() {
|
||||
List<Long> ids = List.of(1L, 2L, 3L);
|
||||
|
||||
CommonResult<Boolean> result = api.deleteDepartmentMaterialList(ids);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(departmentMaterialService).deleteDepartmentMaterialListByIds(ids);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDepartmentMaterial_shouldConvertVoToDto() {
|
||||
DepartmentMaterialRespVO respVO = buildRespVO();
|
||||
when(departmentMaterialService.getDepartmentMaterial(11L)).thenReturn(respVO);
|
||||
|
||||
CommonResult<DepartmentMaterialRespDTO> result = api.getDepartmentMaterial(11L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getId()).isEqualTo(respVO.getId());
|
||||
assertThat(result.getData().getMaterialName()).isEqualTo(respVO.getMaterialName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDepartmentMaterialPage_shouldConvertPageResult() {
|
||||
DepartmentMaterialRespVO respVO = buildRespVO();
|
||||
PageResult<DepartmentMaterialRespVO> page = new PageResult<>(List.of(respVO), 1L);
|
||||
when(departmentMaterialService.getDepartmentMaterialPage(any(DepartmentMaterialPageReqVO.class)))
|
||||
.thenReturn(page);
|
||||
|
||||
DepartmentMaterialPageReqDTO reqDTO = new DepartmentMaterialPageReqDTO();
|
||||
reqDTO.setDeptId(200L);
|
||||
|
||||
CommonResult<PageResult<DepartmentMaterialRespDTO>> result = api.getDepartmentMaterialPage(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getList()).hasSize(1);
|
||||
assertThat(result.getData().getList().get(0).getMaterialName()).isEqualTo("原材料");
|
||||
assertThat(result.getData().getTotal()).isEqualTo(1L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.zt.plat.module.base.api.materialclasses;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesPageReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesRespDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesSaveReqDTO;
|
||||
import com.zt.plat.module.base.api.materialclasses.dto.MaterialClassesTreeRespDTO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesPageReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesRespVO;
|
||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.MaterialClassesSaveReqVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||
import com.zt.plat.module.base.service.materialclasses.MaterialClassesService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MaterialClassesApiImplTest {
|
||||
|
||||
@InjectMocks
|
||||
private MaterialClassesApiImpl api;
|
||||
|
||||
@Mock
|
||||
private MaterialClassesService materialClassesService;
|
||||
|
||||
private MaterialClassesSaveReqDTO buildSaveReq() {
|
||||
MaterialClassesSaveReqDTO dto = new MaterialClassesSaveReqDTO();
|
||||
dto.setId(1L);
|
||||
dto.setParentId(0L);
|
||||
dto.setCode("CLS001");
|
||||
dto.setName("原材料");
|
||||
dto.setLevel(1L);
|
||||
dto.setRemark("顶级分类");
|
||||
return dto;
|
||||
}
|
||||
|
||||
private MaterialClassesRespVO buildRespVO() {
|
||||
MaterialClassesRespVO respVO = new MaterialClassesRespVO();
|
||||
respVO.setId(1L);
|
||||
respVO.setParentId(0L);
|
||||
respVO.setCode("CLS001");
|
||||
respVO.setName("原材料");
|
||||
respVO.setLevel(1L);
|
||||
respVO.setRemark("顶级分类");
|
||||
respVO.setCreateTime(LocalDateTime.now());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Test
|
||||
void createMaterialClasses_shouldForwardToServiceAndReturnConvertedDto() {
|
||||
MaterialClassesSaveReqDTO reqDTO = buildSaveReq();
|
||||
MaterialClassesRespVO serviceResp = buildRespVO();
|
||||
when(materialClassesService.createMaterialClasses(any(MaterialClassesSaveReqVO.class)))
|
||||
.thenReturn(serviceResp);
|
||||
|
||||
CommonResult<MaterialClassesRespDTO> result = api.createMaterialClasses(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getName()).isEqualTo("原材料");
|
||||
|
||||
ArgumentCaptor<MaterialClassesSaveReqVO> captor = ArgumentCaptor.forClass(MaterialClassesSaveReqVO.class);
|
||||
verify(materialClassesService).createMaterialClasses(captor.capture());
|
||||
MaterialClassesSaveReqVO passed = captor.getValue();
|
||||
assertThat(passed.getCode()).isEqualTo(reqDTO.getCode());
|
||||
assertThat(passed.getName()).isEqualTo(reqDTO.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateMaterialClasses_shouldInvokeService() {
|
||||
MaterialClassesSaveReqDTO reqDTO = buildSaveReq();
|
||||
|
||||
CommonResult<Boolean> result = api.updateMaterialClasses(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
ArgumentCaptor<MaterialClassesSaveReqVO> captor = ArgumentCaptor.forClass(MaterialClassesSaveReqVO.class);
|
||||
verify(materialClassesService).updateMaterialClasses(captor.capture());
|
||||
assertThat(captor.getValue().getCode()).isEqualTo(reqDTO.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteMaterialClasses_shouldInvokeService() {
|
||||
CommonResult<Boolean> result = api.deleteMaterialClasses(5L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(materialClassesService).deleteMaterialClasses(5L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteMaterialClassesList_shouldInvokeService() {
|
||||
List<Long> ids = List.of(3L, 4L);
|
||||
|
||||
CommonResult<Boolean> result = api.deleteMaterialClassesList(ids);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData()).isTrue();
|
||||
verify(materialClassesService).deleteMaterialClassesListByIds(ids);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMaterialClasses_shouldConvertDoToDto() {
|
||||
MaterialClassesDO classesDO = new MaterialClassesDO();
|
||||
classesDO.setId(7L);
|
||||
classesDO.setName("辅料");
|
||||
when(materialClassesService.getMaterialClasses(7L)).thenReturn(classesDO);
|
||||
|
||||
CommonResult<MaterialClassesRespDTO> result = api.getMaterialClasses(7L);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getId()).isEqualTo(7L);
|
||||
assertThat(result.getData().getName()).isEqualTo("辅料");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMaterialClassesPage_shouldConvertPageResult() {
|
||||
MaterialClassesDO classesDO = new MaterialClassesDO();
|
||||
classesDO.setId(8L);
|
||||
classesDO.setName("辅料");
|
||||
PageResult<MaterialClassesDO> page = new PageResult<>(List.of(classesDO), 1L);
|
||||
when(materialClassesService.getMaterialClassesPage(any(MaterialClassesPageReqVO.class)))
|
||||
.thenReturn(page);
|
||||
|
||||
MaterialClassesPageReqDTO reqDTO = new MaterialClassesPageReqDTO();
|
||||
reqDTO.setName("辅料");
|
||||
|
||||
CommonResult<PageResult<MaterialClassesRespDTO>> result = api.getMaterialClassesPage(reqDTO);
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
assertThat(result.getData().getList()).hasSize(1);
|
||||
assertThat(result.getData().getList().get(0).getName()).isEqualTo("辅料");
|
||||
assertThat(result.getData().getTotal()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMaterialClassesTree_shouldAssembleHierarchy() {
|
||||
MaterialClassesDO root = new MaterialClassesDO();
|
||||
root.setId(1L);
|
||||
root.setParentId(0L);
|
||||
root.setName("根节点");
|
||||
|
||||
MaterialClassesDO child = new MaterialClassesDO();
|
||||
child.setId(2L);
|
||||
child.setParentId(1L);
|
||||
child.setName("子节点");
|
||||
|
||||
MaterialClassesDO orphan = new MaterialClassesDO();
|
||||
orphan.setId(3L);
|
||||
orphan.setParentId(99L);
|
||||
orphan.setName("孤儿节点");
|
||||
|
||||
when(materialClassesService.getMaterialClassesList()).thenReturn(List.of(child, root, orphan));
|
||||
|
||||
CommonResult<List<MaterialClassesTreeRespDTO>> result = api.getMaterialClassesTree();
|
||||
|
||||
assertThat(result.isSuccess()).isTrue();
|
||||
List<MaterialClassesTreeRespDTO> tree = result.getData();
|
||||
assertThat(tree).hasSize(2);
|
||||
MaterialClassesTreeRespDTO rootNode = tree.get(0);
|
||||
assertThat(rootNode.getId()).isEqualTo(1L);
|
||||
assertThat(rootNode.getChildren()).hasSize(1);
|
||||
assertThat(rootNode.getChildren().get(0).getId()).isEqualTo(2L);
|
||||
|
||||
MaterialClassesTreeRespDTO orphanNode = tree.get(1);
|
||||
assertThat(orphanNode.getId()).isEqualTo(3L);
|
||||
assertThat(orphanNode.getChildren()).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user