pms-server/pms-business/src/main/resources/mapper/business/ProjectTeam/ProjectTeamMapper.xml

176 lines
6.4 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="tech.unissense.pms.business.projectteam.mapper.ProjectTeamMapper">
<resultMap type="tech.unissense.pms.business.projectteam.domain.ProjectTeam" id="ProjectTeamMap">
<result property="projectId" column="project_id" jdbcType="INTEGER"/>
<result property="teamId" column="team_id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="userName" column="user_name" jdbcType="INTEGER"/>
<result property="postId" column="post_id" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="base_query">
select project_id,
team_id,
user_id,
post_id,
create_by,
update_by,
update_time,
create_time
from pms_project_team
</sql>
<!--查询单个-->
<select id="queryById" resultMap="ProjectTeamMap">
select project_id,
team_id,
user_id,
post_id,
create_by,
update_by,
update_time,
create_time
from pms_project_team
where team_id = #{teamId}
</select>
<!--查询指定行数据-->
<select id="list" resultMap="ProjectTeamMap">
select
t1.project_id, t1.team_id, t1.user_id, t1.post_id, t1.create_by, t1.update_by, t1.update_time, t1.create_time,
t2.nick_name as user_name
from pms_project_team t1
left join sys_user t2 on t1.user_id=t2.user_id
<where>
<if test="projectId != null">
and project_id = #{projectId}
</if>
<if test="teamId != null">
and team_id = #{teamId}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="postId != null and postId != ''">
and post_id = #{postId}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
</where>
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from pms_project_team
<where>
<if test="projectId != null">
and project_id = #{projectId}
</if>
<if test="teamId != null">
and team_id = #{teamId}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="postId != null and postId != ''">
and post_id = #{postId}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="teamId" useGeneratedKeys="true">
insert into pms_project_team(project_id, user_id, post_id, create_by, update_by, update_time, create_time)
values (#{projectId}, #{userId}, #{postId}, #{createBy}, #{updateBy}, #{updateTime}, #{createTime})
</insert>
<insert id="insertBatch" keyProperty="teamId" useGeneratedKeys="true">
insert into pms_project_team(project_id, user_id, post_id, create_by, update_by, update_time, create_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.projectId}, #{entity.userId}, #{entity.postId}, #{entity.createBy}, #{entity.updateBy},
#{entity.updateTime}, #{entity.createTime})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="teamId" useGeneratedKeys="true">
insert into pms_project_team(project_id, user_id, post_id, create_by, update_by, update_time, create_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.projectId}, #{entity.userId}, #{entity.postId}, #{entity.createBy}, #{entity.updateBy},
#{entity.updateTime}, #{entity.createTime})
</foreach>
on duplicate key update
project_id = values(project_id),
user_id = values(user_id),
post_id = values(post_id),
update_by = values(update_by),
update_time = values(update_time),
</insert>
<!--通过主键修改数据-->
<update id="update">
update pms_project_team
<set>
<if test="projectId != null">
project_id = #{projectId},
</if>
<if test="userId != null">
user_id = #{userId},
</if>
<if test="postId != null and postId != ''">
post_id = #{postId},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
where team_id = #{teamId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from pms_project_team
where team_id = #{teamId}
</delete>
</mapper>