基于云平台系统功能调整

This commit is contained in:
xy
2026-01-07 19:21:21 +08:00
parent 09e2f329b7
commit 02578546f2
16 changed files with 288 additions and 44 deletions

View File

@@ -0,0 +1,74 @@
package com.njcn.user.controller;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.user.pojo.param.RoleSystemParam;
import com.njcn.user.pojo.po.SysRoleSystem;
import com.njcn.user.service.ISysRoleSystemService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-01-05
*/
@RestController
@RequestMapping("/sysRoleSystem")
@Validated
@Slf4j
@Api(tags = "角色与系统管理")
@AllArgsConstructor
public class SysRoleSystemController extends BaseController {
private final ISysRoleSystemService sysRoleSystemService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getSystemByRoleId")
@ApiOperation("根据角色id获取系统信息")
@ApiImplicitParam(name = "id", value = "角色id", required = true)
public HttpResult<RoleSystemParam> getSystemByRoleId(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getSystemByRoleId");
SysRoleSystem sysRoleSystem = sysRoleSystemService.selectByMultiId(
new SysRoleSystem().setRoleId(id)
);
RoleSystemParam result = new RoleSystemParam();
if (ObjectUtil.isNotNull(sysRoleSystem)) {
result.setRoleId(sysRoleSystem.getRoleId());
result.setSystemIds(Arrays.asList(sysRoleSystem.getSystemId().split(",")));
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增角色与系统关系")
@ApiImplicitParam(name = "param", value = "新增数据", required = true)
public HttpResult<Boolean> add(@RequestBody @Validated RoleSystemParam param) {
String methodDescribe = getMethodDescribe("add");
SysRoleSystem sysRoleSystem = new SysRoleSystem()
.setRoleId(param.getRoleId())
.setSystemId(String.join(",",param.getSystemIds()));
boolean result = sysRoleSystemService.saveOrUpdateByMultiId(sysRoleSystem);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,16 @@
package com.njcn.user.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.user.pojo.po.SysRoleSystem;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2026-01-05
*/
public interface SysRoleSystemMapper extends MppBaseMapper<SysRoleSystem> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.user.service;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.user.pojo.po.SysRoleSystem;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2026-01-05
*/
public interface ISysRoleSystemService extends IMppService<SysRoleSystem> {
}

View File

@@ -54,15 +54,12 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
checkComponentParam(componentParam, false);
Component component = new Component();
BeanUtil.copyProperties(componentParam, component);
// String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
// component.setFunctionGroup(functionGroup);
component.setState(ComponentState.ENABLE);
if (Objects.equals(componentParam.getPid(), FunctionState.FATHER_PID)) {
component.setPids(FunctionState.FATHER_PID);
} else {
Component fatherComponent = this.lambdaQuery().eq(Component::getId, componentParam.getPid()).one();
String pidS = fatherComponent.getPids();
component.setPids(pidS + "," + componentParam.getPid());
component.setPid("1");
component.setPids("0,1");
}
return this.save(component);
}
@@ -80,11 +77,49 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
checkComponentParam(componentParam, true);
Component component = new Component();
BeanUtil.copyProperties(componentParam, component);
// String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
// component.setFunctionGroup(functionGroup);
if (Objects.equals(componentParam.getPid(), FunctionState.FATHER_PID)) {
component.setPids(FunctionState.FATHER_PID);
} else {
component.setPid("1");
component.setPids("0,1");
}
return this.updateById(component);
}
// @Override
// public List<ComponentVO> getComponentTree() {
// List<ComponentVO> list = new ArrayList<>();
// List<ComponentVO> result = new ArrayList<>();
// List<ComponentDTO> componentList = componentMapper.getAllComponent();
// if (!CollectionUtils.isEmpty(componentList)) {
// componentList.forEach(item -> {
// ComponentVO componentVO = new ComponentVO();
// BeanUtil.copyProperties(item, componentVO);
// componentVO.setTimeKeys(StrUtil.split(item.getTimeKey(), ","));
// 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) -> {
// DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
// if (Objects.isNull(dictData)) {
// throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY);
// }
// ComponentVO componentVO = new ComponentVO();
// componentVO.setId(dictData.getId());
// componentVO.setName(dictData.getName());
// componentVO.setSort(dictData.getSort());
// componentVO.setChildren(
// v.stream()
// .filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
// .peek(funS -> funS.setChildren(getChildCategoryList(funS, v))).sorted(Comparator.comparing(ComponentVO::getSort))
// .collect(Collectors.toList()));
// result.add(componentVO);
// });
// result.sort(Comparator.comparing(ComponentVO::getSort));
// }
// return result;
// }
@Override
public List<ComponentVO> getComponentTree() {
List<ComponentVO> list = new ArrayList<>();
@@ -95,24 +130,35 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
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) -> {
DictData dictData = dicDataFeignClient.getDicDataById(k).getData();
if (Objects.isNull(dictData)) {
throw new BusinessException(SystemResponseEnum.SYSTEM_TYPE_EMPTY);
}
//二层集合
List<ComponentVO> second = list.stream().filter(item -> Objects.equals(item.getPid(), "0")).collect(Collectors.toList());
//三层集合
List<ComponentVO> third = list.stream().filter(item -> Objects.equals(item.getPid(), "1")).collect(Collectors.toList());
Set<String> uniqueValues = list.stream()
.flatMap(obj -> Arrays.stream(obj.getSystemType().split(",")))
.map(String::trim)
.collect(Collectors.toSet());
//根据字典code获取当前所有系统
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode("System_Type").getData();
dictDataList.forEach(dic->{
//第一层
ComponentVO componentVO = new ComponentVO();
componentVO.setId(dictData.getId());
componentVO.setName(dictData.getName());
componentVO.setSort(dictData.getSort());
componentVO.setChildren(
v.stream()
.filter(fun -> Objects.equals(ComponentState.FATHER_PID, fun.getPid()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, v))).sorted(Comparator.comparing(ComponentVO::getSort))
.collect(Collectors.toList()));
componentVO.setId(dic.getId());
componentVO.setName(dic.getName());
componentVO.setSort(dic.getSort());
//第二层
if (CollectionUtil.isNotEmpty(second)) {
List<ComponentVO> l2 = second.stream().filter(item2 -> item2.getSystemType().contains(dic.getId())).sorted(Comparator.comparing(ComponentVO::getSort)).collect(Collectors.toList());
componentVO.setChildren(l2);
//第三层
componentVO.getChildren().forEach(item3->{
List<ComponentVO> l3 = third.stream().filter(item4 -> item4.getComponentType().contains(item3.getId())).sorted(Comparator.comparing(ComponentVO::getSort)).collect(Collectors.toList());
item3.setChildren(l3);
});
}
result.add(componentVO);
});
result.sort(Comparator.comparing(ComponentVO::getSort));
@@ -167,13 +213,11 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
@Override
public List<Component> getFatherComponent(String systemType) {
List<Component> list = new ArrayList<>();
Component component = new 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());
return list;
return new ArrayList<>(this.lambdaQuery()
.eq(Component::getSystemType, systemType)
.eq(Component::getPid, ComponentState.FATHER_PID)
.eq(Component::getState, ComponentState.ENABLE)
.list());
}
/**

View File

@@ -1,12 +1,12 @@
package com.njcn.user.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.user.enums.UserResponseEnum;
@@ -127,11 +127,10 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
@Override
public List<Role> selectRoleDetail(Integer id) {
List<Integer> role = new ArrayList<>();
role.add(RoleType.USER);
role.add(RoleType.APP);
if (Objects.equals(id, RoleType.SUPER_ADMINISTRATOR)) {
role.add(RoleType.ADMINISTRATOR);
} else {
role.add(RoleType.USER);
role.add(RoleType.APP);
}
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("sys_role.state", DataStateEnum.DELETED.getCode());

View File

@@ -0,0 +1,20 @@
package com.njcn.user.service.impl;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.user.mapper.SysRoleSystemMapper;
import com.njcn.user.pojo.po.SysRoleSystem;
import com.njcn.user.service.ISysRoleSystemService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2026-01-05
*/
@Service
public class SysRoleSystemServiceImpl extends MppServiceImpl<SysRoleSystemMapper, SysRoleSystem> implements ISysRoleSystemService {
}

View File

@@ -286,13 +286,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
if (Objects.equals(UserType.SUPER_ADMINISTRATOR, type)) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER, UserType.APP));
}
//业务管理员,展示管理员和web用户
//业务管理员展示web用户
else if (Objects.equals(UserType.ADMINISTRATOR, type) && !roleCodeList.contains("operation_manager")) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER));
types.addAll(Arrays.asList(UserType.USER));
}
//运维管理员,展示管理员和App用户
//运维管理员,展示web用户、App用户
else if (Objects.equals(UserType.ADMINISTRATOR, type) && roleCodeList.contains("operation_manager")) {
types.addAll(Arrays.asList(UserType.ADMINISTRATOR, UserType.USER, UserType.APP));
types.addAll(Arrays.asList(UserType.USER, UserType.APP));
}
if (ObjectUtil.isNotNull(queryParam)) {
//查询参数不为空,进行条件填充
@@ -482,7 +482,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
Role roleByCode = roleService.getRoleByCode(AppRoleEnum.MARKET_USER.getCode());
List<UserRole> userRoles = userRoleMapper.selectUserRole(Stream.of(roleByCode.getId()).collect(Collectors.toList()));
List<String> collect = userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList());
return this.listByIds(collect);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(User::getState, UserState.DELETE).in(User::getId, collect);
return this.list(queryWrapper);
}
@Override