|
|
@@ -1,8 +1,21 @@
|
|
1
|
1
|
package com.chinaitop.depot.system.service.impl;
|
|
2
|
2
|
|
|
|
3
|
+import com.chinaitop.depot.system.mapper.FuncInfoMapper;
|
|
|
4
|
+import com.chinaitop.depot.system.mapper.RoleFuncMapper;
|
|
|
5
|
+import com.chinaitop.depot.system.mapper.RoleInfoMapper;
|
|
|
6
|
+import com.chinaitop.depot.system.mapper.UserInfoMapper;
|
|
3
|
7
|
import com.chinaitop.depot.system.mapper.UserRoleMapper;
|
|
|
8
|
+import com.chinaitop.depot.system.model.FuncInfo;
|
|
|
9
|
+import com.chinaitop.depot.system.model.FuncInfoExample;
|
|
|
10
|
+import com.chinaitop.depot.system.model.RoleFunc;
|
|
|
11
|
+import com.chinaitop.depot.system.model.RoleFuncExample;
|
|
|
12
|
+import com.chinaitop.depot.system.model.RoleInfo;
|
|
|
13
|
+import com.chinaitop.depot.system.model.RoleInfoExample;
|
|
|
14
|
+import com.chinaitop.depot.system.model.UserInfo;
|
|
|
15
|
+import com.chinaitop.depot.system.model.UserInfoExample;
|
|
4
|
16
|
import com.chinaitop.depot.system.model.UserRole;
|
|
5
|
17
|
import com.chinaitop.depot.system.model.UserRoleExample;
|
|
|
18
|
+import com.chinaitop.depot.system.model.RoleInfoExample.Criteria;
|
|
6
|
19
|
import com.chinaitop.depot.system.service.UserRoleService;
|
|
7
|
20
|
import org.springframework.stereotype.Service;
|
|
8
|
21
|
|
|
|
@@ -15,6 +28,18 @@ public class UserRoleServiceImpl implements UserRoleService {
|
|
15
|
28
|
|
|
16
|
29
|
@Resource
|
|
17
|
30
|
private UserRoleMapper userRoleMapper;
|
|
|
31
|
+
|
|
|
32
|
+ @Resource
|
|
|
33
|
+ private UserInfoMapper UserInfoMapper;
|
|
|
34
|
+
|
|
|
35
|
+ @Resource
|
|
|
36
|
+ private RoleInfoMapper RoleInfoMapper;
|
|
|
37
|
+
|
|
|
38
|
+ @Resource
|
|
|
39
|
+ private FuncInfoMapper funcInfoMapper;
|
|
|
40
|
+
|
|
|
41
|
+ @Resource
|
|
|
42
|
+ private RoleFuncMapper roleFuncMapper;
|
|
18
|
43
|
|
|
19
|
44
|
@Override
|
|
20
|
45
|
public List<UserRole> queryByExample(UserRoleExample example) {
|
|
|
@@ -41,4 +66,77 @@ public class UserRoleServiceImpl implements UserRoleService {
|
|
41
|
66
|
return userRoleMapper.getUserRoleFeign(userId);
|
|
42
|
67
|
}
|
|
43
|
68
|
|
|
|
69
|
+ @Override
|
|
|
70
|
+ public void addRoleToUser() {
|
|
|
71
|
+ // TODO Auto-generated method stub
|
|
|
72
|
+
|
|
|
73
|
+ //查询出 手动增加的 用户的信息
|
|
|
74
|
+ UserInfoExample example = new UserInfoExample();
|
|
|
75
|
+ example.createCriteria().andUserIdGreaterThanOrEqualTo(10);
|
|
|
76
|
+ example.createCriteria().andUserIdLessThanOrEqualTo(72);
|
|
|
77
|
+ List<UserInfo> userInfoList = UserInfoMapper.selectByExample(example);
|
|
|
78
|
+
|
|
|
79
|
+
|
|
|
80
|
+ //所有的权限信息
|
|
|
81
|
+ FuncInfoExample funcExample = new FuncInfoExample();
|
|
|
82
|
+ List<FuncInfo> funcInfoList = funcInfoMapper.selectByExample(funcExample);
|
|
|
83
|
+
|
|
|
84
|
+ for(UserInfo userInfo:userInfoList){
|
|
|
85
|
+ //查询 改单位下的 管理员 角色的 id
|
|
|
86
|
+
|
|
|
87
|
+ RoleInfoExample example1 = new RoleInfoExample();
|
|
|
88
|
+ Criteria criteria1 = example1.createCriteria();
|
|
|
89
|
+ criteria1.andRoleNameEqualTo("系统管理员");
|
|
|
90
|
+ criteria1.andOrgIdEqualTo(userInfo.getOrgId());
|
|
|
91
|
+ List<RoleInfo> roleInfoList = RoleInfoMapper.selectByExample(example1);
|
|
|
92
|
+
|
|
|
93
|
+ if(roleInfoList.size()>0){
|
|
|
94
|
+ /**
|
|
|
95
|
+ * 人员加角色
|
|
|
96
|
+ */
|
|
|
97
|
+ //查询 该人员 有没有该角色 有 不处理 无 则增加
|
|
|
98
|
+ UserRoleExample example2 = new UserRoleExample();
|
|
|
99
|
+ com.chinaitop.depot.system.model.UserRoleExample.Criteria criteria2 = example2.createCriteria();
|
|
|
100
|
+ criteria2.andRoleIdEqualTo(roleInfoList.get(0).getRoleId());
|
|
|
101
|
+ criteria2.andUserIdEqualTo(userInfo.getUserId());
|
|
|
102
|
+ List<UserRole> userRoleList = userRoleMapper.selectByExample(example2);
|
|
|
103
|
+ if(userRoleList.size()>0){
|
|
|
104
|
+
|
|
|
105
|
+ }else{
|
|
|
106
|
+ UserRole userRole = new UserRole();
|
|
|
107
|
+ userRole.setUserId(userInfo.getUserId());
|
|
|
108
|
+ userRole.setRoleId(roleInfoList.get(0).getRoleId());
|
|
|
109
|
+ userRoleMapper.insert(userRole);
|
|
|
110
|
+ }
|
|
|
111
|
+
|
|
|
112
|
+ /**
|
|
|
113
|
+ * 角色 加 权限
|
|
|
114
|
+ */
|
|
|
115
|
+ //查询 该角色 有没有该权限 有 不处理 无 则增加
|
|
|
116
|
+
|
|
|
117
|
+ for(FuncInfo funcInfo:funcInfoList){
|
|
|
118
|
+ RoleFuncExample example3 = new RoleFuncExample();
|
|
|
119
|
+ com.chinaitop.depot.system.model.RoleFuncExample.Criteria criteria3 = example3.createCriteria();
|
|
|
120
|
+ criteria3.andRoleIdEqualTo(roleInfoList.get(0).getRoleId());
|
|
|
121
|
+ criteria3.andFuncIdEqualTo(funcInfo.getFuncId());
|
|
|
122
|
+ List<RoleFunc> roleFuncList = roleFuncMapper.selectByExample(example3);
|
|
|
123
|
+ if(roleFuncList.size()>0){
|
|
|
124
|
+
|
|
|
125
|
+ }else{
|
|
|
126
|
+ RoleFunc roleFunc = new RoleFunc();
|
|
|
127
|
+ roleFunc.setFuncId(funcInfo.getFuncId());
|
|
|
128
|
+ roleFunc.setRoleId(roleInfoList.get(0).getRoleId());
|
|
|
129
|
+ roleFuncMapper.insert(roleFunc);
|
|
|
130
|
+ }
|
|
|
131
|
+ }
|
|
|
132
|
+
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+
|
|
|
137
|
+
|
|
|
138
|
+
|
|
|
139
|
+
|
|
|
140
|
+ }
|
|
|
141
|
+
|
|
44
|
142
|
}
|