fix(material): 新增是否树的判断标识

This commit is contained in:
han0
2023-12-19 09:31:46 +08:00
parent c54e3ca69b
commit c1ca1800b4
3 changed files with 20 additions and 8 deletions

View File

@@ -40,7 +40,8 @@ public class MaterialController {
@ApiOperation("获取材料树")
@GetMapping("/tree")
public HttpResponse getTree () {
QueryWrapper<Material> query = new QueryWrapper<>();
LambdaQueryWrapper<Material> query = new LambdaQueryWrapper<>();
query.eq(Material::getIsTree, 1);
List<Map<String, Object>> maps = materialService.listMaps(query);
maps = maps.stream().map(map -> convertKeysToLowercase(map)).collect(Collectors.toList());
// todo 列转树改为泛型对象入参
@@ -65,15 +66,18 @@ public class MaterialController {
@ApiParam(value = "父节点id") @RequestParam("parent_id") String parentId
) {
LambdaQueryWrapper<Material> query = new LambdaQueryWrapper<>();
query.eq(Material::getIsTree, 0);
if (parentId != null) {
query.eq(Material::getParentId, parentId);
}
if (keyWord != null) {
query.and(q -> q
.like(Material::getCategory1, keyWord).or()
.like(Material::getCategory2, keyWord).or()
.like(Material::getCategory3, keyWord).or()
.like(Material::getCategory4, keyWord)
);
}
var result = materialService.list(query);
return FuHttpResponse.Builder().dataResponse(result).build();

View File

@@ -119,6 +119,10 @@ public class Material extends Model<Material> {
@TableField("`TYPE`")
private Integer type;
@ApiModelProperty("是否树")
@TableField("`IS_TREE`")
private Integer isTree;
@Override
public Serializable pkVal() {
return this.id;
@@ -144,6 +148,7 @@ public class Material extends Model<Material> {
this.unit = params.getUnit();
this.spec = params.getSpec();
this.tax = params.getTax();
this.isTree = params.getIsTree();
this.updateTime = LocalDateTime.now();
this.createTime = LocalDateTime.now();
this.createUserName = user.getName();

View File

@@ -40,6 +40,9 @@ public class MaterialCreateRequest {
@ApiModelProperty("税率")
private Integer tax;
@ApiModelProperty("是否树")
private Integer isTree;
public void check() throws Exception{
String flag = this.parentId.replace(".00", "");
if (!this.id.contains(flag)) {