<?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="com.nbclass.szxgl.mapper.ProjectTaskUserMapper">
  <resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ProjectTaskUser">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="CHAR" property="id" />
    <result column="_project_id" jdbcType="CHAR" property="projectId" />
    <result column="_project_task_id" jdbcType="CHAR" property="projectTaskId" />
    <result column="_user_id" jdbcType="CHAR" property="userId" />
    <result column="_create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="_update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  
	<select id="selectProjectTaskUser" resultType="java.lang.Integer">
  		select count(*) from project_task_user where _project_task_id = #{taskId} and _user_id = #{userid}
	</select>

    <delete id="deleteByTaskId" parameterType="java.lang.String">
        delete from project_task_user where _project_task_id = #{projectTaskId}
    </delete>

    <delete id="deleteByProjectId" parameterType="java.lang.String">
		delete from project_task_user where _project_id = #{projectId}
	</delete>

    <select id="selectProjectTaskUserList" resultType="com.nbclass.szxgl.model.ProjectTaskUser">
  	select * from project_task_user where _project_task_id=#{projectTaskId}
    </select>

    <select id="selectUserIds" resultType="java.lang.String">
  	select _user_id from project_task_user where _project_task_id=#{projectTaskId}
    </select>

    <insert id="insertOrUpdate" parameterType="com.nbclass.szxgl.model.ProjectTaskUser">
    INSERT INTO project_task_user
    (
    id,
    _project_id,
    _project_task_id,
    _user_id,
    _create_time
    )
    VALUES
    (
    #{id},
    #{projectId},
    #{projectTaskId},
    #{userId},
    #{createTime}
    )
    ON DUPLICATE KEY UPDATE _project_id = #{projectId}, _project_task_id = #{projectTaskId}, _user_id = #{userId}, _update_time = #{updateTime}
</insert>

</mapper>