add
This commit is contained in:
@ -4,6 +4,8 @@ import com.qiaoba.api.system.entity.dto.ResetUserBasicInfoDto;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.result.AjaxResult;
|
||||
import com.qiaoba.module.system.service.SysProfileService;
|
||||
import com.qiaoba.module.system.service.SysUserPostService;
|
||||
import com.qiaoba.module.system.service.SysUserRoleService;
|
||||
import com.qiaoba.module.system.service.SysUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -26,15 +28,16 @@ public class SysProfileController {
|
||||
|
||||
private final SysProfileService sysProfileService;
|
||||
private final SysUserService sysUserService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final SysUserPostService sysUserPostService;
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "基本信息")
|
||||
public AjaxResult profile() {
|
||||
String username = SecurityUtil.getLoginUserId();
|
||||
AjaxResult ajax = AjaxResult.success(sysUserService.selectById(username, false));
|
||||
// todo
|
||||
ajax.put("roleGroup", "超级管理员,普通角色");
|
||||
ajax.put("postGroup", "董事长");
|
||||
String userId = SecurityUtil.getLoginUserId();
|
||||
AjaxResult ajax = AjaxResult.success(sysUserService.selectById(userId, false));
|
||||
ajax.put("roleGroup", sysUserRoleService.selectRoleGroup(userId));
|
||||
ajax.put("postGroup", sysUserPostService.selectPostGroup(userId));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
@ -39,4 +39,11 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
*/
|
||||
String selectBindUserByRoleId(@Param("list") List<String> ids);
|
||||
|
||||
/**
|
||||
* 查询用户拥有角色
|
||||
*
|
||||
* @param userId userId
|
||||
* @return 角色名称
|
||||
*/
|
||||
List<String> selectRoleGroupByUserId(String userId);
|
||||
}
|
||||
|
@ -22,6 +22,14 @@ public interface SysUserPostMapper extends BaseMapper<SysUserPost> {
|
||||
*/
|
||||
List<String> selectPostIdsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 通过userId查询所绑定的岗位名称列表
|
||||
*
|
||||
* @param userId userId
|
||||
* @return postNames
|
||||
*/
|
||||
List<String> selectPostNamesByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询正在被使用的岗位名称列表
|
||||
*
|
||||
|
@ -33,6 +33,15 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
*/
|
||||
List<String> selectRoleKeysByUserId(@Param("userId") String userId, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 通过userId查询所绑定的角色Key列表
|
||||
*
|
||||
* @param userId userId
|
||||
* @param status 状态
|
||||
* @return roleIds
|
||||
*/
|
||||
List<String> selectRoleNamesByUserId(@Param("userId") String userId, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 批量取消角色所绑定的用户
|
||||
*
|
||||
|
@ -49,4 +49,12 @@ public interface SysUserPostService {
|
||||
* @return postNames
|
||||
*/
|
||||
List<String> selectUsedPostNameByIds(List<String> postIds);
|
||||
|
||||
/**
|
||||
* 查询用户拥有的岗位
|
||||
*
|
||||
* @param userId userId
|
||||
* @return 岗位 逗号拼接
|
||||
*/
|
||||
String selectPostGroup(String userId);
|
||||
}
|
||||
|
@ -60,6 +60,15 @@ public interface SysUserRoleService {
|
||||
*/
|
||||
List<String> selectRoleKeysByUserId(String userId, String status);
|
||||
|
||||
/**
|
||||
* 通过userId查询所绑定的角色Key列表
|
||||
*
|
||||
* @param userId userId
|
||||
* @param status 状态
|
||||
* @return roleNames
|
||||
*/
|
||||
List<String> selectRoleNamesByUserId(String userId, String status);
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*
|
||||
@ -67,4 +76,12 @@ public interface SysUserRoleService {
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void insertAuthUsers(String roleId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 查询用户拥有的角色
|
||||
*
|
||||
* @param userId userId
|
||||
* @return 角色 逗号拼接
|
||||
*/
|
||||
String selectRoleGroup(String userId);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.qiaoba.api.system.entity.dto.DataScopeDto;
|
||||
import com.qiaoba.api.system.entity.dto.SysRoleDto;
|
||||
import com.qiaoba.api.system.entity.param.SysRoleParam;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.constants.BaseConstant;
|
||||
import com.qiaoba.common.base.exceptions.ServiceException;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.qiaoba.module.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.qiaoba.api.system.entity.SysUserPost;
|
||||
import com.qiaoba.common.base.constants.BaseConstant;
|
||||
import com.qiaoba.module.system.mapper.SysUserPostMapper;
|
||||
import com.qiaoba.module.system.service.SysUserPostService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -48,6 +51,12 @@ public class SysUserPostServiceImpl implements SysUserPostService {
|
||||
return sysUserPostMapper.selectUsedPostNameByIds(postIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectPostGroup(String userId) {
|
||||
List<String> list = sysUserPostMapper.selectPostNamesByUserId(userId);
|
||||
return CollUtil.isNotEmpty(list) ? StrUtil.join(BaseConstant.LINE_JOIN_STR, list) : StrUtil.EMPTY;
|
||||
}
|
||||
|
||||
private QueryWrapper<SysUserPost> createWrapper(String userId) {
|
||||
QueryWrapper<SysUserPost> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.qiaoba.module.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.qiaoba.api.system.entity.SysUserRole;
|
||||
import com.qiaoba.common.base.constants.BaseConstant;
|
||||
import com.qiaoba.common.base.enums.BaseEnum;
|
||||
import com.qiaoba.module.system.mapper.SysUserRoleMapper;
|
||||
import com.qiaoba.module.system.service.SysUserRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -54,6 +58,11 @@ public class SysUserRoleServiceImpl implements SysUserRoleService {
|
||||
return sysUserRoleMapper.selectRoleKeysByUserId(userId, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectRoleNamesByUserId(String userId, String status) {
|
||||
return sysUserRoleMapper.selectRoleNamesByUserId(userId, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertAuthUsers(String roleId, List<String> userIds) {
|
||||
List<SysUserRole> list = new ArrayList<>();
|
||||
@ -63,6 +72,12 @@ public class SysUserRoleServiceImpl implements SysUserRoleService {
|
||||
Db.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectRoleGroup(String userId) {
|
||||
List<String> list = selectRoleNamesByUserId(userId, BaseEnum.NORMAL.getCode());
|
||||
return CollUtil.isNotEmpty(list) ? StrUtil.join(BaseConstant.LINE_JOIN_STR, list) : StrUtil.EMPTY;
|
||||
}
|
||||
|
||||
private QueryWrapper<SysUserRole> createWrapper(String userId) {
|
||||
QueryWrapper<SysUserRole> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
|
@ -8,6 +8,14 @@
|
||||
select post_id from sys_user_post where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectPostNamesByUserId" resultType="string">
|
||||
select t2.post_name
|
||||
from sys_user_post t1
|
||||
left join sys_post t2 on t1.post_id = t2.post_id
|
||||
where t1.user_id = #{userId}
|
||||
order by t2.post_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectUsedPostNameByIds" resultType="string">
|
||||
select DISTINCT t1.post_name
|
||||
from sys_post t1
|
||||
|
@ -22,6 +22,15 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectRoleNamesByUserId" resultType="string">
|
||||
select t2.role_name from sys_user_role t1
|
||||
left join sys_role t2 on t2.role_id = t1.role_id
|
||||
where t1.user_id = #{userId}
|
||||
<if test="status != null and status != ''">
|
||||
and t2.status = #{status}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteByRoleIdAndUserIds">
|
||||
delete from sys_user_role where role_id = #{roleId} and user_id in
|
||||
<foreach collection="list" item="userId" open="(" separator="," close=")">
|
||||
|
Reference in New Issue
Block a user