diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/ComponentParam.java b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/ComponentParam.java index deaf8e1d2..8240e7591 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/ComponentParam.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/ComponentParam.java @@ -9,7 +9,6 @@ import lombok.EqualsAndHashCode; import org.hibernate.validator.constraints.Range; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import java.util.List; @@ -60,9 +59,7 @@ public class ComponentParam { private String image; @ApiModelProperty("时间标识") - private String timeKey; - - + private List timeKeys; @ApiModelProperty("系统类型") @NotBlank(message = "系统类型不为空") @@ -84,6 +81,4 @@ public class ComponentParam { } - - } diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/Component.java b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/Component.java index e076fa034..c4fda58cd 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/Component.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/Component.java @@ -1,14 +1,15 @@ package com.njcn.user.pojo.po; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.njcn.db.bo.BaseEntity; - -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + + /** - * * @author xuyang * @since 2021-12-13 */ @@ -80,5 +81,13 @@ public class Component extends BaseEntity { private String timeKey; + @TableField(exist = false) + private List timeKeys; + public String getTimeKey() { + if (timeKeys != null) { + timeKey = String.join(",", timeKeys); + } + return timeKey; + } } diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/vo/ComponentVO.java b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/vo/ComponentVO.java index 70d2129ec..c3b31d4c4 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/vo/ComponentVO.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/vo/ComponentVO.java @@ -52,6 +52,9 @@ public class ComponentVO implements Serializable { @ApiModelProperty("时间标识") private String timeKey; + @ApiModelProperty("时间标识集合") + private List timeKeys; + @ApiModelProperty("子级") List children; diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/ComponentServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/ComponentServiceImpl.java index 6b110d0c9..16ebe2176 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/ComponentServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/ComponentServiceImpl.java @@ -2,6 +2,7 @@ package com.njcn.user.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; @@ -25,7 +26,10 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -89,17 +93,18 @@ public class ComponentServiceImpl extends ServiceImpl list = new ArrayList<>(); List result = new ArrayList<>(); List componentList = componentMapper.getAllComponent(); - if (!CollectionUtils.isEmpty(componentList)){ + if (!CollectionUtils.isEmpty(componentList)) { componentList.forEach(item -> { ComponentVO componentVO = new ComponentVO(); BeanUtil.copyProperties(item, componentVO); + componentVO.setTimeKeys(StrUtil.split(item.getTimeKey(), ",")); // componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList())); list.add(componentVO); }); - Map> map = list.stream().filter(m->!Objects.isNull(m.getSystemType())).collect(Collectors.groupingBy(ComponentVO::getSystemType)); - map.forEach((k,v)->{ + Map> map = list.stream().filter(m -> !Objects.isNull(m.getSystemType())).collect(Collectors.groupingBy(ComponentVO::getSystemType)); + map.forEach((k, v) -> { DictData dictData = dicDataFeignClient.getDicDataById(k).getData(); - if (Objects.isNull(dictData)){ + if (Objects.isNull(dictData)) { throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY); } ComponentVO componentVO = new ComponentVO(); @@ -107,9 +112,9 @@ public class ComponentServiceImpl extends ServiceImpl Objects.equals(ComponentState.FATHER_PID, fun.getPid())) - .peek(funS -> funS.setChildren(getChildCategoryList(funS, v))) - .collect(Collectors.toList())); + .filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid())) + .peek(funS -> funS.setChildren(getChildCategoryList(funS, v))) + .collect(Collectors.toList())); result.add(componentVO); }); } @@ -132,19 +137,20 @@ public class ComponentServiceImpl extends ServiceImpl { ComponentVO componentVO = new ComponentVO(); BeanUtil.copyProperties(item, componentVO); + componentVO.setTimeKeys(StrUtil.split(item.getTimeKey(), ",")); // componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList())); componentVOList.add(componentVO); }); - Map> map = componentVOList.stream().collect(Collectors.groupingBy(ComponentVO::getSystemType)); - map.forEach((k, v)->{ + Map> map = componentVOList.stream().collect(Collectors.groupingBy(ComponentVO::getSystemType)); + map.forEach((k, v) -> { DictData dictData = dicDataFeignClient.getDicDataById(k).getData(); - if (Objects.isNull(dictData)){ + if (Objects.isNull(dictData)) { throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY); } ComponentVO componentVO = new ComponentVO(); @@ -167,7 +173,7 @@ public class ComponentServiceImpl extends ServiceImpl