Merge remote-tracking branch 'origin/main'

This commit is contained in:
wr
2025-12-05 15:34:12 +08:00
4 changed files with 35 additions and 22 deletions

View File

@@ -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<String> timeKeys;
@ApiModelProperty("系统类型")
@NotBlank(message = "系统类型不为空")
@@ -84,6 +81,4 @@ public class ComponentParam {
}
}

View File

@@ -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<String> timeKeys;
public String getTimeKey() {
if (timeKeys != null) {
timeKey = String.join(",", timeKeys);
}
return timeKey;
}
}

View File

@@ -52,6 +52,9 @@ public class ComponentVO implements Serializable {
@ApiModelProperty("时间标识")
private String timeKey;
@ApiModelProperty("时间标识集合")
private List<String> timeKeys;
@ApiModelProperty("子级")
List<ComponentVO> children;

View File

@@ -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<ComponentMapper, Component
List<ComponentVO> list = new ArrayList<>();
List<ComponentVO> result = new ArrayList<>();
List<ComponentDTO> 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<String,List<ComponentVO>> map = list.stream().filter(m->!Objects.isNull(m.getSystemType())).collect(Collectors.groupingBy(ComponentVO::getSystemType));
map.forEach((k,v)->{
Map<String, List<ComponentVO>> 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<ComponentMapper, Component
componentVO.setName(dictData.getName());
componentVO.setChildren(
v.stream()
.filter(fun -> 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<ComponentMapper, Component
}
list = componentMapper.getComponentByList(componentList);
}
if (CollectionUtil.isEmpty(list)){
if (CollectionUtil.isEmpty(list)) {
return result;
}
list.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()));
componentVOList.add(componentVO);
});
Map<String,List<ComponentVO>> map = componentVOList.stream().collect(Collectors.groupingBy(ComponentVO::getSystemType));
map.forEach((k, v)->{
Map<String, List<ComponentVO>> 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<ComponentMapper, Component
component.setId("0");
component.setName("");
list.add(component);
list.addAll(this.lambdaQuery().eq(Component::getSystemType, systemType).eq(Component::getPid,ComponentState.FATHER_PID).eq(Component::getState, ComponentState.ENABLE).list());
list.addAll(this.lambdaQuery().eq(Component::getSystemType, systemType).eq(Component::getPid, ComponentState.FATHER_PID).eq(Component::getState, ComponentState.ENABLE).list());
return list;
}