@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import java.time.LocalDateTime; | |||||
import java.util.*; | import java.util.*; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
@@ -150,6 +151,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR | |||||
throw BizException.wrap("角色名 %s 已经存在", data.getName()); | throw BizException.wrap("角色名 %s 已经存在", data.getName()); | ||||
} | } | ||||
Role role = BeanUtil.toBean(data, Role.class); | Role role = BeanUtil.toBean(data, Role.class); | ||||
role.setUpdateOn(LocalDateTime.now()); | |||||
role.setUpdateBy(userId); | role.setUpdateBy(userId); | ||||
updateById(role); | updateById(role); | ||||
saveRoleMenu(data.getMenuIds(), role.getId()); | saveRoleMenu(data.getMenuIds(), role.getId()); | ||||
@@ -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 { | |||||
} |
@@ -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.po.ReqUserInfoListPO; | ||||
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO; | import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO; | ||||
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO; | 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.Api; | ||||
import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
import javax.validation.Valid; | import javax.validation.Valid; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @author Liuxinxin | * @author Liuxinxin | ||||
@@ -61,4 +63,9 @@ public class UserInfoController { | |||||
return userInfoManage.currentUserInfo(); | return userInfoManage.currentUserInfo(); | ||||
} | } | ||||
@ApiOperation(value = "获取当前用户可控角色列表") | |||||
@PostMapping("/controlled/role-list") | |||||
public List<UserRoleVO> getControlledRoleList() { | |||||
return userInfoManage.getControlledRoleList(); | |||||
} | |||||
} | } |
@@ -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; | |||||
} |
@@ -10,6 +10,7 @@ import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.common.constant.RegionConst; | import com.ningdatech.pmapi.common.constant.RegionConst; | ||||
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | ||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | 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.DingEmployeeInfo; | ||||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | ||||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | ||||
@@ -490,4 +491,42 @@ public class UserInfoManage { | |||||
} | } | ||||
return processInstanceUserDto; | 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; | |||||
} | |||||
} | } |