Browse Source

生成产品项目关联关系表

生成迭代与产品关联关系表
master
陈裕财 5 years ago
parent
commit
282b61e158
  1. 11
      xm-core/src/main/java/com/xm/core/entity/XmProductProjectLink.java
  2. 44
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmIterationMapper.xml
  3. 22
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml
  4. 21
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductProjectLinkMapper.xml
  5. 14
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml

11
xm-core/src/main/java/com/xm/core/entity/XmProductProjectLink.java

@ -11,7 +11,7 @@ import java.util.Date;
* XM.xm_product_project_link 产品与项目的关联关系表一般由产品经理挂接项目到产品上的所有字段名: <br> * XM.xm_product_project_link 产品与项目的关联关系表一般由产品经理挂接项目到产品上的所有字段名: <br>
* project_id,product_id,ctime,cuserid,cusername,link_status;<br> * project_id,product_id,ctime,cuserid,cusername,link_status;<br>
* 当前主键(包括多主键):<br> * 当前主键(包括多主键):<br>
* project_id;<br>
* project_id,product_id;<br>
*/ */
@ApiModel(description="产品与项目的关联关系表,一般由产品经理挂接项目到产品上") @ApiModel(description="产品与项目的关联关系表,一般由产品经理挂接项目到产品上")
public class XmProductProjectLink implements java.io.Serializable { public class XmProductProjectLink implements java.io.Serializable {
@ -20,10 +20,10 @@ public class XmProductProjectLink implements java.io.Serializable {
@ApiModelProperty(notes="项目表中的主键,主键",allowEmptyValue=true,example="",allowableValues="") @ApiModelProperty(notes="项目表中的主键,主键",allowEmptyValue=true,example="",allowableValues="")
String projectId; String projectId;
@ApiModelProperty(notes="产品表中的主键",allowEmptyValue=true,example="",allowableValues="")
@ApiModelProperty(notes="产品表中的主键,主键",allowEmptyValue=true,example="",allowableValues="")
String productId; String productId;
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") @ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="")
Date ctime; Date ctime;
@ -37,9 +37,10 @@ public class XmProductProjectLink implements java.io.Serializable {
@ApiModelProperty(notes="关联状态1关联0取消关联",allowEmptyValue=true,example="",allowableValues="") @ApiModelProperty(notes="关联状态1关联0取消关联",allowEmptyValue=true,example="",allowableValues="")
String linkStatus; String linkStatus;
/**项目表中的主键**/
public XmProductProjectLink(String projectId) {
/**项目表中的主键,产品表中的主键**/
public XmProductProjectLink(String projectId,String productId) {
this.projectId = projectId; this.projectId = projectId;
this.productId = productId;
} }
/**产品与项目的关联关系表,一般由产品经理挂接项目到产品上**/ /**产品与项目的关联关系表,一般由产品经理挂接项目到产品上**/

44
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmIterationMapper.xml

@ -24,15 +24,22 @@
<if test=" onlineTimeStart !=null "> and res.online_time &gt; #{onlineTimeStart} </if> <if test=" onlineTimeStart !=null "> and res.online_time &gt; #{onlineTimeStart} </if>
<if test=" onlineTimeEnd !=null "> and res.online_time &lt; #{onlineTimeEnd} </if> <if test=" onlineTimeEnd !=null "> and res.online_time &lt; #{onlineTimeEnd} </if>
<include refid="where"/> <include refid="where"/>
<if test="( productId != null and productId !='') or ( menuId != null and menuId !='')">
and exists ( select 1 from XM.xm_iteration_menu im where im.iteration_id=res.id
<if test=" ( menuId != null and menuId !='')">
and exists ( select 1 from XM.xm_iteration_menu im where im.iteration_id=res.id and im.menu_id=#{menuId}
<if test="productId != null and productId !='' "> and im.product_id=#{productId} </if> <if test="productId != null and productId !='' "> and im.product_id=#{productId} </if>
<if test="menuId != null and menuId !='' "> and im.menu_id=#{menuId} </if>
) )
</if> </if>
<if test="( productId != null and productId !='') and ( menuId == null or menuId =='') and ( projectId ==null or projectId=='' ) ">
and exists ( select 1 from xm_iteration_product_link ipl
where ipl.iteration_id=res.id and ipl.product_id=#{productId}
)
</if>
<if test=" projectId !=null and projectId!=''"> <if test=" projectId !=null and projectId!=''">
and exists( select 1 from XM.xm_task t inner join xm_iteration_menu im on t.menu_id=im.menu_id
where t.project_id=#{projectId} and im.iteration_id =res.id
and exists( select 1 from XM.xm_iteration_product_link ipl inner join XM.xm_product_project_link ppl
on ipl.product_id=ppl.product_id
where ppl.project_id=#{projectId} and ipl.iteration_id =res.id
<if test=" productId != null and productId !='' "> and ipl.product_id=#{productId}</if>
) )
</if> </if>
<if test="compete !=null and compete!=''"> <if test="compete !=null and compete!=''">
@ -58,14 +65,29 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test=" createTimeStart !=null "> and res.ctime &gt; #{createTimeStart} </if>
<if test=" createTimeEnd !=null "> and res.ctime &lt; #{createTimeEnd} </if>
<if test=" onlineTimeStart !=null "> and res.online_time &gt; #{onlineTimeStart} </if>
<if test=" onlineTimeEnd !=null "> and res.online_time &lt; #{onlineTimeEnd} </if>
<include refid="where"/> <include refid="where"/>
<if test=" ( menuId != null and menuId !='')">
and exists ( select 1 from XM.xm_iteration_menu im where im.iteration_id=res.id and im.menu_id=#{menuId}
<if test="productId != null and productId !='' "> and im.product_id=#{productId} </if>
)
</if>
<if test="( productId != null and productId !='') or ( menuId != null and menuId !='')">
and exists ( select 1 from XM.xm_iteration_menu im where im.iteration_id=res.id
<if test="productId != null and productId !='' "> and im.product_id=#{productId} </if>
<if test="menuId != null and menuId !='' "> and im.menu_id=#{menuId} </if>
)
</if>
<if test="( productId != null and productId !='') and ( menuId == null or menuId =='') and ( projectId ==null or projectId=='' ) ">
and exists ( select 1 from xm_iteration_product_link ipl
where ipl.iteration_id=res.id and ipl.product_id=#{productId}
)
</if>
<if test=" projectId !=null and projectId!=''">
and exists( select 1 from XM.xm_iteration_product_link ipl inner join XM.xm_product_project_link ppl
on ipl.product_id=ppl.product_id
where ppl.project_id=#{projectId} and ipl.iteration_id =res.id
<if test=" productId != null and productId !='' "> and ipl.product_id=#{productId}</if>
)
</if>
<if test="compete !=null and compete!=''"> <if test="compete !=null and compete!=''">
and ( res.admin_userid=#{compete} and ( res.admin_userid=#{compete}
or exists (select 1 from XM.xm_iteration_menu im left join xm.xm_menu m on im.product_id=m.product_id where m.mm_userid=#{compete} and im.iteration_id=res.id) or exists (select 1 from XM.xm_iteration_menu im left join xm.xm_menu m on im.product_id=m.product_id where m.mm_userid=#{compete} and im.iteration_id=res.id)

22
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml

@ -16,16 +16,20 @@
</foreach> </foreach>
</if> </if>
<include refid="where"/> <include refid="where"/>
<if test="projectId != null and projectId !='' "> and exists (select 1 from XM.xm_task t left join XM.xm_menu m on t.menu_id=m.menu_id and t.project_id=#{projectId} where t.project_id=#{projectId} and m.product_id=res.id) </if>
<if test="compete !=null and compete!=''">
<if test=" projectId !=null and projectId!=''">
and exists( select 1 from XM.xm_product_project_link ppl
where ppl.project_id=#{projectId} and ppl.product_id=res.id
)
</if>
<if test="iterationId!=null and iterationId!=''">
and exists( select 1 from xm_iteration_product_link ipl where ipl.product_id =res.id and ipl.iteration_id=#{iterationId} )
</if>
<if test="compete !=null and compete!=''">
and ( exists ( select 1 from xm_project_group_user gu inner join XM.xm_task t on gu.project_id=t.project_id and t.product_id=res.id where gu.userid=#{compete} and t.product_id=res.id ) and ( exists ( select 1 from xm_project_group_user gu inner join XM.xm_task t on gu.project_id=t.project_id and t.product_id=res.id where gu.userid=#{compete} and t.product_id=res.id )
or res.pm_userid=#{compete} or res.pm_userid=#{compete}
or exists ( select 1 from xm_menu m where m.mm_userid=#{compete} and m.product_id=res.id) or exists ( select 1 from xm_menu m where m.mm_userid=#{compete} and m.product_id=res.id)
) )
</if> </if>
<if test="iterationId!=null and iterationId!=''">
and exists( select 1 from xm_iteration_menu im where im.product_id =res.id and im.iteration_id=#{iterationId} )
</if>
<if test="key != null and key !='' "> and res.product_name like #{key} </if> <if test="key != null and key !='' "> and res.product_name like #{key} </if>
</where> </where>
</select> </select>
@ -46,8 +50,12 @@
</if> </if>
<include refid="where"/> <include refid="where"/>
<if test="key != null and key !='' "> and res.product_name like #{key} </if> <if test="key != null and key !='' "> and res.product_name like #{key} </if>
<if test="projectId != null and projectId !='' "> and exists (select 1 from XM.xm_task t left join XM.xm_menu m on t.menu_id=m.menu_id and t.project_id=#{projectId} where t.project_id=#{projectId} and m.product_id=res.id) </if>
<if test="compete !=null and compete!=''">
<if test=" projectId !=null and projectId!=''">
and exists( select 1 from XM.xm_product_project_link ppl
where ppl.project_id=#{projectId} and ppl.product_id=res.id
)
</if>
<if test="compete !=null and compete!=''">
and ( exists ( select 1 from xm_project_group_user gu inner join XM.xm_task t on gu.project_id=t.project_id and t.product_id=res.id where gu.userid=#{compete} and t.product_id=res.id ) and ( exists ( select 1 from xm_project_group_user gu inner join XM.xm_task t on gu.project_id=t.project_id and t.product_id=res.id where gu.userid=#{compete} and t.product_id=res.id )
or res.pm_userid=#{compete} or res.pm_userid=#{compete}
or exists ( select 1 from xm_menu m where m.mm_userid=#{compete} and m.product_id=res.id) or exists ( select 1 from xm_menu m where m.mm_userid=#{compete} and m.product_id=res.id)

21
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductProjectLinkMapper.xml

@ -40,6 +40,7 @@
select * from XM.xm_product_project_link res select * from XM.xm_product_project_link res
where where
res.project_id = #{projectId} res.project_id = #{projectId}
and res.product_id = #{productId}
</select> </select>
<!-- 通过主键查询获取数据对象 返回map--> <!-- 通过主键查询获取数据对象 返回map-->
@ -47,6 +48,7 @@
select * from XM.xm_product_project_link res select * from XM.xm_product_project_link res
where where
res.project_id = #{projectId} res.project_id = #{projectId}
and res.product_id = #{productId}
</select> </select>
<!-- 获取数据条目 返回long --> <!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmProductProjectLink" resultType="long"> <select id="countByWhere" parameterType="com.xm.core.entity.XmProductProjectLink" resultType="long">
@ -55,8 +57,8 @@
<include refid="where"/> <include refid="where"/>
</where> </where>
</select> </select>
<!-- 新增一条记录 主键project_id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmProductProjectLink" useGeneratedKeys="false" keyProperty="project_id">
<!-- 新增一条记录 主键project_id,product_id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmProductProjectLink" useGeneratedKeys="false" >
insert into XM.xm_product_project_link( insert into XM.xm_product_project_link(
<include refid="columns"/> <include refid="columns"/>
) values ( ) values (
@ -75,7 +77,7 @@
<!-- 按主键删除一条记录--> <!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmProductProjectLink"> <delete id="deleteByPk" parameterType="com.xm.core.entity.XmProductProjectLink">
delete from XM.xm_product_project_link delete from XM.xm_product_project_link
where project_id = #{projectId}
where project_id = #{projectId} and product_id = #{productId}
</delete> </delete>
<!-- 根据条件修改若干条记录 --> <!-- 根据条件修改若干条记录 -->
@ -84,7 +86,7 @@
<set> <set>
<include refid="someFieldSet"/> <include refid="someFieldSet"/>
</set> </set>
where project_id = #{projectId}
where project_id = #{projectId} and product_id = #{productId}
</update> </update>
<!-- 根据主键修改一条记录 --> <!-- 根据主键修改一条记录 -->
@ -93,7 +95,7 @@
<set> <set>
<include refid="set"/> <include refid="set"/>
</set> </set>
where project_id = #{projectId}
where project_id = #{projectId} and product_id = #{productId}
</update> </update>
<!-- 批量新增 批量插入 借用insert 循环插入实现 <!-- 批量新增 批量插入 借用insert 循环插入实现
@ -107,17 +109,17 @@
update XM.xm_product_project_link update XM.xm_product_project_link
set set
<include refid="batchSet"/> <include refid="batchSet"/>
where project_id = #{item.projectId}
where project_id = #{item.projectId} and product_id = #{item.productId}
</foreach> </foreach>
</update> </update>
<!-- 批量删除 --> <!-- 批量删除 -->
<delete id="batchDelete" parameterType="List"> <delete id="batchDelete" parameterType="List">
delete from XM.xm_product_project_link delete from XM.xm_product_project_link
where where
(project_id)
(project_id, product_id)
in in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > <foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.projectId}
( #{item.projectId}, #{item.productId}
) )
</foreach> </foreach>
</delete> </delete>
@ -139,14 +141,12 @@
</sql> </sql>
<!--sql片段 更新字段 --> <!--sql片段 更新字段 -->
<sql id="set"> <sql id="set">
product_id = #{productId},
ctime = #{ctime}, ctime = #{ctime},
cuserid = #{cuserid}, cuserid = #{cuserid},
cusername = #{cusername}, cusername = #{cusername},
link_status = #{linkStatus} link_status = #{linkStatus}
</sql> </sql>
<sql id="someFieldSet"> <sql id="someFieldSet">
<if test="productId != null and productId != ''"> product_id = #{productId}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if> <if test="ctime != null"> ctime = #{ctime}, </if>
<if test="cuserid != null and cuserid != ''"> cuserid = #{cuserid}, </if> <if test="cuserid != null and cuserid != ''"> cuserid = #{cuserid}, </if>
<if test="cusername != null and cusername != ''"> cusername = #{cusername}, </if> <if test="cusername != null and cusername != ''"> cusername = #{cusername}, </if>
@ -154,7 +154,6 @@
</sql> </sql>
<!--sql片段 批量更新 --> <!--sql片段 批量更新 -->
<sql id="batchSet"> <sql id="batchSet">
product_id = #{item.productId},
ctime = #{item.ctime}, ctime = #{item.ctime},
cuserid = #{item.cuserid}, cuserid = #{item.cuserid},
cusername = #{item.cusername}, cusername = #{item.cusername},

14
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml

@ -115,15 +115,15 @@
<if test="myFocus != null and myFocus != ''"> <if test="myFocus != null and myFocus != ''">
and exists ( select 1 from XM.xm_my_focus f where f.userid=#{userid} and f.project_id=res.id ) and exists ( select 1 from XM.xm_my_focus f where f.userid=#{userid} and f.project_id=res.id )
</if> </if>
<if test="productId != null and productId !='' ">
and exists ( select 1 from XM.xm_task t left join XM.xm_menu m on t.menu_id=m.menu_id and m.product_id=#{productId}
where m.product_id=#{productId} and t.project_id=res.id
<if test=" productId !=null and productId!='' ">
and exists( select 1 from XM.xm_product_project_link ppl
where ppl.product_id=#{productId} and ppl.project_id=res.id
) )
</if> </if>
<if test="(iterationId!=null and iterationId!='' )">
and exists( select 1 from XM.xm_task t inner join xm_iteration_menu im on t.menu_id=im.menu_id
where t.project_id=res.id and im.iteration_id =#{iterationId}
<if test="iterationId!=null and iterationId!=''">
and exists( select 1 from xm_iteration_product_link ipl inner join xm_product_project ppl
on ipl.product_id=ppl.product_id
where ipl.product_id =res.id and ipl.iteration_id=#{iterationId}
) )
</if> </if>
<if test="key != null and key !='' "> and res.name like #{key} </if> <if test="key != null and key !='' "> and res.name like #{key} </if>

Loading…
Cancel
Save