瀏覽代碼

新增专家可控角色列表

master
niohe·erbao 1 年之前
父節點
當前提交
aa5f2e2218
共有 5 個文件被更改,包括 48 次插入61 次删除
  1. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RoleServiceImpl.java
  2. +0
    -20
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/RoleInfoController.java
  3. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java
  4. +0
    -41
      pmapi/src/main/java/com/ningdatech/pmapi/user/entity/RoleInfo.java
  5. +39
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RoleServiceImpl.java 查看文件

@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

@@ -150,6 +151,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
throw BizException.wrap("角色名 %s 已经存在", data.getName());
}
Role role = BeanUtil.toBean(data, Role.class);
role.setUpdateOn(LocalDateTime.now());
role.setUpdateBy(userId);
updateById(role);
saveRoleMenu(data.getMenuIds(), role.getId());


+ 0
- 20
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/RoleInfoController.java 查看文件

@@ -1,20 +0,0 @@
package com.ningdatech.pmapi.user.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
* <p>
* 角色表 前端控制器
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
@Controller
@RequestMapping("/pmapi.user/role-info")
public class RoleInfoController {

}

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java 查看文件

@@ -9,6 +9,7 @@ import com.ningdatech.pmapi.user.model.po.ReqUserDisableOrEnablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
* @author Liuxinxin
@@ -61,4 +63,9 @@ public class UserInfoController {
return userInfoManage.currentUserInfo();
}

@ApiOperation(value = "获取当前用户可控角色列表")
@PostMapping("/controlled/role-list")
public List<UserRoleVO> getControlledRoleList() {
return userInfoManage.getControlledRoleList();
}
}

+ 0
- 41
pmapi/src/main/java/com/ningdatech/pmapi/user/entity/RoleInfo.java 查看文件

@@ -1,41 +0,0 @@
package com.ningdatech.pmapi.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* <p>
* 角色表
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
@Data
@TableName("nd_role_info")
@ApiModel(value = "RoleInfo对象", description = "角色表")
public class RoleInfo implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;

@ApiModelProperty("角色名称")
private String name;

@ApiModelProperty("备注")
private String description;

private LocalDateTime createOn;

private LocalDateTime updateOn;

}

+ 39
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java 查看文件

@@ -10,6 +10,7 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.constant.RegionConst;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
@@ -490,4 +491,42 @@ public class UserInfoManage {
}
return processInstanceUserDto;
}

/**
* 获取当前用户可控角色列表
*
* @return
*/
public List<UserRoleVO> getControlledRoleList() {
Long userId = LoginUserUtil.getUserId();
// 装配用户角色信息列表
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userId));

List<UserRoleVO> controlledRoleVOList = new ArrayList<>();
List<Long> controlledRoleIdList = new ArrayList<>();
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList());
controlledRoleIdList.addAll(roleIdList);
List<Role> roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList));

for (Role role : roleList) {
List<Long> manageRoleIdList = BizUtils.splitToLong(role.getManageRoleIds());
if (CollUtil.isNotEmpty(manageRoleIdList)) {
controlledRoleIdList.addAll(manageRoleIdList);
}
}
controlledRoleIdList = controlledRoleIdList.stream().distinct().collect(Collectors.toList());
List<Role> controlledRoleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, controlledRoleIdList));

controlledRoleVOList = controlledRoleList.stream().map(r -> {
UserRoleVO userRoleVO = new UserRoleVO();
userRoleVO.setId(r.getId());
userRoleVO.setName(r.getName());
userRoleVO.setCode(r.getCode());
return userRoleVO;
}).collect(Collectors.toList());
}
return controlledRoleVOList;
}
}

Loading…
取消
儲存