dingxin 6 years ago
parent
commit
ccb19b6a56

+ 7
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToSysUserRoleMapper.java View File

27
      * @return
27
      * @return
28
      */
28
      */
29
     List<ToSysUserRole> selelctByRoleId(@Param("roleId") Integer roleId);
29
     List<ToSysUserRole> selelctByRoleId(@Param("roleId") Integer roleId);
30
+
31
+    /**
32
+     * 根据 角色id 删除关联关系
33
+     * @param list
34
+     * @return
35
+     */
36
+    int deleteByRoleId(List<Integer> list);
30
 }
37
 }

+ 7
- 4
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToSysRoleServiceImpl.java View File

190
     public ResponseBean deleteRole(List<Integer> ids, UserElement userElement) {
190
     public ResponseBean deleteRole(List<Integer> ids, UserElement userElement) {
191
         ResponseBean responseBean = new ResponseBean();
191
         ResponseBean responseBean = new ResponseBean();
192
         ids.forEach(e ->{
192
         ids.forEach(e ->{
193
-            List<ToSysUserRole> userRoleList = toSysUserRoleMapper.selelctByRoleId(e);
194
-            if (CollectionUtils.isNotEmpty(userRoleList)) {
195
-                throw new WisdomException("角色存在用户关联关系, 无法删除!");
196
-            }
193
+//            List<ToSysUserRole> userRoleList = toSysUserRoleMapper.selelctByRoleId(e);
194
+//            if (CollectionUtils.isNotEmpty(userRoleList)) {
195
+//                throw new WisdomException("角色存在用户关联关系, 无法删除!");
196
+//            }
197
             ToSysRole toSysRole = toSysRoleMapper.selectByPrimaryKey(e);
197
             ToSysRole toSysRole = toSysRoleMapper.selectByPrimaryKey(e);
198
             if (null == toSysRole) {
198
             if (null == toSysRole) {
199
                 throw new WisdomException("删除失败, 角色编号 " + e + " 不存在!");
199
                 throw new WisdomException("删除失败, 角色编号 " + e + " 不存在!");
203
             toSysRole.setUpdateDate(new Date());
203
             toSysRole.setUpdateDate(new Date());
204
             toSysRoleMapper.updateByPrimaryKeySelective(toSysRole);
204
             toSysRoleMapper.updateByPrimaryKeySelective(toSysRole);
205
         });
205
         });
206
+        // 删除这个角色下关联关系
207
+        toSysUserRoleMapper.deleteByRoleId(ids);
208
+
206
         responseBean.addSuccess("操作成功!");
209
         responseBean.addSuccess("操作成功!");
207
         return responseBean;
210
         return responseBean;
208
     }
211
     }

+ 14
- 5
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java View File

18
 import com.github.pagehelper.Page;
18
 import com.github.pagehelper.Page;
19
 import com.github.pagehelper.PageHelper;
19
 import com.github.pagehelper.PageHelper;
20
 import lombok.extern.slf4j.Slf4j;
20
 import lombok.extern.slf4j.Slf4j;
21
+import org.apache.commons.collections.CollectionUtils;
21
 import org.apache.commons.lang.StringUtils;
22
 import org.apache.commons.lang.StringUtils;
22
 import org.springframework.beans.BeanUtils;
23
 import org.springframework.beans.BeanUtils;
23
 import org.springframework.beans.factory.annotation.Autowired;
24
 import org.springframework.beans.factory.annotation.Autowired;
24
 import org.springframework.stereotype.Service;
25
 import org.springframework.stereotype.Service;
25
 
26
 
26
-import javax.security.auth.callback.TextOutputCallback;
27
 import java.util.*;
27
 import java.util.*;
28
 
28
 
29
 @Service("iToUserServer")
29
 @Service("iToUserServer")
87
         ToUserVO toUserVO = new ToUserVO();
87
         ToUserVO toUserVO = new ToUserVO();
88
         BeanUtils.copyProperties(toUser,toUserVO);
88
         BeanUtils.copyProperties(toUser,toUserVO);
89
 
89
 
90
-        List<ToSysRole> sysRoleList = toSysRoleMapper.selectRoleByUserId(userId);
91
-        toUserVO.setRoles(sysRoleList);
92
-        // 菜单权限
93
-        toUserVO.setPermissionList(getPermission(userId));
90
+        List<ToSysRole> roleList = toSysRoleMapper.selectRoleByUserId(userId);
91
+        if (CollectionUtils.isNotEmpty(roleList)) {
92
+            List<ToSysRole> sysRoleList = toSysRoleMapper.selectRoleByUserId(userId);
93
+            toUserVO.setRoles(sysRoleList);
94
+            // 菜单权限
95
+            toUserVO.setPermissionList(getPermission(userId));
96
+        } else {
97
+            ToSysRole toSysRole = new ToSysRole();
98
+            toSysRole.setRoleName("没有角色");
99
+            toUserVO.setRoles(Arrays.asList(toSysRole));
100
+            // 菜单权限
101
+            toUserVO.setPermissionList(Collections.EMPTY_LIST);
102
+        }
94
         response.addSuccess(toUserVO);
103
         response.addSuccess(toUserVO);
95
 
104
 
96
         return response;
105
         return response;

+ 10
- 0
CODE/smart-community/operate-api/src/main/resources/mapper/ToSysUserRoleMapper.xml View File

83
     where role_id = #{roleId,jdbcType=INTEGER}
83
     where role_id = #{roleId,jdbcType=INTEGER}
84
   </select>
84
   </select>
85
 
85
 
86
+  <delete id="deleteByRoleId" parameterType="list" >
87
+    delete from
88
+    to_sys_user_role
89
+    where role_id in (
90
+      <foreach collection="list" item="item" separator=",">
91
+        #{item}
92
+      </foreach>
93
+    )
94
+  </delete>
95
+
86
 </mapper>
96
 </mapper>

+ 6
- 5
VUECODE/smart-operate-manage/src/store/modules/user.js View File

50
       return new Promise((resolve, reject) => {
50
       return new Promise((resolve, reject) => {
51
         getInfo().then(response => {
51
         getInfo().then(response => {
52
           const data = response.data
52
           const data = response.data
53
-          if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
54
-            commit('SET_ROLES', data.roles)
55
-          } else {
56
-            reject('getInfo: roles must be a non-null array !')
57
-          }
53
+          // if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
54
+          //   commit('SET_ROLES', data.roles)
55
+          // } else {
56
+          //   reject('getInfo: roles must be a non-null array !')
57
+          // }
58
+          commit('SET_ROLES', data.roles)
58
           commit('SET_NAME', data.userName)
59
           commit('SET_NAME', data.userName)
59
           commit('SET_AVATAR', data.loginName)
60
           commit('SET_AVATAR', data.loginName)
60
           commit('SET_USER_DATA', data)
61
           commit('SET_USER_DATA', data)

+ 2
- 1
VUECODE/smart-operate-manage/src/views/account/role/add/index.vue View File

4
       <el-form-item label="角色名称" prop="roleName">
4
       <el-form-item label="角色名称" prop="roleName">
5
         <el-input v-model="ruleForm.roleName"/>
5
         <el-input v-model="ruleForm.roleName"/>
6
       </el-form-item>
6
       </el-form-item>
7
-      <el-form-item label="角色描述" prop="description">
7
+      <!-- prop="description" -->
8
+      <el-form-item label="角色描述">
8
         <el-input v-model="ruleForm.description"/>
9
         <el-input v-model="ruleForm.description"/>
9
       </el-form-item>
10
       </el-form-item>
10
       <el-form-item label="权限资源" prop="menuArray">
11
       <el-form-item label="权限资源" prop="menuArray">

+ 5
- 2
VUECODE/smart-operate-manage/src/views/account/role/edi/index.vue View File

4
       <el-form-item label="角色名称" prop="roleName">
4
       <el-form-item label="角色名称" prop="roleName">
5
         <el-input v-model="ruleForm.roleName"/>
5
         <el-input v-model="ruleForm.roleName"/>
6
       </el-form-item>
6
       </el-form-item>
7
-      <el-form-item label="角色描述" prop="description">
7
+      <!--  prop="description" -->
8
+      <el-form-item label="角色描述">
8
         <el-input v-model="ruleForm.description"/>
9
         <el-input v-model="ruleForm.description"/>
9
       </el-form-item>
10
       </el-form-item>
10
       <el-form-item label="权限资源" prop="menuArray">
11
       <el-form-item label="权限资源" prop="menuArray">
59
   },
60
   },
60
   mounted() {
61
   mounted() {
61
     this.ruleForm.id = this.$route.params.id
62
     this.ruleForm.id = this.$route.params.id
62
-    this.getMenuList()
63
+    // 获取用户数据
63
     this.getInfo()
64
     this.getInfo()
64
   },
65
   },
65
   methods: {
66
   methods: {
125
         for (const i in resMenu) {
126
         for (const i in resMenu) {
126
           this.ruleForm.menuArray.push(resMenu[i].menuId)
127
           this.ruleForm.menuArray.push(resMenu[i].menuId)
127
         }
128
         }
129
+
130
+        this.getMenuList()
128
       }).catch(() => {
131
       }).catch(() => {
129
         console.log('error GetInfo')
132
         console.log('error GetInfo')
130
       })
133
       })

+ 3
- 1
VUECODE/smart-operate-manage/src/views/account/role/info/index.vue View File

60
   },
60
   },
61
   mounted() {
61
   mounted() {
62
     this.ruleForm.id = this.$route.params.id
62
     this.ruleForm.id = this.$route.params.id
63
-    this.getMenuList()
63
+    // 获取用户数据
64
     this.getInfo()
64
     this.getInfo()
65
   },
65
   },
66
   methods: {
66
   methods: {
93
         for (const i in resMenu) {
93
         for (const i in resMenu) {
94
           this.ruleForm.menuArray.push(resMenu[i].menuId)
94
           this.ruleForm.menuArray.push(resMenu[i].menuId)
95
         }
95
         }
96
+
97
+        this.getMenuList()
96
       }).catch(() => {
98
       }).catch(() => {
97
         console.log('error GetInfo')
99
         console.log('error GetInfo')
98
       })
100
       })

+ 0
- 1
VUECODE/smart-operate-manage/src/views/banner/infoBanner/index.vue View File

301
   height: 178px;
301
   height: 178px;
302
   display: block;
302
   display: block;
303
 }
303
 }
304
-
305
 </style>
304
 </style>
306
 
305