Bläddra i källkod

修改新建用户时的校验

qitz 2 år sedan
förälder
incheckning
8ca9b43b3b

+ 2
- 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java Visa fil

@@ -138,7 +138,7 @@ public class SysUserController extends BaseController
138 138
         }
139 139
         user.setCreateBy(getUsername());
140 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,7 +164,7 @@ public class SysUserController extends BaseController
164 164
             return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
165 165
         }
166 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 Visa fil

@@ -33,6 +33,14 @@ public interface SysPostMapper
33 33
      */
34 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 45
      * 根据用户ID获取岗位选择框列表
38 46
      * 

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java Visa fil

@@ -58,6 +58,13 @@ public interface SysUserMapper
58 58
      * @return 用户对象信息
59 59
      */
60 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 Visa fil

@@ -1,6 +1,8 @@
1 1
 package com.ruoyi.system.service;
2 2
 
3 3
 import java.util.List;
4
+
5
+import com.ruoyi.common.core.domain.AjaxResult;
4 6
 import com.ruoyi.common.core.domain.entity.SysUser;
5 7
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
6 8
 
@@ -112,7 +114,7 @@ public interface ISysUserService
112 114
      * @param user 用户信息
113 115
      * @return 结果
114 116
      */
115
-    public int insertUser(SysUser user);
117
+    public AjaxResult insertUser(SysUser user);
116 118
 
117 119
     /**
118 120
      * 注册用户信息
@@ -128,7 +130,7 @@ public interface ISysUserService
128 130
      * @param user 用户信息
129 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 Visa fil

@@ -1,10 +1,14 @@
1 1
 package com.ruoyi.system.service.impl;
2 2
 
3 3
 import java.util.ArrayList;
4
+import java.util.Arrays;
4 5
 import java.util.List;
5 6
 import java.util.stream.Collectors;
6 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 12
 import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
9 13
 import org.slf4j.Logger;
10 14
 import org.slf4j.LoggerFactory;
@@ -24,11 +28,6 @@ import com.ruoyi.common.utils.spring.SpringUtils;
24 28
 import com.ruoyi.system.domain.SysPost;
25 29
 import com.ruoyi.system.domain.SysUserPost;
26 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 31
 import com.ruoyi.system.service.ISysConfigService;
33 32
 import com.ruoyi.system.service.ISysUserService;
34 33
 
@@ -48,6 +47,9 @@ public class SysUserServiceImpl implements ISysUserService
48 47
     @Autowired
49 48
     private SysRoleMapper roleMapper;
50 49
 
50
+    @Autowired
51
+    private SysDeptMapper sysDeptMapper;
52
+
51 53
     @Autowired
52 54
     private SysPostMapper postMapper;
53 55
 
@@ -261,15 +263,35 @@ public class SysUserServiceImpl implements ISysUserService
261 263
      */
262 264
     @Override
263 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 289
         int rows = userMapper.insertUser(user);
268 290
         // 新增用户岗位关联
269 291
         insertUserPost(user);
270 292
         // 新增用户与角色管理
271 293
         insertUserRole(user);
272
-        return rows;
294
+        return AjaxResult.success("新建用户成功");
273 295
     }
274 296
 
275 297
     /**
@@ -292,8 +314,28 @@ public class SysUserServiceImpl implements ISysUserService
292 314
      */
293 315
     @Override
294 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 339
         Long userId = user.getUserId();
298 340
         // 删除用户与角色关联
299 341
         userRoleMapper.deleteUserRoleByUserId(userId);
@@ -303,7 +345,8 @@ public class SysUserServiceImpl implements ISysUserService
303 345
         userPostMapper.deleteUserPostByUserId(userId);
304 346
         // 新增用户与岗位管理
305 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 Visa fil

@@ -620,17 +620,17 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
620 620
         CaseApplication caseApplication = new CaseApplication();
621 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 635
         List<LogisticsInfoVO> logisticsInfo = this.getLogisticsInfo(caseApplication);
636 636
         if (logisticsInfo != null && logisticsInfo.size() > 0) {

+ 0
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java Visa fil

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

+ 5
- 0
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml Visa fil

@@ -45,6 +45,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
45 45
 		<include refid="selectPostVo"/>
46 46
 		where post_id = #{postId}
47 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 54
 	<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
50 55
 		select p.post_id

+ 9
- 0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml Visa fil

@@ -131,6 +131,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
131 131
 		<include refid="selectUserVo"/>
132 132
 		where u.user_id = #{userId}
133 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 144
 	<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
136 145
 		select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1