角色权限修改
正在显示
6 个修改的文件
包含
65 行增加
和
16 行删除
... | @@ -13,15 +13,14 @@ import com.skua.core.context.BaseContextHandler; | ... | @@ -13,15 +13,14 @@ import com.skua.core.context.BaseContextHandler; |
13 | import com.skua.core.entity.SysPermissionDataRule; | 13 | import com.skua.core.entity.SysPermissionDataRule; |
14 | import com.skua.core.query.QueryGenerator; | 14 | import com.skua.core.query.QueryGenerator; |
15 | import com.skua.core.util.ConvertUtils; | 15 | import com.skua.core.util.ConvertUtils; |
16 | import com.skua.modules.system.entity.SysDepart; | ||
16 | import com.skua.modules.system.entity.SysPermission; | 17 | import com.skua.modules.system.entity.SysPermission; |
17 | import com.skua.modules.system.entity.SysRole; | 18 | import com.skua.modules.system.entity.SysRole; |
18 | import com.skua.modules.system.entity.SysRolePermission; | 19 | import com.skua.modules.system.entity.SysRolePermission; |
19 | import com.skua.modules.system.model.TreeModel; | 20 | import com.skua.modules.system.model.TreeModel; |
20 | import com.skua.modules.system.service.ISysPermissionDataRuleService; | 21 | import com.skua.modules.system.service.*; |
21 | import com.skua.modules.system.service.ISysPermissionService; | ||
22 | import com.skua.modules.system.service.ISysRolePermissionService; | ||
23 | import com.skua.modules.system.service.ISysRoleService; | ||
24 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
23 | import org.apache.commons.lang.StringUtils; | ||
25 | import org.apache.shiro.SecurityUtils; | 24 | import org.apache.shiro.SecurityUtils; |
26 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 25 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
27 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; | 26 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
... | @@ -51,6 +50,9 @@ public class SysRoleController { | ... | @@ -51,6 +50,9 @@ public class SysRoleController { |
51 | private ISysRoleService sysRoleService; | 50 | private ISysRoleService sysRoleService; |
52 | 51 | ||
53 | @Autowired | 52 | @Autowired |
53 | private ISysDepartService sysDepartService; | ||
54 | |||
55 | @Autowired | ||
54 | private ISysPermissionDataRuleService sysPermissionDataRuleService; | 56 | private ISysPermissionDataRuleService sysPermissionDataRuleService; |
55 | 57 | ||
56 | @Autowired | 58 | @Autowired |
... | @@ -75,9 +77,14 @@ public class SysRoleController { | ... | @@ -75,9 +77,14 @@ public class SysRoleController { |
75 | Result<IPage<SysRole>> result = new Result<IPage<SysRole>>(); | 77 | Result<IPage<SysRole>> result = new Result<IPage<SysRole>>(); |
76 | QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap()); | 78 | QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap()); |
77 | Page<SysRole> page = new Page<SysRole>(pageNo, pageSize); | 79 | Page<SysRole> page = new Page<SysRole>(pageNo, pageSize); |
78 | // if(!BaseContextHandler.getUserId().equals("admin")){ | 80 | if(StringUtils.isNotEmpty(BaseContextHandler.getDeparts())){ |
79 | // queryWrapper.notLike("role_code","admin"); | 81 | SysDepart sysDepart = sysDepartService.getById(BaseContextHandler.getDeparts()); |
80 | // } | 82 | if(sysDepart!=null){ |
83 | if(!"A01".equals(sysDepart.getOrgCode())){ | ||
84 | queryWrapper.notLike("role_type","group"); | ||
85 | } | ||
86 | } | ||
87 | } | ||
81 | IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper); | 88 | IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper); |
82 | result.setSuccess(true); | 89 | result.setSuccess(true); |
83 | result.setResult(pageList); | 90 | result.setResult(pageList); |
... | @@ -195,6 +202,14 @@ public class SysRoleController { | ... | @@ -195,6 +202,14 @@ public class SysRoleController { |
195 | if(!BaseContextHandler.getUserLoginName().equals("admin")){ | 202 | if(!BaseContextHandler.getUserLoginName().equals("admin")){ |
196 | queryWrapper.notLike("role_code","admin"); | 203 | queryWrapper.notLike("role_code","admin"); |
197 | } | 204 | } |
205 | if(StringUtils.isNotEmpty(BaseContextHandler.getDeparts())){ | ||
206 | SysDepart sysDepart = sysDepartService.getById(BaseContextHandler.getDeparts()); | ||
207 | if(sysDepart!=null){ | ||
208 | if(!"A01".equals(sysDepart.getOrgCode())){ | ||
209 | queryWrapper.notLike("role_type","group"); | ||
210 | } | ||
211 | } | ||
212 | } | ||
198 | queryWrapper.orderByDesc("create_time"); | 213 | queryWrapper.orderByDesc("create_time"); |
199 | List<SysRole> list = sysRoleService.list(queryWrapper); | 214 | List<SysRole> list = sysRoleService.list(queryWrapper); |
200 | if(list==null||list.size()<=0) { | 215 | if(list==null||list.size()<=0) { | ... | ... |
... | @@ -4,6 +4,7 @@ import java.io.Serializable; | ... | @@ -4,6 +4,7 @@ import java.io.Serializable; |
4 | import java.time.LocalDateTime; | 4 | import java.time.LocalDateTime; |
5 | import java.util.Date; | 5 | import java.util.Date; |
6 | 6 | ||
7 | import com.skua.core.aspect.annotation.Dict; | ||
7 | import org.jeecgframework.poi.excel.annotation.Excel; | 8 | import org.jeecgframework.poi.excel.annotation.Excel; |
8 | import org.springframework.format.annotation.DateTimeFormat; | 9 | import org.springframework.format.annotation.DateTimeFormat; |
9 | 10 | ||
... | @@ -44,6 +45,13 @@ public class SysRole implements Serializable { | ... | @@ -44,6 +45,13 @@ public class SysRole implements Serializable { |
44 | private String roleCode; | 45 | private String roleCode; |
45 | 46 | ||
46 | /** | 47 | /** |
48 | * 角色编码 | ||
49 | */ | ||
50 | @Excel(name="角色类型",width=15) | ||
51 | @Dict(dicCode = "role_type") | ||
52 | private String roleType; | ||
53 | |||
54 | /** | ||
47 | * 所属机构 | 55 | * 所属机构 |
48 | */ | 56 | */ |
49 | /*@Excel(name="所属机构",width=15)*/ | 57 | /*@Excel(name="所属机构",width=15)*/ | ... | ... |
... | @@ -34,10 +34,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> { | ... | @@ -34,10 +34,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> { |
34 | * | 34 | * |
35 | * @param | 35 | * @param |
36 | * @param page | 36 | * @param page |
37 | * @param orgCode | 37 | * @param roleId |
38 | * @return | 38 | * @return |
39 | */ | 39 | */ |
40 | IPage<SysUser> getUserByRoleId(Page page,@Param("roleId") String roleId, @Param("username") String username); | 40 | IPage<SysUser> getUserByRoleId(Page page,@Param("roleId") String roleId, |
41 | @Param("username") String username,@Param("departId") String departId); | ||
41 | 42 | ||
42 | /** | 43 | /** |
43 | * 根据用户名设置部门ID | 44 | * 根据用户名设置部门ID |
... | @@ -74,4 +75,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> { | ... | @@ -74,4 +75,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> { |
74 | List<SysUser> getUserByUserIds(@Param("userIds") String userIds); | 75 | List<SysUser> getUserByUserIds(@Param("userIds") String userIds); |
75 | 76 | ||
76 | List<SysUser> operationUserList(@Param("departId") String departId); | 77 | List<SysUser> operationUserList(@Param("departId") String departId); |
78 | |||
79 | String queryDepartIdsByUserId(@Param("userId") String userId); | ||
77 | } | 80 | } | ... | ... |
... | @@ -17,13 +17,35 @@ | ... | @@ -17,13 +17,35 @@ |
17 | 17 | ||
18 | <!-- 根据角色Id查询 --> | 18 | <!-- 根据角色Id查询 --> |
19 | <select id="getUserByRoleId" resultType="com.skua.modules.system.entity.SysUser"> | 19 | <select id="getUserByRoleId" resultType="com.skua.modules.system.entity.SysUser"> |
20 | select * from sys_user where del_flag = '0' and is_system_user = '0' | 20 | SELECT |
21 | and id in (select user_id from sys_user_role where role_id=#{roleId}) | 21 | u.* |
22 | FROM | ||
23 | sys_user u | ||
24 | LEFT JOIN sys_user_depart d ON u.id = d.user_id | ||
25 | WHERE | ||
26 | u.del_flag = '0' | ||
27 | AND u.is_system_user = '0' | ||
28 | AND u.id IN ( SELECT user_id FROM sys_user_role WHERE role_id = #{roleId} ) | ||
22 | <if test="username!=null and username!=''"> | 29 | <if test="username!=null and username!=''"> |
23 | and (username like concat('%',#{username},'%') or realname like concat('%',#{username},'%')) | 30 | AND (u.username LIKE CONCAT('%',#{username},'%') or u.realname LIKE CONCAT('%',#{username},'%')) |
31 | </if> | ||
32 | <if test="departId!=null and departId!=''"> | ||
33 | AND d.dep_id IN | ||
34 | <foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")"> | ||
35 | #{item} | ||
36 | </foreach> | ||
24 | </if> | 37 | </if> |
25 | </select> | 38 | </select> |
26 | 39 | ||
40 | <select id="queryDepartIdsByUserId" resultType="java.lang.String"> | ||
41 | SELECT | ||
42 | CONCAT( dep_id, ',', dep_ids ) AS departs | ||
43 | FROM | ||
44 | sys_user_depart | ||
45 | WHERE | ||
46 | user_id = #{userId} | ||
47 | </select> | ||
48 | |||
27 | <!-- 修改用户部门code --> | 49 | <!-- 修改用户部门code --> |
28 | <update id="updateUserDepart"> | 50 | <update id="updateUserDepart"> |
29 | UPDATE sys_user SET org_code = #{orgCode} where username = #{username} | 51 | UPDATE sys_user SET org_code = #{orgCode} where username = #{username} | ... | ... |
... | @@ -114,6 +114,7 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S | ... | @@ -114,6 +114,7 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | |||
117 | @Override | 118 | @Override |
118 | public List<String> queryDepartIdsOfUserId(String userId) { | 119 | public List<String> queryDepartIdsOfUserId(String userId) { |
119 | List<String> departByUserId = baseMapper.getDepartByUserId(userId); | 120 | List<String> departByUserId = baseMapper.getDepartByUserId(userId); | ... | ... |
... | @@ -14,6 +14,7 @@ import com.skua.core.context.BaseContextHandler; | ... | @@ -14,6 +14,7 @@ import com.skua.core.context.BaseContextHandler; |
14 | import com.skua.core.util.ConvertUtils; | 14 | import com.skua.core.util.ConvertUtils; |
15 | import com.skua.modules.system.entity.*; | 15 | import com.skua.modules.system.entity.*; |
16 | import com.skua.modules.system.mapper.*; | 16 | import com.skua.modules.system.mapper.*; |
17 | import com.skua.modules.system.service.ISysUserDepartService; | ||
17 | import com.skua.modules.system.service.ISysUserService; | 18 | import com.skua.modules.system.service.ISysUserService; |
18 | import com.skua.modules.system.vo.SysUserVO; | 19 | import com.skua.modules.system.vo.SysUserVO; |
19 | import com.skua.modules.websocket.WebSocket; | 20 | import com.skua.modules.websocket.WebSocket; |
... | @@ -24,6 +25,7 @@ import org.springframework.cache.annotation.Cacheable; | ... | @@ -24,6 +25,7 @@ import org.springframework.cache.annotation.Cacheable; |
24 | import org.springframework.stereotype.Service; | 25 | import org.springframework.stereotype.Service; |
25 | import org.springframework.transaction.annotation.Transactional; | 26 | import org.springframework.transaction.annotation.Transactional; |
26 | 27 | ||
28 | import javax.annotation.Resource; | ||
27 | import java.util.*; | 29 | import java.util.*; |
28 | import java.util.stream.Collectors; | 30 | import java.util.stream.Collectors; |
29 | 31 | ||
... | @@ -136,8 +138,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl | ... | @@ -136,8 +138,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
136 | // SysUser user = userMapper.getUserByName(username); | 138 | // SysUser user = userMapper.getUserByName(username); |
137 | // info.setSysUserCode(user.getUsername()); | 139 | // info.setSysUserCode(user.getUsername()); |
138 | // info.setSysUserName(user.getRealname()); | 140 | // info.setSysUserName(user.getRealname()); |
139 | |||
140 | |||
141 | LoginUser user = sysBaseAPI.getUserByName(username); | 141 | LoginUser user = sysBaseAPI.getUserByName(username); |
142 | if (user != null) { | 142 | if (user != null) { |
143 | info.setSysUserCode(user.getUsername()); | 143 | info.setSysUserCode(user.getUsername()); |
... | @@ -170,11 +170,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl | ... | @@ -170,11 +170,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
170 | return userMapper.getUserByDepId(page, departId, username); | 170 | return userMapper.getUserByDepId(page, departId, username); |
171 | } | 171 | } |
172 | 172 | ||
173 | |||
174 | // 根据角色Id查询 | 173 | // 根据角色Id查询 |
175 | @Override | 174 | @Override |
176 | public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) { | 175 | public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) { |
177 | return userMapper.getUserByRoleId(page, roleId, username); | 176 | String departIds = userMapper.queryDepartIdsByUserId(BaseContextHandler.getUserId()); |
177 | return userMapper.getUserByRoleId(page, roleId, username, departIds); | ||
178 | } | 178 | } |
179 | 179 | ||
180 | //获取登录人所属集团 | 180 | //获取登录人所属集团 | ... | ... |
-
请 注册 或 登录 后发表评论