<?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.goafanti.common.dao.OrgTechCenterDetailMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgTechCenterDetail" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="cid" property="cid" jdbcType="VARCHAR" />
    <result column="project_time" property="projectTime" jdbcType="TIMESTAMP" />
    <result column="project_name" property="projectName" jdbcType="VARCHAR" />
    <result column="term_start_time" property="termStartTime" jdbcType="TIMESTAMP" />
    <result column="term_end_time" property="termEndTime" jdbcType="TIMESTAMP" />
    <result column="institution" property="institution" jdbcType="VARCHAR" />
    <result column="protocol_url" property="protocolUrl" jdbcType="VARCHAR" />
    <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, cid, project_time, project_name, term_start_time, term_end_time, institution, protocol_url, deleted_sign
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from org_tech_center_detail
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from org_tech_center_detail
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrgTechCenterDetail" >
    insert into org_tech_center_detail (id, cid, project_time, 
      project_name, term_start_time, term_end_time, institution, 
      protocol_url, deleted_sign)
    values (#{id,jdbcType=VARCHAR}, #{cid,jdbcType=VARCHAR}, #{projectTime,jdbcType=TIMESTAMP}, 
      #{projectName,jdbcType=VARCHAR}, #{termStartTime,jdbcType=TIMESTAMP}, #{termEndTime,jdbcType=TIMESTAMP},
      #{institution,jdbcType=VARCHAR}, 
      #{protocolUrl,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgTechCenterDetail" >
    insert into org_tech_center_detail
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="cid != null" >
        cid,
      </if>
      <if test="projectTime != null" >
        project_time,
      </if>
      <if test="projectName != null" >
        project_name,
      </if>
      <if test="termStartTime != null" >
        term_start_time,
      </if>
      <if test="termEndTime != null" >
        term_end_time,
      </if>
      <if test="institution != null" >
        institution,
      </if>
      <if test="protocolUrl != null" >
        protocol_url,
      </if>
      <if test="deletedSign != null" >
        deleted_sign,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="cid != null" >
        #{cid,jdbcType=VARCHAR},
      </if>
      <if test="projectTime != null" >
        #{projectTime,jdbcType=TIMESTAMP},
      </if>
      <if test="projectName != null" >
        #{projectName,jdbcType=VARCHAR},
      </if>
      <if test="termStartTime != null" >
        #{termStartTime,jdbcType=TIMESTAMP},
      </if>
       <if test="termEndTime != null" >
        #{termEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="institution != null" >
        #{institution,jdbcType=VARCHAR},
      </if>
      <if test="protocolUrl != null" >
        #{protocolUrl,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        #{deletedSign,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgTechCenterDetail" >
    update org_tech_center_detail
    <set >
      <if test="cid != null" >
        cid = #{cid,jdbcType=VARCHAR},
      </if>
      <if test="projectTime != null" >
        project_time = #{projectTime,jdbcType=TIMESTAMP},
      </if>
      <if test="projectName != null" >
        project_name = #{projectName,jdbcType=VARCHAR},
      </if>
      <if test="termStartTime != null" >
        term_start_time = #{termStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="termEndTime != null" >
        term_end_time = #{termEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="institution != null" >
        institution = #{institution,jdbcType=VARCHAR},
      </if>
      <if test="protocolUrl != null" >
        protocol_url = #{protocolUrl,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        deleted_sign = #{deletedSign,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgTechCenterDetail" >
    update org_tech_center_detail
    set cid = #{cid,jdbcType=VARCHAR},
      project_time = #{projectTime,jdbcType=TIMESTAMP},
      project_name = #{projectName,jdbcType=VARCHAR},
      term_start_time = #{termStartTime,jdbcType=TIMESTAMP},
      term_end_time = #{termEndTime,jdbcType=TIMESTAMP},
      institution = #{institution,jdbcType=VARCHAR},
      protocol_url = #{protocolUrl,jdbcType=VARCHAR},
      deleted_sign = #{deletedSign,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
   <select id="findOrgTechCenterDetailListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
     d.id, d.cid, d.project_time , d.project_name , d.term_start_time, d.term_end_time,
      d.institution, d.protocol_url , d.deleted_sign
    from org_tech_center_detail d 
    where d.deleted_sign = 0 and d.cid = #{cid,jdbcType=VARCHAR}
	order by d.project_time desc
    <if test="page_sql != null">
    	${page_sql}
    </if>
  </select>
  
  <select id="findOrgTechCenterDetailCount" resultType="java.lang.Integer" parameterType="String">
   	select count(1) 
	   from org_tech_center_detail d 
    where d.deleted_sign = 0 and d.cid = #{cid,jdbcType=VARCHAR}
  </select>
  
  <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	update org_tech_center_detail set deleted_sign = 1
  	where  id in 
	<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
		#{item}
	</foreach>
  </update>
</mapper>