Browse Source

生成产品项目关联关系表

生成迭代与产品关联关系表
master
陈裕财 5 years ago
parent
commit
282b61e158
  1. 11
      xm-core/src/main/java/com/xm/core/entity/XmProductProjectLink.java
  2. 40
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmIterationMapper.xml
  3. 18
      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. 12
      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>
* project_id,product_id,ctime,cuserid,cusername,link_status;<br>
* 当前主键(包括多主键):<br>
* project_id;<br>
* project_id,product_id;<br>
*/
@ApiModel(description="产品与项目的关联关系表,一般由产品经理挂接项目到产品上")
public class XmProductProjectLink implements java.io.Serializable {
@ -21,10 +21,10 @@ public class XmProductProjectLink implements java.io.Serializable {
@ApiModelProperty(notes="项目表中的主键,主键",allowEmptyValue=true,example="",allowableValues="")
String projectId;
@ApiModelProperty(notes="产品表中的主键",allowEmptyValue=true,example="",allowableValues="")
@ApiModelProperty(notes="产品表中的主键,主键",allowEmptyValue=true,example="",allowableValues="")
String productId;
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="")
Date ctime;
@ -37,9 +37,10 @@ public class XmProductProjectLink implements java.io.Serializable {
@ApiModelProperty(notes="关联状态1关联0取消关联",allowEmptyValue=true,example="",allowableValues="")
String linkStatus;
/**项目表中的主键**/
public XmProductProjectLink(String projectId) {
/**项目表中的主键,产品表中的主键**/
public XmProductProjectLink(String projectId,String productId) {
this.projectId = projectId;
this.productId = productId;
}
/**产品与项目的关联关系表,一般由产品经理挂接项目到产品上**/

40
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=" onlineTimeEnd !=null "> and res.online_time &lt; #{onlineTimeEnd} </if>
<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="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_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 test="compete !=null and compete!=''">
@ -58,12 +65,27 @@
#{item}
</foreach>
</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"/>
<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="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!=''">

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

@ -16,16 +16,20 @@
</foreach>
</if>
<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=" 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 )
or res.pm_userid=#{compete}
or exists ( select 1 from xm_menu m where m.mm_userid=#{compete} and m.product_id=res.id)
)
</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>
</where>
</select>
@ -46,7 +50,11 @@
</if>
<include refid="where"/>
<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=" 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 )
or res.pm_userid=#{compete}

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

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

@ -116,14 +116,14 @@
and exists ( select 1 from XM.xm_my_focus f where f.userid=#{userid} and f.project_id=res.id )
</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
and exists( select 1 from XM.xm_product_project_link ppl
where ppl.product_id=#{productId} and ppl.project_id=res.id
)
</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 test="key != null and key !='' "> and res.name like #{key} </if>

Loading…
Cancel
Save