anderx %!s(int64=2) %!d(string=hai) anos
pai
achega
f9b04e28fe

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/project/domain/ProjectTask.java

@@ -43,6 +43,11 @@ public class ProjectTask implements Serializable {
      */
     private String adminName;
 
+    /**
+     * 成员名称
+     */
+    private String staffName;
+
     private static final long serialVersionUID = 1L;
 
     public Long getId() {
@@ -100,4 +105,12 @@ public class ProjectTask implements Serializable {
     public void setAdminName(String adminName) {
         this.adminName = adminName;
     }
+
+    public String getStaffName() {
+        return staffName;
+    }
+
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
 }

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/project/mapper/ProjectTaskMapper.java

@@ -14,4 +14,6 @@ public interface ProjectTaskMapper {
     int updateByPrimaryKeySelective(ProjectTask record);
 
     int updateByPrimaryKey(ProjectTask record);
-}
+
+    void updateStaffName(Long pid);
+}

+ 6 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.service.impl;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.project.domain.ProjectStaff;
 import com.ruoyi.project.mapper.ProjectStaffMapper;
+import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectStaffService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -11,11 +12,13 @@ import org.springframework.stereotype.Service;
 public class ProjectStaffServiceImpl implements ProjectStaffService {
     @Autowired
     private ProjectStaffMapper projectStaffMapper;
-
+    @Autowired
+    private ProjectTaskMapper projectTaskMapper;
     @Override
     public AjaxResult addStaff(ProjectStaff in) {
-
-        return AjaxResult.success(projectStaffMapper.insertSelective(in));
+        int i = projectStaffMapper.insertSelective(in);
+        projectTaskMapper.updateStaffName(in.getPid());
+        return AjaxResult.success();
     }
 
     @Override

+ 26 - 10
ruoyi-system/src/main/resources/mapper/project/ProjectTaskMapper.xml

@@ -9,12 +9,13 @@
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
     <result column="admin_name" jdbcType="VARCHAR" property="adminName" />
+    <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, aid, `name`, project_status, create_time, remark, admin_name
+    id, aid, `name`, project_status, create_time, remark, admin_name, staff_name
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    select 
+    select
     <include refid="Base_Column_List" />
     from project_task
     where id = #{id,jdbcType=BIGINT}
@@ -24,12 +25,12 @@
     where id = #{id,jdbcType=BIGINT}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
-    insert into project_task (aid, `name`, project_status, 
-      create_time, remark, admin_name
-      )
-    values (#{aid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{projectStatus,jdbcType=INTEGER}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{adminName,jdbcType=VARCHAR}
-      )
+    insert into project_task (aid, `name`, project_status,
+      create_time, remark, admin_name,
+      staff_name)
+    values (#{aid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{projectStatus,jdbcType=INTEGER},
+      #{createTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{adminName,jdbcType=VARCHAR},
+      #{staffName,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
     insert into project_task
@@ -52,6 +53,9 @@
       <if test="adminName != null">
         admin_name,
       </if>
+      <if test="staffName != null">
+        staff_name,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="aid != null">
@@ -72,6 +76,9 @@
       <if test="adminName != null">
         #{adminName,jdbcType=VARCHAR},
       </if>
+      <if test="staffName != null">
+        #{staffName,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.project.domain.ProjectTask">
@@ -95,6 +102,9 @@
       <if test="adminName != null">
         admin_name = #{adminName,jdbcType=VARCHAR},
       </if>
+      <if test="staffName != null">
+        staff_name = #{staffName,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -105,7 +115,13 @@
       project_status = #{projectStatus,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       remark = #{remark,jdbcType=VARCHAR},
-      admin_name = #{adminName,jdbcType=VARCHAR}
+      admin_name = #{adminName,jdbcType=VARCHAR},
+      staff_name = #{staffName,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
-</mapper>
+  <update id="updateStaffName">
+    update project_task a left join (select pid ,group_concat(name)name from project_staff
+        where pid = #{pid} group by  pid) b on a.id=b.pid set a.staff_name =b.name
+    where a.id = #{pid}
+  </update>
+</mapper>