Browse Source

Revert "合并所有代码"

This reverts commit 49f9baa32670a5bf45fb4901f014a96e71eca3d2.
dingxin 6 years ago
parent
commit
24278bbd0c

+ 8
- 36
src/main/java/com.huiju.welcome/controller/SysUserController.java View File

@@ -251,41 +251,20 @@ public class SysUserController extends BaseController {
251 251
                                        @RequestParam(value = "userName",required = false) String userName,
252 252
                                        @RequestParam(value = "phone",required = false) String phone) {
253 253
         IPage<SysUserRole> pg = new Page<>(pageNum, pageSize);
254
-
255 254
         ResponseBean userManagement= sysUserService.userManagementList(pg,userName,phone);
256
-
257 255
         return userManagement;
258 256
     }
259 257
 
260
-    @ApiOperation(value = "员工管理角色权限添加", notes = "员工管理角色权限添加")
261
-    @RequestMapping(value = "/addUserRole", method = RequestMethod.POST)
262
-    public ResponseBean userManagement(@RequestParam(value = "phone",required = false) String phone,
263
-                                       @RequestParam(value = "roleId",required = false) List<String> roleId) {
264
-        ResponseBean userManagement= sysUserService.addUserRole(phone,roleId);
265
-        return userManagement;
266
-    }
267
-
268
-    @ApiOperation(value = "查询当前员工的角色权限", notes = "查询当前员工的角色权限")
269
-    @RequestMapping(value = "/userRoledetails", method = RequestMethod.GET)
270
-    public ResponseBean userRoledetails(@RequestParam(value = "userId",required = false) Integer userId) {
271
-         ResponseBean userRoledetails= sysUserService.userRoledetails(userId);
272
-        return userRoledetails;
273
-    }
274
-    @ApiOperation(value = "修改当前员工的角色权限", notes = "修改当前员工的角色权限")
275
-    @RequestMapping(value = "/updateUserRolede", method = RequestMethod.POST)
276
-    public ResponseBean updateUserRolede(@RequestParam(value = "userId",required = false) Integer userId,
277
-                                         @RequestParam(value = "menuArray",required = false) List<String> menuArray) {
278
-        ResponseBean updateUserRolede= sysUserService.updateUserRolede(userId,menuArray);
279
-        return updateUserRolede;
280
-    }
281
-    @ApiOperation(value = "获取所有角色权限", notes = "获取所有角色权限")
282
-    @RequestMapping(value = "/roleAll", method = RequestMethod.GET)
283
-    public ResponseBean roleAll() {
284
-        ResponseBean roleAll= sysUserService.roleAll();
285
-        return roleAll;
258
+    @ApiOperation(value = "树形", notes = "树形")
259
+    @ApiImplicitParams({
260
+            @ApiImplicitParam(paramType = "body", dataType = "SysUser", name = "sysUser", value = "用户详情")
261
+    })
262
+    @RequestMapping(value = "/user/tree", method = RequestMethod.GET)
263
+    public ResponseBean userRoleTree(@RequestBody SysUser sysUser, HttpServletRequest request) {
264
+        ResponseBean tree= sysUserService.userRoleTree();
265
+        return tree;
286 266
     }
287 267
 
288
-
289 268
     @ApiOperation(value = "角色管理列表", notes = "角色管理列表")
290 269
     @ApiImplicitParams({
291 270
             @ApiImplicitParam(paramType = "body", dataType = "String", name = "userName", value = "角色名称"),
@@ -298,11 +277,4 @@ public class SysUserController extends BaseController {
298 277
         ResponseBean roleManagementList= sysUserService.roleManagementList(pg,roleName);
299 278
         return roleManagementList;
300 279
     }
301
-
302
-    @ApiOperation(value = "删除当前员工的角色权限", notes = "删除当前员工的角色权限")
303
-    @RequestMapping(value = "/deleteUserRole", method = RequestMethod.POST)
304
-    public ResponseBean deleteUserRole(@RequestParam(value = "userId",required = false) Integer userId) {
305
-        ResponseBean deleteUserRole= sysUserService.deleteUserRole(userId);
306
-        return deleteUserRole;
307
-    }
308 280
 }

+ 0
- 8
src/main/java/com.huiju.welcome/mapper/SysRoleMapper.java View File

@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.huiju.welcome.model.SysRole;
6 6
 import org.apache.ibatis.annotations.Mapper;
7 7
 
8
-import java.util.List;
9
-
10 8
 /**
11 9
  * <p>
12 10
  *  Mapper 接口
@@ -25,10 +23,4 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
25 23
      * @return
26 24
      */
27 25
     IPage<SysRole> roleManagementList(IPage<SysRole> pg, String roleName);
28
-
29
-    /**
30
-     * 获取所有角色
31
-     * @return
32
-     */
33
-    List<SysRole> selectroleAll();
34 26
 }

+ 0
- 8
src/main/java/com.huiju.welcome/mapper/SysUserRoleMapper.java View File

@@ -8,8 +8,6 @@ import com.huiju.welcome.model.TaVisitorAppointment;
8 8
 import org.apache.ibatis.annotations.Mapper;
9 9
 import org.apache.ibatis.annotations.Param;
10 10
 
11
-import java.util.List;
12
-
13 11
 /**
14 12
  * <p>
15 13
  *  Mapper 接口
@@ -30,10 +28,4 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
30 28
      */
31 29
     IPage<SysUserRole> userManagementList(IPage<SysUserRole> pg, @Param("userName") String userName, @Param("phone") String phone);
32 30
 
33
-    /**
34
-     * 查询当用户的角色
35
-     * @param userId
36
-     * @return
37
-     */
38
-    List<SysUserRole> selectListSysUserRole(@Param("userId") Integer userId);
39 31
 }

+ 3
- 5
src/main/java/com.huiju.welcome/model/SysUserRole.java View File

@@ -1,11 +1,8 @@
1 1
 package com.huiju.welcome.model;
2 2
 
3 3
 import java.io.Serializable;
4
-import java.util.List;
5 4
 
6
-import com.baomidou.mybatisplus.annotation.IdType;
7 5
 import com.baomidou.mybatisplus.annotation.TableField;
8
-import com.baomidou.mybatisplus.annotation.TableId;
9 6
 import lombok.Data;
10 7
 import lombok.EqualsAndHashCode;
11 8
 import lombok.experimental.Accessors;
@@ -18,10 +15,9 @@ import lombok.experimental.Accessors;
18 15
  * @author jobob
19 16
  * @since 2019-07-12
20 17
  */
21
-
18
+@Data
22 19
 @EqualsAndHashCode(callSuper = false)
23 20
 @Accessors(chain = true)
24
-@Data
25 21
 public class SysUserRole implements Serializable {
26 22
 
27 23
     private static final long serialVersionUID = 1L;
@@ -48,4 +44,6 @@ public class SysUserRole implements Serializable {
48 44
      */
49 45
     @TableField("`roleName`")
50 46
     private String roleName;
47
+
48
+
51 49
 }

+ 0
- 37
src/main/java/com.huiju.welcome/service/ISysUserService.java View File

@@ -8,8 +8,6 @@ import com.huiju.welcome.model.SysUser;
8 8
 import com.huiju.welcome.model.SysUserRole;
9 9
 import com.huiju.welcome.model.TaVisitorAppointment;
10 10
 
11
-import java.util.List;
12
-
13 11
 /**
14 12
  * <p>
15 13
  *  服务类
@@ -46,39 +44,4 @@ public interface ISysUserService extends IService<SysUser> {
46 44
      * @return
47 45
      */
48 46
     ResponseBean roleManagementList(IPage<SysRole> pg, String roleName);
49
-
50
-    /**
51
-     * 添加角色权限
52
-     * @param phone
53
-     * @param role
54
-     * @return
55
-     */
56
-    ResponseBean addUserRole(String phone, List<String> role);
57
-
58
-    /**
59
-     * 查询当前员工所有权限
60
-     * @param userId
61
-     * @return
62
-     */
63
-    ResponseBean userRoledetails(Integer userId);
64
-
65
-    /**
66
-     * 修改当前员工的角色权限
67
-     * @param userId
68
-     * @return
69
-     */
70
-    ResponseBean updateUserRolede(Integer userId,List<String> role);
71
-
72
-    /**
73
-     * 获取所有角色
74
-     * @return
75
-     */
76
-    ResponseBean roleAll();
77
-
78
-    /**
79
-     * 删除当前员工权限
80
-     * @param userId
81
-     * @return
82
-     */
83
-    ResponseBean deleteUserRole(Integer userId);
84 47
 }

+ 0
- 83
src/main/java/com.huiju.welcome/service/impl/SysUserServiceImpl.java View File

@@ -11,8 +11,6 @@ import com.huiju.welcome.utils.StatusUtils;
11 11
 import org.springframework.beans.factory.annotation.Autowired;
12 12
 import org.springframework.stereotype.Service;
13 13
 
14
-import java.util.ArrayList;
15
-import java.util.HashMap;
16 14
 import java.util.List;
17 15
 
18 16
 /**
@@ -77,85 +75,4 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
77 75
         responseBean.addSuccess(list);
78 76
         return responseBean;
79 77
     }
80
-
81
-    @Override
82
-    public ResponseBean addUserRole(String phone, List<String> role) {
83
-        ResponseBean responseBean = new ResponseBean<>();
84
-        String[] strArray = role.toArray(new String[role.size()]);
85
-        /*查询当前号码是否存在*/
86
-        QueryWrapper<SysUser> sysUserQueryWrapper= new QueryWrapper<>();
87
-        sysUserQueryWrapper.eq("phone",phone);
88
-        SysUser sysUser = sysUserMapper.selectOne(sysUserQueryWrapper);
89
-        if (null == sysUser){
90
-            responseBean.addError("此号码不存在");
91
-            return responseBean;
92
-        }
93
-        // 查询当前人员角色权限是否存在
94
-        List<SysUserRole> sysUserRole= sysUserRoleMapper.selectListSysUserRole(sysUser.getUserId());
95
-        if (sysUserRole!=null && !sysUserRole.isEmpty()){
96
-            responseBean.addError("此用户已存在权限,请点击修改");
97
-            return responseBean;
98
-        }
99
-        for (String id:strArray){
100
-            SysUserRole userRole= new SysUserRole();
101
-            userRole.setUserId(sysUser.getUserId()).setRoleId(Integer.valueOf(id));
102
-            sysUserRoleMapper.insert(userRole);
103
-        }
104
-        responseBean.addSuccess(sysUser);
105
-        return responseBean;
106
-    }
107
-
108
-    @Override
109
-    public ResponseBean userRoledetails(Integer userId) {
110
-        ResponseBean responseBean= new ResponseBean<>();
111
-        List<Integer> arrayList= new ArrayList<>();
112
-        SysUser user= sysUserMapper.selectById(userId);
113
-        List<SysRole> sysRole= sysRoleMapper.selectroleAll();
114
-        List<SysUserRole> sysUserRoleList= sysUserRoleMapper.selectListSysUserRole(userId);
115
-        for (SysUserRole sysUserRole:sysUserRoleList){
116
-            arrayList.add(sysUserRole.getRoleId());
117
-        }
118
-        HashMap<Object,Object> map = new HashMap<>();
119
-        map.put("arrayList",arrayList);
120
-        map.put("user",user);
121
-        map.put("sysRole",sysRole);
122
-        responseBean.addSuccess(map);
123
-        return responseBean;
124
-    }
125
-
126
-    @Override
127
-    public ResponseBean updateUserRolede(Integer userId,List<String> role) {
128
-        ResponseBean responseBean= new ResponseBean<>();
129
-        // 查出当前用户的所有权限,先删除后添加
130
-        List<SysUserRole> sysUserRoleList= sysUserRoleMapper.selectListSysUserRole(userId);
131
-        for (SysUserRole sysUserRole:sysUserRoleList){
132
-            sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().eq("user_id",userId));
133
-        }
134
-        String[] array = role.toArray(new String[role.size()]);
135
-        for (String id:array){
136
-            SysUserRole sysRole= new SysUserRole();
137
-            sysRole.setRoleId(Integer.valueOf(id)).setUserId(userId);
138
-            sysUserRoleMapper.insert(sysRole);
139
-        }
140
-        responseBean.addSuccess("成功");
141
-        return responseBean;
142
-    }
143
-
144
-    @Override
145
-    public ResponseBean roleAll() {
146
-       ResponseBean responseBean=  new ResponseBean<>();
147
-        List<SysRole> sysRole= sysRoleMapper.selectroleAll();
148
-        responseBean.addSuccess(sysRole);
149
-        return responseBean;
150
-    }
151
-
152
-    @Override
153
-    public ResponseBean deleteUserRole(Integer userId) {
154
-        ResponseBean responseBean= new ResponseBean<>();
155
-        QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
156
-        sysUserRoleQueryWrapper.eq("user_id",userId);
157
-        int sysUserRole=  sysUserRoleMapper.delete(sysUserRoleQueryWrapper);
158
-        responseBean.addSuccess(sysUserRole);
159
-        return responseBean;
160
-    }
161 78
 }

+ 0
- 4
src/main/resources/mapper/SysRoleMapper.xml View File

@@ -6,8 +6,4 @@
6 6
         select * from sys_role order by create_date desc
7 7
     </select>
8 8
 
9
-    <select id="selectroleAll" resultType="com.huiju.welcome.model.SysUserRole">
10
-        select * from  sys_role
11
-    </select>
12
-
13 9
 </mapper>

+ 1
- 8
src/main/resources/mapper/SysUserRoleMapper.xml View File

@@ -5,8 +5,7 @@
5 5
         select
6 6
         u.username,
7 7
         u.phone,
8
-        u.user_id as userId,
9
-        GROUP_CONCAT(r.role_name) roleName
8
+        r.role_name as roleName
10 9
         from sys_user_role ur
11 10
         left join sys_user u on  ur.user_id = u.user_id
12 11
         left join sys_role r on  ur.role_id = r.role_id
@@ -18,11 +17,5 @@
18 17
                 u.phone LIKE CONCAT('%',#{phone},'%')
19 18
             </if>
20 19
         </where>
21
-        GROUP BY
22
-        ur.user_id
23
-    </select>
24
-    
25
-    <select id="selectListSysUserRole" resultType="com.huiju.welcome.model.SysUserRole">
26
-        select * from sys_user_role where  user_id = #{userId};
27 20
     </select>
28 21
 </mapper>