Просмотр исходного кода

修改新建用户时的校验

qitz 2 лет назад
Родитель
Сommit
8ca9b43b3b

+ 2
- 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java Просмотреть файл

138
         }
138
         }
139
         user.setCreateBy(getUsername());
139
         user.setCreateBy(getUsername());
140
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
140
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
141
-        return toAjax(userService.insertUser(user));
141
+        return userService.insertUser(user);
142
     }
142
     }
143
 
143
 
144
     /**
144
     /**
164
             return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
164
             return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
165
         }
165
         }
166
         user.setUpdateBy(getUsername());
166
         user.setUpdateBy(getUsername());
167
-        return toAjax(userService.updateUser(user));
167
+        return userService.updateUser(user);
168
     }
168
     }
169
 
169
 
170
     /**
170
     /**

+ 8
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java Просмотреть файл

33
      */
33
      */
34
     public SysPost selectPostById(Long postId);
34
     public SysPost selectPostById(Long postId);
35
 
35
 
36
+    /**
37
+     * 查询岗位为经办人的岗位信息
38
+     *
39
+     * @param postCode 岗位编码
40
+     * @return 角色对象信息
41
+     */
42
+    public SysPost selectPostByPostCode(String postCode);
43
+
36
     /**
44
     /**
37
      * 根据用户ID获取岗位选择框列表
45
      * 根据用户ID获取岗位选择框列表
38
      * 
46
      * 

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java Просмотреть файл

58
      * @return 用户对象信息
58
      * @return 用户对象信息
59
      */
59
      */
60
     public SysUser selectUserById(Long userId);
60
     public SysUser selectUserById(Long userId);
61
+    /**
62
+     * 通过部门ID查询用户
63
+     *
64
+     * @param deptId 部门ID
65
+     * @return 用户对象信息
66
+     */
67
+    public List<SysUser> selectUserByDeptId(Long deptId);
61
 
68
 
62
     /**
69
     /**
63
      * 新增用户信息
70
      * 新增用户信息

+ 4
- 2
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java Просмотреть файл

1
 package com.ruoyi.system.service;
1
 package com.ruoyi.system.service;
2
 
2
 
3
 import java.util.List;
3
 import java.util.List;
4
+
5
+import com.ruoyi.common.core.domain.AjaxResult;
4
 import com.ruoyi.common.core.domain.entity.SysUser;
6
 import com.ruoyi.common.core.domain.entity.SysUser;
5
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
7
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
6
 
8
 
112
      * @param user 用户信息
114
      * @param user 用户信息
113
      * @return 结果
115
      * @return 结果
114
      */
116
      */
115
-    public int insertUser(SysUser user);
117
+    public AjaxResult insertUser(SysUser user);
116
 
118
 
117
     /**
119
     /**
118
      * 注册用户信息
120
      * 注册用户信息
128
      * @param user 用户信息
130
      * @param user 用户信息
129
      * @return 结果
131
      * @return 结果
130
      */
132
      */
131
-    public int updateUser(SysUser user);
133
+    public AjaxResult updateUser(SysUser user);
132
 
134
 
133
     /**
135
     /**
134
      * 用户授权角色
136
      * 用户授权角色

+ 52
- 9
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java Просмотреть файл

1
 package com.ruoyi.system.service.impl;
1
 package com.ruoyi.system.service.impl;
2
 
2
 
3
 import java.util.ArrayList;
3
 import java.util.ArrayList;
4
+import java.util.Arrays;
4
 import java.util.List;
5
 import java.util.List;
5
 import java.util.stream.Collectors;
6
 import java.util.stream.Collectors;
6
 import javax.validation.Validator;
7
 import javax.validation.Validator;
7
 
8
 
9
+import com.ruoyi.common.core.domain.AjaxResult;
10
+import com.ruoyi.common.core.domain.entity.SysDept;
11
+import com.ruoyi.system.mapper.*;
8
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
12
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
9
 import org.slf4j.Logger;
13
 import org.slf4j.Logger;
10
 import org.slf4j.LoggerFactory;
14
 import org.slf4j.LoggerFactory;
24
 import com.ruoyi.system.domain.SysPost;
28
 import com.ruoyi.system.domain.SysPost;
25
 import com.ruoyi.system.domain.SysUserPost;
29
 import com.ruoyi.system.domain.SysUserPost;
26
 import com.ruoyi.system.domain.SysUserRole;
30
 import com.ruoyi.system.domain.SysUserRole;
27
-import com.ruoyi.system.mapper.SysPostMapper;
28
-import com.ruoyi.system.mapper.SysRoleMapper;
29
-import com.ruoyi.system.mapper.SysUserMapper;
30
-import com.ruoyi.system.mapper.SysUserPostMapper;
31
-import com.ruoyi.system.mapper.SysUserRoleMapper;
32
 import com.ruoyi.system.service.ISysConfigService;
31
 import com.ruoyi.system.service.ISysConfigService;
33
 import com.ruoyi.system.service.ISysUserService;
32
 import com.ruoyi.system.service.ISysUserService;
34
 
33
 
48
     @Autowired
47
     @Autowired
49
     private SysRoleMapper roleMapper;
48
     private SysRoleMapper roleMapper;
50
 
49
 
50
+    @Autowired
51
+    private SysDeptMapper sysDeptMapper;
52
+
51
     @Autowired
53
     @Autowired
52
     private SysPostMapper postMapper;
54
     private SysPostMapper postMapper;
53
 
55
 
261
      */
263
      */
262
     @Override
264
     @Override
263
     @Transactional
265
     @Transactional
264
-    public int insertUser(SysUser user)
266
+    public AjaxResult insertUser(SysUser user)
265
     {
267
     {
268
+        Long deptId = user.getDeptId();
269
+        Long[] postIds = user.getPostIds();
270
+        if(deptId!=null){
271
+            SysDept dept = sysDeptMapper.selectDeptById(deptId);
272
+            Integer deptType = dept.getDeptType();
273
+            if(deptType.intValue()==1){
274
+                SysPost sysPost = postMapper.selectPostByPostCode("jbr");
275
+                Long postId = sysPost.getPostId();
276
+                if(postIds.length>0){
277
+                    boolean isContain = Arrays.asList(postIds).contains(postId);
278
+                    if(isContain){
279
+                        List<SysUser>  sysUsers = userMapper.selectUserByDeptId(deptId);
280
+                        if(sysUsers!=null&&sysUsers.size()>0){
281
+                            return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
282
+                        }
283
+                    }
284
+                }
285
+            }
286
+        }
287
+
266
         // 新增用户信息
288
         // 新增用户信息
267
         int rows = userMapper.insertUser(user);
289
         int rows = userMapper.insertUser(user);
268
         // 新增用户岗位关联
290
         // 新增用户岗位关联
269
         insertUserPost(user);
291
         insertUserPost(user);
270
         // 新增用户与角色管理
292
         // 新增用户与角色管理
271
         insertUserRole(user);
293
         insertUserRole(user);
272
-        return rows;
294
+        return AjaxResult.success("新建用户成功");
273
     }
295
     }
274
 
296
 
275
     /**
297
     /**
292
      */
314
      */
293
     @Override
315
     @Override
294
     @Transactional
316
     @Transactional
295
-    public int updateUser(SysUser user)
317
+    public AjaxResult updateUser(SysUser user)
296
     {
318
     {
319
+        Long deptId = user.getDeptId();
320
+        Long[] postIds = user.getPostIds();
321
+        if(deptId!=null){
322
+            SysDept dept = sysDeptMapper.selectDeptById(deptId);
323
+            Integer deptType = dept.getDeptType();
324
+            if(deptType.intValue()==1){
325
+                SysPost sysPost = postMapper.selectPostByPostCode("jbr");
326
+                Long postId = sysPost.getPostId();
327
+                if(postIds.length>0){
328
+                    boolean isContain = Arrays.asList(postIds).contains(postId);
329
+                    if(isContain){
330
+                        List<SysUser>  sysUsers = userMapper.selectUserByDeptId(deptId);
331
+                        if(sysUsers!=null&&sysUsers.size()>0){
332
+                            return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
333
+                        }
334
+                    }
335
+                }
336
+            }
337
+        }
338
+
297
         Long userId = user.getUserId();
339
         Long userId = user.getUserId();
298
         // 删除用户与角色关联
340
         // 删除用户与角色关联
299
         userRoleMapper.deleteUserRoleByUserId(userId);
341
         userRoleMapper.deleteUserRoleByUserId(userId);
303
         userPostMapper.deleteUserPostByUserId(userId);
345
         userPostMapper.deleteUserPostByUserId(userId);
304
         // 新增用户与岗位管理
346
         // 新增用户与岗位管理
305
         insertUserPost(user);
347
         insertUserPost(user);
306
-        return userMapper.updateUser(user);
348
+        userMapper.updateUser(user);
349
+        return AjaxResult.success("更新用户成功");
307
     }
350
     }
308
 
351
 
309
     /**
352
     /**

+ 10
- 10
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Просмотреть файл

620
         CaseApplication caseApplication = new CaseApplication();
620
         CaseApplication caseApplication = new CaseApplication();
621
         caseApplication.setId(id);
621
         caseApplication.setId(id);
622
         //查询案件信息
622
         //查询案件信息
623
-        CaseApplication caseApplication1 = caseApplicationService.selectCaseApplication(caseApplication);
624
-        if (caseApplication1 != null) {
625
-            archivesDetailVO.setCaseApplication(caseApplication1);
626
-        }
623
+//        CaseApplication caseApplication1 = caseApplicationService.selectCaseApplication(caseApplication);
624
+//        if (caseApplication1 != null) {
625
+//            archivesDetailVO.setCaseApplication(caseApplication1);
626
+//        }
627
         //查询案件日志信息
627
         //查询案件日志信息
628
-        CaseLogRecord caseLogRecord = new CaseLogRecord();
629
-        caseLogRecord.setCaseAppliId(id);
630
-        List<CaseLogRecord> caseLogRecords = caseLogRecordService.selectCaseLogRecordList(caseLogRecord);
631
-        if (caseLogRecords != null && caseLogRecords.size() > 0) {
632
-            archivesDetailVO.setCaseLogRecordList(caseLogRecords);
633
-        }
628
+//        CaseLogRecord caseLogRecord = new CaseLogRecord();
629
+//        caseLogRecord.setCaseAppliId(id);
630
+//        List<CaseLogRecord> caseLogRecords = caseLogRecordService.selectCaseLogRecordList(caseLogRecord);
631
+//        if (caseLogRecords != null && caseLogRecords.size() > 0) {
632
+//            archivesDetailVO.setCaseLogRecordList(caseLogRecords);
633
+//        }
634
         //查询快递信息
634
         //查询快递信息
635
         List<LogisticsInfoVO> logisticsInfo = this.getLogisticsInfo(caseApplication);
635
         List<LogisticsInfoVO> logisticsInfo = this.getLogisticsInfo(caseApplication);
636
         if (logisticsInfo != null && logisticsInfo.size() > 0) {
636
         if (logisticsInfo != null && logisticsInfo.size() > 0) {

+ 0
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java Просмотреть файл

40
     private DeptIdentifyMapper deptIdentifyMapper;
40
     private DeptIdentifyMapper deptIdentifyMapper;
41
 
41
 
42
     @Scheduled(cron = "0/10 * * * * ?")
42
     @Scheduled(cron = "0/10 * * * * ?")
43
-//    @Scheduled(cron = "0/30 * * * * ?")
44
     @Transactional
43
     @Transactional
45
     public void fixExecuteSelectFlowDetailUtils(){
44
     public void fixExecuteSelectFlowDetailUtils(){
46
         Gson gson = new Gson();
45
         Gson gson = new Gson();

+ 5
- 0
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml Просмотреть файл

45
 		<include refid="selectPostVo"/>
45
 		<include refid="selectPostVo"/>
46
 		where post_id = #{postId}
46
 		where post_id = #{postId}
47
 	</select>
47
 	</select>
48
+
49
+	<select id="selectPostByPostCode" parameterType="String" resultMap="SysPostResult">
50
+		<include refid="selectPostVo"/>
51
+		where post_code = #{postCode}
52
+	</select>
48
 	
53
 	
49
 	<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
54
 	<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
50
 		select p.post_id
55
 		select p.post_id

+ 9
- 0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml Просмотреть файл

131
 		<include refid="selectUserVo"/>
131
 		<include refid="selectUserVo"/>
132
 		where u.user_id = #{userId}
132
 		where u.user_id = #{userId}
133
 	</select>
133
 	</select>
134
+
135
+	<select id="selectUserByDeptId" parameterType="Long" resultMap="SysUserResult">
136
+		SELECT  ud.user_id , ud.nick_name ,ud.phonenumber ,ud.dept_id ,d.dept_name
137
+        FROM  (SELECT u.user_id , u.nick_name ,u.phonenumber ,u.dept_id
138
+        FROM sys_user_post up left join sys_user  u on u.user_id  = up.user_id
139
+            left join  sys_post  sp on up.post_id  = sp.post_id
140
+        where sp.post_code = 'jbr') ud left join sys_dept d on ud.dept_id = d.dept_id
141
+		where d.dept_id = #{deptId}
142
+	</select>
134
 	
143
 	
135
 	<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
144
 	<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
136
 		select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
145
 		select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1