Sfoglia il codice sorgente

岗检小组成员

csg6 10 mesi fa
parent
commit
9e9e45c093

+ 1 - 1
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/controller/PostTeamUserController.java

@@ -94,7 +94,7 @@ public class PostTeamUserController extends BaseController {
94 94
     }
95 95
 
96 96
     /**
97
-     * 前端使用使用添加新增,不使用修改,新增接口始终传全量数据
97
+     * 前端使用新增,不使用修改,新增接口始终传全量数据
98 98
      * 修改岗检小组关联成员
99 99
      *
100 100
      @ApiOperation("修改岗检小组关联成员")

+ 20 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/domain/PostTeamUser.java

@@ -47,4 +47,24 @@ public class PostTeamUser extends BaseEntity
47 47
     @Excel(name = "创建者用户ID")
48 48
     private Long createUserId;
49 49
 
50
+    @ApiModelProperty("小组成员姓名")
51
+    @TableField(exist = false)
52
+    private String nickName;
53
+
54
+    @ApiModelProperty("邮箱")
55
+    @TableField(exist = false)
56
+    private String email;
57
+
58
+    @ApiModelProperty("电话")
59
+    @TableField(exist = false)
60
+    private String phonenumber;
61
+
62
+    @ApiModelProperty("部门名称")
63
+    @TableField(exist = false)
64
+    private String deptName;
65
+
66
+    @ApiModelProperty("岗位名称")
67
+    @TableField(exist = false)
68
+    private String postName;
69
+
50 70
 }

+ 14 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/service/impl/PostTeamUserServiceImpl.java

@@ -14,6 +14,7 @@ import com.ruoyi.postCheck.mapper.PostTeamUserMapper;
14 14
 import com.ruoyi.postCheck.domain.PostTeamUser;
15 15
 import com.ruoyi.postCheck.service.IPostTeamUserService;
16 16
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
17
+import org.springframework.transaction.annotation.Transactional;
17 18
 import org.springframework.util.CollectionUtils;
18 19
 
19 20
 /**
@@ -56,6 +57,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
56 57
      * @return 结果
57 58
      */
58 59
     @Override
60
+    @Transactional(rollbackFor = Exception.class)
59 61
     public int insertPostTeamUser(List<PostTeamUser> postTeamUserList) {
60 62
         if (CollectionUtils.isEmpty(postTeamUserList)) {
61 63
             return 0;
@@ -74,6 +76,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
74 76
         //新增用户
75 77
         int count = 0;
76 78
         int index = 0;
79
+        Long postTeamIdLast = null;
77 80
         for (PostTeamUser postTeamUser : postTeamUserList) {
78 81
             //类型(1-组长;2-成员;)
79 82
             if (index++ == 0) {
@@ -86,6 +89,16 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
86 89
                 throw new BaseException("postTeamId为空,请检查!");
87 90
             }
88 91
 
92
+            if (postTeamIdLast != null && !postTeamIdLast.equals(postTeamId)) {
93
+                throw new BaseException("postTeamId出现多个值,不允许多个小组混合添加成员,请检查!");
94
+            }
95
+            postTeamIdLast = postTeamId;
96
+
97
+            Long userId = postTeamUser.getUserId();
98
+            if (userId == null) {
99
+                throw new BaseException("userId为空,请检查!");
100
+            }
101
+
89 102
             //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
90 103
 //        if (postTeamUser.getId() == null)
91 104
             postTeamUser.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
@@ -143,6 +156,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
143 156
 //        return postTeamUserMapper.updatePostTeamUser(postTeamUser);
144 157
     }
145 158
 */
159
+
146 160
     /**
147 161
      * 批量删除岗检小组关联成员
148 162
      *

+ 35 - 7
ruoyi-postcheck/src/main/resources/mapper/postCheck/PostTeamUserMapper.xml

@@ -3,7 +3,7 @@
3 3
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 4
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 5
 <mapper namespace="com.ruoyi.postCheck.mapper.PostTeamUserMapper">
6
-    
6
+
7 7
     <resultMap type="PostTeamUser" id="PostTeamUserResult">
8 8
         <result property="id"    column="id"    />
9 9
         <result property="postTeamId"    column="post_team_id"    />
@@ -16,27 +16,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
16 16
         <result property="updateTime"    column="update_time"    />
17 17
         <result property="updateBy"    column="update_by"    />
18 18
         <result property="createUserId"    column="create_user_id"    />
19
+
20
+        <result property="nickName"    column="nick_name"    />
21
+        <result property="email"    column="email"/>
22
+        <result property="phonenumber"    column="phonenumber"/>
23
+        <result property="deptName"    column="dept_name"/>
24
+        <result property="postName"    column="post_name"/>
19 25
     </resultMap>
20 26
 
21 27
     <sql id="selectPostTeamUserVo">
22
-        select id, post_team_id, user_id, type, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id from post_team_user
28
+        select
29
+            t1.id,
30
+            t1.post_team_id,
31
+            t1.user_id,
32
+            t1.type,
33
+            t1.remark,
34
+            t1.del_flag,
35
+            t1.create_time,
36
+            t1.create_by,
37
+            t1.update_time,
38
+            t1.update_by,
39
+            t1.create_user_id,
40
+            t2.nick_name,
41
+            t2."email" ,
42
+            t2."phonenumber" ,
43
+            t3."dept_name" ,
44
+            t5."post_name"
45
+        from post_team_user t1
46
+        left join public.sys_users t2 on t2.user_id = t1.user_id
47
+        LEFT JOIN "sys_dept" t3 ON t3."dept_id" = t2."dept_id"
48
+        LEFT JOIN "sys_user_post" t4 ON t4."user_id" = t2."user_id"
49
+        LEFT JOIN "sys_post" t5 ON t5."post_id" = t4."post_id"
23 50
     </sql>
24 51
 
25 52
     <select id="selectPostTeamUserList" parameterType="PostTeamUser" resultMap="PostTeamUserResult">
26 53
         <include refid="selectPostTeamUserVo"/>
27
-        <where>  
54
+        <where>
28 55
             <if test="postTeamId != null  and postTeamId != ''"> and post_team_id = #{postTeamId}</if>
29 56
             <if test="userId != null "> and user_id = #{userId}</if>
30 57
             <if test="type != null "> and type = #{type}</if>
31 58
             <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
32 59
         </where>
60
+        GROUP BY t1."id"
33 61
     </select>
34
-    
62
+
35 63
     <select id="selectPostTeamUserById" parameterType="Long" resultMap="PostTeamUserResult">
36 64
         <include refid="selectPostTeamUserVo"/>
37 65
         where id = #{id}
38 66
     </select>
39
-        
67
+
40 68
     <insert id="insertPostTeamUser" parameterType="PostTeamUser">
41 69
         insert into post_team_user
42 70
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -89,9 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
89 117
     </delete>
90 118
 
91 119
     <delete id="deletePostTeamUserByIds" parameterType="String">
92
-        delete from post_team_user where id in 
120
+        delete from post_team_user where id in
93 121
         <foreach item="id" collection="array" open="(" separator="," close=")">
94 122
             #{id}
95 123
         </foreach>
96 124
     </delete>
97
-</mapper>
125
+</mapper>