@author Hellohao @version 1.0 @date 2019/8/20 14:10
| 20 | * @date 2019/8/20 14:10 |
| 21 | */ |
| 22 | @Component |
| 23 | public class GetCurrentSource { |
| 24 | @Autowired |
| 25 | private GroupServiceImpl groupServiceImpl; |
| 26 | @Autowired |
| 27 | private UserGroupServiceImpl userGroupServiceImpl; |
| 28 | @Autowired |
| 29 | private UserServiceImpl userServiceImpl; |
| 30 | |
| 31 | private static GroupServiceImpl groupService; |
| 32 | private static UserGroupServiceImpl userGroupService; |
| 33 | private static UserServiceImpl userService; |
| 34 | |
| 35 | @PostConstruct |
| 36 | public void init() { |
| 37 | groupService =groupServiceImpl; |
| 38 | userGroupService = userGroupServiceImpl; |
| 39 | userService = userServiceImpl; |
| 40 | } |
| 41 | |
| 42 | public static Group GetSource(Integer userid) { |
| 43 | //UserType 0-未分配 1-游客 2-用户 3-管理员 |
| 44 | User user =null; |
| 45 | if(userid!=null){ |
| 46 | User u = new User(); |
| 47 | u.setId(userid); |
| 48 | user = userService.getUsers(u); |
| 49 | } |
| 50 | Group group =null; |
| 51 | if(user==null){ |
| 52 | //游客 |
| 53 | Integer count = groupService.GetCountFroUserType(1); |
| 54 | if(count>0){ |
| 55 | group = groupService.getGroupFroUserType(1); |
| 56 | }else{ |
| 57 | group = groupService.idgrouplist(1); |
| 58 | } |
| 59 | }else{ |
| 60 | //用户 |
| 61 | if(user.getGroupid()!=1){ |
| 62 | //说明自定义过的优先 |
| 63 | group = groupService.idgrouplist(user.getGroupid()); |
| 64 | }else{ |
| 65 | //默认的,用的是group主键为1的 但是还需要看看用户组有没有设置,比如管理员 用户 |
| 66 | if(user.getLevel()>1){ |
| 67 | //先查询管理员用户组有没有 如果有就用 没有就默认 |
| 68 | Integer count = groupService.GetCountFroUserType(3); |
| 69 | if(count>0){ |
| 70 | group = groupService.getGroupFroUserType(3); |
| 71 | }else{ |
| 72 | group = groupService.idgrouplist(1); |
| 73 | } |
| 74 | }else{ |
| 75 | //先查询普通用户组有没有 如果有就用 没有就默认 |
| 76 | Integer count = groupService.GetCountFroUserType(2); |
| 77 | if(count>0){ |
| 78 | group = groupService.getGroupFroUserType(2); |
| 79 |
nothing calls this directly
no outgoing calls
no test coverage detected