<?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.ProjectUserMapper">
  <resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ProjectUser">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="CHAR" property="id" />
    <result column="_project_id" jdbcType="CHAR" property="projectId" />
    <result column="_type" jdbcType="TINYINT" property="type" />
    <result column="_table_id" jdbcType="CHAR" property="tableId" />
    <result column="_create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="_update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  
  <select id="selectProjectUser" resultType="java.lang.Integer">
  	select count(*) from project_user where _project_id = #{pid} and _type = 1 and _table_id = #{username}
  </select>
  
  <select id="selectProjectUserList" resultType="com.nbclass.szxgl.model.ProjectUser">
  	select * from project_user where _project_id=#{projectId} 
  </select>
  
  <insert id="insertOrUpdate" parameterType="com.nbclass.szxgl.model.ProjectUser">
    INSERT INTO project_user
    (
    id,
    _project_id,
    _type,
    _table_id,
    _create_time
    )
    VALUES
    (
    #{id},
    #{projectId},
    #{type},
    #{tableId},
    #{createTime}
    )
    ON DUPLICATE KEY UPDATE _project_id = #{projectId}, _type = #{type}, _table_id = #{tableId}, _update_time = #{updateTime}
</insert>

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