zelong.shao

manager|用户信息&&角色权限

Showing 29 changed files with 328 additions and 167 deletions
1 package com.fedex.connect.common.dependencies.enums.sys; 1 package com.fedex.connect.common.dependencies.enums.sys;
2 2
3 public enum RoleEnum { 3 public enum RoleEnum {
4 - SYSTEM(0L,"System","系统"), 4 + SYSTEM("system","System","系统"),
5 - CUSOTMER(1L,"Cusotmer","用户"), 5 + CUSOTMER("customer","Customer","用户"),
6 6
7 ; 7 ;
8 8
9 9
10 - private Long code; 10 + private String code;
11 private String enMsg; 11 private String enMsg;
12 private String msg; 12 private String msg;
13 13
14 - RoleEnum(Long code, String enMsg,String msg) { 14 + RoleEnum(String code, String enMsg,String msg) {
15 this.code = code; 15 this.code = code;
16 this.enMsg = enMsg; 16 this.enMsg = enMsg;
17 this.msg = msg; 17 this.msg = msg;
18 } 18 }
19 19
20 - public Long getCode() { 20 + public String getCode() {
21 return code; 21 return code;
22 } 22 }
23 23
24 - public void setCode(Long code) { 24 + public void setCode(String code) {
25 this.code = code; 25 this.code = code;
26 } 26 }
27 27
......
1 package com.fedex.connect.common.dependencies.enums.sys; 1 package com.fedex.connect.common.dependencies.enums.sys;
2 2
3 public enum UserTypeEnum { 3 public enum UserTypeEnum {
4 - LOCAL(0L,"LOCAL","本地账号"), 4 + LOCAL("userType_01","LOCAL","本地账号"),
5 - FCL(1L,"FCL","FCL账号"); 5 + FCL("userType_02","FCL","FCL账号");
6 6
7 - private Long code; 7 + private String code;
8 private String enMsg; 8 private String enMsg;
9 private String msg; 9 private String msg;
10 10
11 - UserTypeEnum(Long code, String enMsg,String msg) { 11 + UserTypeEnum(String code, String enMsg,String msg) {
12 this.code = code; 12 this.code = code;
13 this.enMsg = enMsg; 13 this.enMsg = enMsg;
14 this.msg = msg; 14 this.msg = msg;
15 } 15 }
16 16
17 - public Long getCode() { 17 + public String getCode() {
18 return code; 18 return code;
19 } 19 }
20 20
21 - public void setCode(Long code) { 21 + public void setCode(String code) {
22 this.code = code; 22 this.code = code;
23 } 23 }
24 24
......
...@@ -8,6 +8,7 @@ import com.fedex.connect.common.model.sys.User; ...@@ -8,6 +8,7 @@ import com.fedex.connect.common.model.sys.User;
8 import com.fedex.connect.manager.config.PropertiesConfig; 8 import com.fedex.connect.manager.config.PropertiesConfig;
9 import com.fedex.connect.manager.service.bi.IDicEntriesService; 9 import com.fedex.connect.manager.service.bi.IDicEntriesService;
10 import com.fedex.connect.manager.service.log.ILogLoginService; 10 import com.fedex.connect.manager.service.log.ILogLoginService;
11 +import com.fedex.connect.manager.service.sys.IPrivilegeService;
11 import com.fedex.connect.manager.service.sys.ISysAuthService; 12 import com.fedex.connect.manager.service.sys.ISysAuthService;
12 import com.fedex.connect.manager.service.sys.ISysUserService; 13 import com.fedex.connect.manager.service.sys.ISysUserService;
13 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
...@@ -32,6 +33,8 @@ public class BaseController extends BasicController { ...@@ -32,6 +33,8 @@ public class BaseController extends BasicController {
32 protected ILogLoginService logLoginService; 33 protected ILogLoginService logLoginService;
33 @Autowired 34 @Autowired
34 protected IDicEntriesService dicEntriesService; 35 protected IDicEntriesService dicEntriesService;
36 + @Autowired
37 + protected IPrivilegeService privilegeService;
35 38
36 public User getCurrentUserInfo(){ 39 public User getCurrentUserInfo(){
37 User user = this.getUserInfo(localeMessageUtil); 40 User user = this.getUserInfo(localeMessageUtil);
......
1 +package com.fedex.connect.manager.controller.sys;
2 +
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 +import org.springframework.web.bind.annotation.PathVariable;
5 +
6 +public interface ISysPrivilegeController {
7 + ResponseVo getPrivilege(@PathVariable Long userId);
8 +}
1 +package com.fedex.connect.manager.controller.sys;
2 +
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 +
5 +public interface ISysUserController {
6 + ResponseVo getUser();
7 +}
...@@ -38,7 +38,7 @@ import java.util.*; ...@@ -38,7 +38,7 @@ import java.util.*;
38 @Slf4j 38 @Slf4j
39 @RestController 39 @RestController
40 @RequestMapping(value = "/auth", name = "权鉴操作相关请求") 40 @RequestMapping(value = "/auth", name = "权鉴操作相关请求")
41 -@Api(value="SysAuthController",tags={"用户相关请求(无需token)"}) 41 +@Api(value="SysAuthController",tags={"登陆相关请求(无需token)"})
42 public class SysAuthController extends BaseController implements ISysAuthController { 42 public class SysAuthController extends BaseController implements ISysAuthController {
43 43
44 @Autowired 44 @Autowired
......
1 +package com.fedex.connect.manager.controller.sys.impl;
2 +
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 +import com.fedex.connect.manager.controller.base.BaseController;
5 +import com.fedex.connect.manager.controller.sys.ISysPrivilegeController;
6 +import io.swagger.annotations.Api;
7 +import io.swagger.annotations.ApiOperation;
8 +import lombok.extern.slf4j.Slf4j;
9 +import org.springframework.web.bind.annotation.GetMapping;
10 +import org.springframework.web.bind.annotation.PathVariable;
11 +import org.springframework.web.bind.annotation.RequestMapping;
12 +import org.springframework.web.bind.annotation.RestController;
13 +
14 +@Slf4j
15 +@RestController
16 +@RequestMapping(value = "/privilege", name = "权限相关请求")
17 +@Api(value="SysPrivilegeController",tags={"权限相关请求"})
18 +public class SysPrivilegeController extends BaseController implements ISysPrivilegeController {
19 +
20 + @Override
21 + @GetMapping(value = {"/{userId}"})
22 + @ApiOperation(value = "根据用户ID获取菜单")
23 + public ResponseVo getPrivilege(@PathVariable Long userId){
24 + return privilegeService.getPrivilegeByUserId(userId);
25 + }
26 +}
1 +package com.fedex.connect.manager.controller.sys.impl;
2 +
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 +import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
5 +import com.fedex.connect.common.model.sys.User;
6 +import com.fedex.connect.manager.controller.base.BaseController;
7 +import com.fedex.connect.manager.controller.sys.ISysUserController;
8 +import com.fedex.connect.manager.enums.ResponseCode;
9 +import io.swagger.annotations.Api;
10 +import io.swagger.annotations.ApiOperation;
11 +import lombok.extern.slf4j.Slf4j;
12 +import org.springframework.web.bind.annotation.GetMapping;
13 +import org.springframework.web.bind.annotation.RequestMapping;
14 +import org.springframework.web.bind.annotation.RestController;
15 +
16 +@Slf4j
17 +@RestController
18 +@RequestMapping(value = "/user", name = "用户相关请求")
19 +@Api(value="SysUserController",tags={"用户相关请求(无需token)"})
20 +public class SysUserController extends BaseController implements ISysUserController {
21 +
22 + @Override
23 + @GetMapping("/getUser")
24 + @ApiOperation(value = "登录界面查询用户,可不要token")
25 + public ResponseVo getUser(){
26 + ResponseVo success = responseUtils.success();
27 + try{
28 + User sysUser = CurrentUserInfo.getUser();
29 + if (sysUser == null){
30 + responseUtils.fail(ResponseCode.MESSAGE_CODE_40004);
31 + }
32 +
33 + if (sysUser.getId() == null || sysUser.getId() == 0){
34 + responseUtils.fail(ResponseCode.MESSAGE_CODE_40005);
35 + }
36 + //返回用户信息
37 + return responseUtils.success(sysUser);
38 + } catch (Exception e){
39 + log.error("获取用户信息失败",e);
40 + responseUtils.fail(ResponseCode.MESSAGE_CODE_40006);
41 + }
42 + return success;
43 + }
44 +}
...@@ -6,6 +6,7 @@ import com.fedex.connect.common.dependencies.enums.sys.UserTypeEnum; ...@@ -6,6 +6,7 @@ import com.fedex.connect.common.dependencies.enums.sys.UserTypeEnum;
6 import com.fedex.connect.common.dependencies.util.Utils; 6 import com.fedex.connect.common.dependencies.util.Utils;
7 import com.fedex.connect.common.model.sys.User; 7 import com.fedex.connect.common.model.sys.User;
8 import io.swagger.annotations.ApiModel; 8 import io.swagger.annotations.ApiModel;
9 +import lombok.Data;
9 import org.apache.commons.lang3.StringUtils; 10 import org.apache.commons.lang3.StringUtils;
10 11
11 import java.util.Date; 12 import java.util.Date;
...@@ -14,6 +15,7 @@ import java.util.Date; ...@@ -14,6 +15,7 @@ import java.util.Date;
14 * 用户相关DTO 15 * 用户相关DTO
15 */ 16 */
16 @ApiModel(value = "用户相关DTO") 17 @ApiModel(value = "用户相关DTO")
18 +@Data
17 public class SysUserDto { 19 public class SysUserDto {
18 20
19 /** 21 /**
...@@ -42,6 +44,8 @@ public class SysUserDto { ...@@ -42,6 +44,8 @@ public class SysUserDto {
42 user.setStatus(DatabaseConstants.GLOBAL_STATUS_VALID); 44 user.setStatus(DatabaseConstants.GLOBAL_STATUS_VALID);
43 user.setRemark(dto.getRemark()); 45 user.setRemark(dto.getRemark());
44 user.setTypeCode(dto.getTypeCode()); 46 user.setTypeCode(dto.getTypeCode());
47 + user.setUserUuid(dto.getUserUuid());
48 + user.setTypeName(dto.getTypeName());
45 return user; 49 return user;
46 } 50 }
47 51
...@@ -55,7 +59,8 @@ public class SysUserDto { ...@@ -55,7 +59,8 @@ public class SysUserDto {
55 } else { 59 } else {
56 this.userName = fcl_acc_no; 60 this.userName = fcl_acc_no;
57 } 61 }
58 - this.typeCode = UserTypeEnum.FCL.getEnMsg(); 62 + this.typeCode = UserTypeEnum.FCL.getCode();
63 + this.typeName = UserTypeEnum.FCL.getMsg();
59 this.password = fcl_pwd; 64 this.password = fcl_pwd;
60 this.loginName = uuid; 65 this.loginName = uuid;
61 this.email = null; 66 this.email = null;
...@@ -63,6 +68,7 @@ public class SysUserDto { ...@@ -63,6 +68,7 @@ public class SysUserDto {
63 this.companyName = null; 68 this.companyName = null;
64 this.unifiedBusinessNum = null; 69 this.unifiedBusinessNum = null;
65 this.customsSerialNum = null; 70 this.customsSerialNum = null;
71 + this.userUuid = uuid;
66 } 72 }
67 73
68 /** 74 /**
...@@ -70,6 +76,10 @@ public class SysUserDto { ...@@ -70,6 +76,10 @@ public class SysUserDto {
70 */ 76 */
71 private Long id; 77 private Long id;
72 78
79 + private String typeName;
80 +
81 + private String userUuid;
82 +
73 /** 83 /**
74 * 用户账号 84 * 用户账号
75 */ 85 */
...@@ -157,147 +167,5 @@ public class SysUserDto { ...@@ -157,147 +167,5 @@ public class SysUserDto {
157 @JsonIgnore 167 @JsonIgnore
158 private String remark; 168 private String remark;
159 169
160 - public Long getId() {
161 - return id;
162 - }
163 -
164 - public void setId(Long id) {
165 - this.id = id;
166 - }
167 -
168 - public String getLoginName() {
169 - return loginName;
170 - }
171 -
172 - public void setLoginName(String loginName) {
173 - this.loginName = loginName;
174 - }
175 -
176 - public String getUserName() {
177 - return userName;
178 - }
179 -
180 - public void setUserName(String userName) {
181 - this.userName = userName;
182 - }
183 -
184 - public String getPassword() {
185 - return password;
186 - }
187 -
188 - public void setPassword(String password) {
189 - this.password = password;
190 - }
191 -
192 - public String getPassword2() {
193 - return password2;
194 - }
195 -
196 - public void setPassword2(String password2) {
197 - this.password2 = password2;
198 - }
199 -
200 - public String getAccountNo() {
201 - return accountNo;
202 - }
203 -
204 - public void setAccountNo(String accountNo) {
205 - this.accountNo = accountNo;
206 - }
207 -
208 - public String getFedexAccNo2() {
209 - return fedexAccNo2;
210 - }
211 -
212 - public void setFedexAccNo2(String fedexAccNo2) {
213 - this.fedexAccNo2 = fedexAccNo2;
214 - }
215 -
216 - public String getEmail() {
217 - return email;
218 - }
219 -
220 - public void setEmail(String email) {
221 - this.email = email;
222 - }
223 -
224 - public String getPhone() {
225 - return phone;
226 - }
227 -
228 - public void setPhone(String phone) {
229 - this.phone = phone;
230 - }
231 -
232 - public String getCompanyName() {
233 - return companyName;
234 - }
235 -
236 - public void setCompanyName(String companyName) {
237 - this.companyName = companyName;
238 - }
239 -
240 - public String getUnifiedBusinessNum() {
241 - return unifiedBusinessNum;
242 - }
243 -
244 - public void setUnifiedBusinessNum(String unifiedBusinessNum) {
245 - this.unifiedBusinessNum = unifiedBusinessNum;
246 - }
247 -
248 - public String getCustomsSerialNum() {
249 - return customsSerialNum;
250 - }
251 -
252 - public void setCustomsSerialNum(String customsSerialNum) {
253 - this.customsSerialNum = customsSerialNum;
254 - }
255 -
256 - public Long getTypeId() {
257 - return typeId;
258 - }
259 -
260 - public void setTypeId(Long typeId) {
261 - this.typeId = typeId;
262 - }
263 -
264 - public String getTypeCode() {
265 - return typeCode;
266 - }
267 -
268 - public void setTypeCode(String typeCode) {
269 - this.typeCode = typeCode;
270 - }
271 -
272 - public Long getStatus() {
273 - return status;
274 - }
275 -
276 - public void setStatus(Long status) {
277 - this.status = status;
278 - }
279 -
280 - public boolean isPolicyFlag() {
281 - return policyFlag;
282 - }
283 170
284 - public void setPolicyFlag(boolean policyFlag) {
285 - this.policyFlag = policyFlag;
286 - }
287 -
288 - public boolean isClauseFlag() {
289 - return clauseFlag;
290 - }
291 -
292 - public void setClauseFlag(boolean clauseFlag) {
293 - this.clauseFlag = clauseFlag;
294 - }
295 -
296 - public String getRemark() {
297 - return remark;
298 - }
299 -
300 - public void setRemark(String remark) {
301 - this.remark = remark;
302 - }
303 } 171 }
......
...@@ -10,12 +10,9 @@ public enum ResponseCode { ...@@ -10,12 +10,9 @@ public enum ResponseCode {
10 MESSAGE_CODE_40001(40001,"business_exception_40001"), 10 MESSAGE_CODE_40001(40001,"business_exception_40001"),
11 MESSAGE_CODE_40002(40002,"business_log_40002"), 11 MESSAGE_CODE_40002(40002,"business_log_40002"),
12 MESSAGE_CODE_40003(40003,"system_exception_40003"), 12 MESSAGE_CODE_40003(40003,"system_exception_40003"),
13 - /******打个样,编写样例*****/ 13 + MESSAGE_CODE_40004(40004,"system_exception_40004"),
14 -// MESSAGE_CODE_40001(40001,"business_exception_40001"), 14 + MESSAGE_CODE_40005(40005,"system_exception_40005"),
15 -// MESSAGE_CODE_40002(40002,"business_success_40002"), 15 + MESSAGE_CODE_40006(40006,"system_exception_40006"),
16 -// MESSAGE_CODE_40003(40003,"system_exception_40003"),
17 -// MESSAGE_CODE_40004(40004,"system_success_40004"),
18 -// MESSAGE_CODE_40005(40005,"business_log_40005"),
19 ; 16 ;
20 private Integer code; 17 private Integer code;
21 private String msg; 18 private String msg;
......
...@@ -7,6 +7,9 @@ import com.fedex.connect.common.dao.sys.RoleMapper; ...@@ -7,6 +7,9 @@ import com.fedex.connect.common.dao.sys.RoleMapper;
7 import com.fedex.connect.common.dao.sys.UserMapper; 7 import com.fedex.connect.common.dao.sys.UserMapper;
8 import com.fedex.connect.common.dao.sys.UserRoleMapper; 8 import com.fedex.connect.common.dao.sys.UserRoleMapper;
9 import com.fedex.connect.manager.repository.dao.ParamConfigExtMapper; 9 import com.fedex.connect.manager.repository.dao.ParamConfigExtMapper;
10 +import com.fedex.connect.manager.repository.dao.PrivilegeExtMapper;
11 +import com.fedex.connect.manager.repository.dao.RoleExtMapper;
12 +import com.fedex.connect.manager.repository.dao.RolePrivilegeExtMapper;
10 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
11 14
12 public class BaseDao { 15 public class BaseDao {
...@@ -24,4 +27,10 @@ public class BaseDao { ...@@ -24,4 +27,10 @@ public class BaseDao {
24 public DictionaryEntriesMapper dictionaryEntriesMapper; 27 public DictionaryEntriesMapper dictionaryEntriesMapper;
25 @Autowired 28 @Autowired
26 public ParamConfigExtMapper paramConfigExtMapper; 29 public ParamConfigExtMapper paramConfigExtMapper;
30 + @Autowired
31 + public RolePrivilegeExtMapper rolePrivilegeExtMapper;
32 + @Autowired
33 + public RoleExtMapper roleExtMapper;
34 + @Autowired
35 + public PrivilegeExtMapper privilegeExtMapper;
27 } 36 }
......
1 +package com.fedex.connect.manager.repository.dao;
2 +
3 +import com.fedex.connect.common.model.sys.Privilege;
4 +import org.apache.ibatis.annotations.Mapper;
5 +import org.apache.ibatis.annotations.Param;
6 +import org.apache.ibatis.annotations.Select;
7 +
8 +import java.util.List;
9 +
10 +@Mapper
11 +public interface PrivilegeExtMapper {
12 + @Select({
13 + "<script>",
14 + "SELECT * FROM T_SYS_PRIVILEGE",
15 + "WHERE ID IN",
16 + "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
17 + "#{id}",
18 + "</foreach>",
19 + "</script>"
20 + })
21 + List<Privilege> findPrivilegesByIds(@Param("ids") List<Long> ids);
22 +
23 +}
1 +package com.fedex.connect.manager.repository.dao;
2 +
3 +import com.fedex.connect.common.model.sys.Role;
4 +import org.apache.ibatis.annotations.Mapper;
5 +import org.apache.ibatis.annotations.Param;
6 +import org.apache.ibatis.annotations.Select;
7 +
8 +import java.util.List;
9 +
10 +@Mapper
11 +public interface RoleExtMapper {
12 + @Select({
13 + "<script>",
14 + "SELECT * FROM T_SYS_ROLE",
15 + "WHERE ID IN",
16 + "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
17 + "#{id}",
18 + "</foreach>",
19 + "</script>"
20 + })
21 + List<Role> findRolesByIds(@Param("ids") List<Long> ids);
22 +
23 +}
1 +package com.fedex.connect.manager.repository.dao;
2 +
3 +import org.apache.ibatis.annotations.Mapper;
4 +import org.apache.ibatis.annotations.Param;
5 +import org.apache.ibatis.annotations.Select;
6 +
7 +import java.util.List;
8 +
9 +@Mapper
10 +public interface RolePrivilegeExtMapper {
11 + @Select({
12 + "<script>",
13 + "SELECT DISTINCT PRIV_ID FROM T_SYS_ROLE_PRIVILEGE",
14 + "WHERE ROLE_ID IN",
15 + "<foreach collection='roleIds' item='roleId' open='(' separator=',' close=')'>",
16 + "#{roleId}",
17 + "</foreach>",
18 + "</script>"
19 + })
20 + List<Long> findByRoleIds(@Param("roleIds") List<Long> roleIds);
21 +}
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 +<mapper namespace="com.fedex.connect.manager.repository.dao.PrivilegeExtMapper">
4 +
5 +</mapper>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 +<mapper namespace="com.fedex.connect.manager.repository.dao.RoleExtMapper">
4 +
5 +</mapper>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 +<mapper namespace="com.fedex.connect.manager.repository.dao.RolePrivilegeExtMapper">
4 +
5 +</mapper>
...\ No newline at end of file ...\ No newline at end of file
1 +package com.fedex.connect.manager.repository.repo.sys;
2 +
3 +import com.fedex.connect.common.model.sys.Privilege;
4 +
5 +import java.util.List;
6 +
7 +public interface IPrivilegeRepository {
8 + List<Privilege> findPrivilegesByIds(List<Long> ids);
9 +}
1 +package com.fedex.connect.manager.repository.repo.sys;
2 +
3 +import java.util.List;
4 +
5 +public interface IRolePrivilegeRepository {
6 + List<Long> findByRoleIds(List<Long> roleIds);
7 +}
...@@ -11,4 +11,6 @@ public interface IRoleRepository { ...@@ -11,4 +11,6 @@ public interface IRoleRepository {
11 Role selectByPrimaryKey(Long id); 11 Role selectByPrimaryKey(Long id);
12 12
13 int insert(Role record); 13 int insert(Role record);
14 +
15 + List<Role> selectByIds(List<Long> ids);
14 } 16 }
......
1 +package com.fedex.connect.manager.repository.repo.sys.impl;
2 +
3 +import com.fedex.connect.common.model.sys.Privilege;
4 +import com.fedex.connect.manager.repository.base.BaseDao;
5 +import com.fedex.connect.manager.repository.repo.sys.IPrivilegeRepository;
6 +import org.springframework.stereotype.Repository;
7 +
8 +import java.util.List;
9 +
10 +@Repository
11 +public class PrivilegeRepositoryImpl extends BaseDao implements IPrivilegeRepository {
12 +
13 + @Override
14 + public List<Privilege> findPrivilegesByIds(List<Long> ids) {
15 + return privilegeExtMapper.findPrivilegesByIds(ids);
16 + }
17 +}
1 +package com.fedex.connect.manager.repository.repo.sys.impl;
2 +
3 +import com.fedex.connect.manager.repository.base.BaseDao;
4 +import com.fedex.connect.manager.repository.repo.sys.IRolePrivilegeRepository;
5 +import org.apache.ibatis.annotations.Param;
6 +import org.springframework.stereotype.Repository;
7 +
8 +import java.util.List;
9 +
10 +@Repository
11 +public class RolePrivilegeRepositoryImpl extends BaseDao implements IRolePrivilegeRepository {
12 + public List<Long> findByRoleIds(@Param("roleIds") List<Long> roleIds){
13 + return rolePrivilegeExtMapper.findByRoleIds(roleIds);
14 + }
15 +}
...@@ -25,4 +25,9 @@ public class RoleRepositoryImpl extends BaseDao implements IRoleRepository { ...@@ -25,4 +25,9 @@ public class RoleRepositoryImpl extends BaseDao implements IRoleRepository {
25 public int insert(Role record) { 25 public int insert(Role record) {
26 return roleMapper.insert(record); 26 return roleMapper.insert(record);
27 } 27 }
28 +
29 + @Override
30 + public List<Role> selectByIds(List<Long> ids) {
31 + return roleExtMapper.findRolesByIds(ids);
32 + }
28 } 33 }
......
...@@ -5,10 +5,7 @@ import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; ...@@ -5,10 +5,7 @@ import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
5 import com.fedex.connect.common.dependencies.util.ResponseUtils; 5 import com.fedex.connect.common.dependencies.util.ResponseUtils;
6 import com.fedex.connect.manager.repository.repo.bi.IDicEntriesRepository; 6 import com.fedex.connect.manager.repository.repo.bi.IDicEntriesRepository;
7 import com.fedex.connect.manager.repository.repo.log.IUserLoginLogRepository; 7 import com.fedex.connect.manager.repository.repo.log.IUserLoginLogRepository;
8 -import com.fedex.connect.manager.repository.repo.sys.IRedisSlabRepository; 8 +import com.fedex.connect.manager.repository.repo.sys.*;
9 -import com.fedex.connect.manager.repository.repo.sys.IRoleRepository;
10 -import com.fedex.connect.manager.repository.repo.sys.IUserRepository;
11 -import com.fedex.connect.manager.repository.repo.sys.IUserRoleRepository;
12 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
13 10
14 import javax.annotation.Resource; 11 import javax.annotation.Resource;
...@@ -36,4 +33,8 @@ public class BaseService { ...@@ -36,4 +33,8 @@ public class BaseService {
36 public IUserRepository userRepository; 33 public IUserRepository userRepository;
37 @Autowired 34 @Autowired
38 public IDicEntriesRepository dicEntriesRepository; 35 public IDicEntriesRepository dicEntriesRepository;
36 + @Autowired
37 + public IRolePrivilegeRepository rolePrivilegeRepository;
38 + @Autowired
39 + public IPrivilegeRepository privilegeRepository;
39 } 40 }
......
1 +package com.fedex.connect.manager.service.sys;
2 +
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 +
5 +public interface IPrivilegeService {
6 + ResponseVo getPrivilegeByUserId(Long id);
7 +}
1 +package com.fedex.connect.manager.service.sys.impl;
2 +
3 +import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
4 +import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
5 +import com.fedex.connect.common.model.sys.Privilege;
6 +import com.fedex.connect.common.model.sys.UserRole;
7 +import com.fedex.connect.common.model.sys.UserRoleExample;
8 +import com.fedex.connect.manager.service.base.BaseService;
9 +import com.fedex.connect.manager.service.sys.IPrivilegeService;
10 +import lombok.extern.slf4j.Slf4j;
11 +import org.springframework.stereotype.Service;
12 +import org.springframework.util.CollectionUtils;
13 +
14 +import java.util.List;
15 +import java.util.stream.Collectors;
16 +
17 +@Service
18 +@Slf4j
19 +public class PrivilegeServiceImpl extends BaseService implements IPrivilegeService {
20 +
21 + public ResponseVo getPrivilegeByUserId(Long id){
22 + /**
23 + * 获取到该用户的角色
24 + */
25 + UserRoleExample example = new UserRoleExample();
26 + UserRoleExample.Criteria criteria = example.createCriteria();
27 + criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID);
28 + criteria.andUserIdEqualTo(id);
29 + List<UserRole> userRoles = userRoleRepository.selectByExample(example);
30 + /**
31 + * 根据角色获取菜单权限
32 + */
33 + if (!CollectionUtils.isEmpty(userRoles)){
34 + List<Long> roleIds = userRoles.stream()
35 + .map(UserRole::getRoleId) // 假设 UserRole 有 getRoleId 方法
36 + .distinct() // 去重
37 + .collect(Collectors.toList());
38 + List<Long> byRoleIds = rolePrivilegeRepository.findByRoleIds(roleIds);
39 + /**
40 + * 获取权限
41 + */
42 + List<Privilege> privilegesByIds = privilegeRepository.findPrivilegesByIds(byRoleIds);
43 + return responseUtils.success(privilegesByIds);
44 + }
45 +
46 + return new ResponseVo();
47 + }
48 +}
...@@ -116,7 +116,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService { ...@@ -116,7 +116,7 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
116 116
117 //当前阶段,权限采用默认权限 117 //当前阶段,权限采用默认权限
118 if (saveUserCt > 0){ 118 if (saveUserCt > 0){
119 - Role roleInfo = sysRoleService.findRoleByCode(RoleEnum.CUSOTMER.getEnMsg()); 119 + Role roleInfo = sysRoleService.findRoleByCode(RoleEnum.CUSOTMER.getCode());
120 //创建用户角色对应关系 120 //创建用户角色对应关系
121 sysUserRoleService.save(user.getId(), roleInfo.getId()); 121 sysUserRoleService.save(user.getId(), roleInfo.getId());
122 } 122 }
......
...@@ -12,3 +12,6 @@ system_exception_10007=登录已过期,请重新登录 ...@@ -12,3 +12,6 @@ system_exception_10007=登录已过期,请重新登录
12 business_exception_40001=存入token失败 12 business_exception_40001=存入token失败
13 business_log_40002=用户登录 13 business_log_40002=用户登录
14 system_exception_40003=系统异常,请联系清关部门 14 system_exception_40003=系统异常,请联系清关部门
15 +system_exception_40004=登录已过期,请重新登录
16 +system_exception_40005=用戶不存在
17 +system_exception_40006=登录已过期
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -12,3 +12,6 @@ system_exception_10007=登录已过期,请重新登录 ...@@ -12,3 +12,6 @@ system_exception_10007=登录已过期,请重新登录
12 business_exception_40001=存入token失败 12 business_exception_40001=存入token失败
13 business_log_40002=用户登录 13 business_log_40002=用户登录
14 system_exception_40003=系统异常,请联系清关部门 14 system_exception_40003=系统异常,请联系清关部门
15 +system_exception_40004=登录已过期,请重新登录
16 +system_exception_40005=用戶不存在
17 +system_exception_40006=登录已过期
...\ No newline at end of file ...\ No newline at end of file
......