<?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.OrgStandardMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgStandard" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="uid" property="uid" jdbcType="VARCHAR" />
    <result column="standard_name" property="standardName" jdbcType="VARCHAR" />
    <result column="standard_number" property="standardNumber" jdbcType="VARCHAR" />
    <result column="standard_level" property="standardLevel" jdbcType="INTEGER" />
    <result column="participate_way" property="participateWay" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="year" property="year" jdbcType="INTEGER" />
    <result column="enclosure_url" property="enclosureUrl" jdbcType="VARCHAR" />
    <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, standard_name, standard_number, standard_level, participate_way, create_time, year,
    enclosure_url, deleted_sign
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from org_standard
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from org_standard
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrgStandard" >
    insert into org_standard (id, uid, standard_name, 
      standard_number, standard_level, participate_way, create_time, year,
      enclosure_url, deleted_sign
      )
    values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{standardName,jdbcType=VARCHAR}, 
      #{standardNumber,jdbcType=VARCHAR}, #{standardLevel,jdbcType=INTEGER}, #{participateWay,jdbcType=INTEGER},
      #{createTime,jdbcType=TIMESTAMP}, #{year,jdbcType=INTEGER}, #{enclosureUrl,jdbcType=VARCHAR},
      #{deletedSign,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgStandard" >
    insert into org_standard
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="standardName != null" >
        standard_name,
      </if>
      <if test="standardNumber != null" >
        standard_number,
      </if>
      <if test="standardLevel != null" >
        standard_level,
      </if>
      <if test="participateWay != null" >
        participate_way,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      
       <if test="year != null" >
        year,
      </if>
      <if test="enclosureUrl != null" >
        enclosure_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="uid != null" >
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="standardName != null" >
        #{standardName,jdbcType=VARCHAR},
      </if>
      <if test="standardNumber != null" >
        #{standardNumber,jdbcType=VARCHAR},
      </if>
      <if test="standardLevel != null" >
        #{standardLevel,jdbcType=INTEGER},
      </if>
      <if test="participateWay != null" >
        #{participateWay,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      
      <if test="year != null" >
        #{year,jdbcType=INTEGER},
      </if>
      <if test="enclosureUrl != null" >
        #{enclosureUrl,jdbcType=VARCHAR},
      </if>
      
      <if test="deletedSign != null" >
        #{deletedSign,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgStandard" >
    update org_standard
    <set >
      <if test="uid != null" >
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="standardName != null" >
        standard_name = #{standardName,jdbcType=VARCHAR},
      </if>
      <if test="standardNumber != null" >
        standard_number = #{standardNumber,jdbcType=VARCHAR},
      </if>
      <if test="standardLevel != null" >
        standard_level = #{standardLevel,jdbcType=INTEGER},
      </if>
      <if test="participateWay != null" >
        participate_way = #{participateWay,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      
       <if test="year != null" >
        year = #{year,jdbcType=INTEGER},
      </if>
      <if test="enclosureUrl != null" >
        enclosure_url = #{enclosureUrl,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.OrgStandard" >
    update org_standard
    set uid = #{uid,jdbcType=VARCHAR},
      standard_name = #{standardName,jdbcType=VARCHAR},
      standard_number = #{standardNumber,jdbcType=VARCHAR},
      standard_level = #{standardLevel,jdbcType=INTEGER},
      participate_way = #{participateWay,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      year = #{year,jdbcType=INTEGER},
      enclosure_url = #{enclosureUrl,jdbcType=VARCHAR},
      deleted_sign = #{deletedSign,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
   <select id="findOrgStandardListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
    <include refid="Base_Column_List" />
    from org_standard
    where deleted_sign = 0
    <if test="uid != null">
	    and  uid = #{uid,jdbcType=VARCHAR}
	</if>
	<if test="year != null">
	 	and  year = #{year,jdbcType=INTEGER}
	</if>
    <if test="standardName != null">
    	and  standard_name = #{standardName,jdbcType=VARCHAR}
    </if>
    <if test="standardNumber != null">
    	and   standard_number= #{standardNumber,jdbcType=VARCHAR}
    </if>
    <if test="standardLevel != null">
    	and   standard_level= #{standardLevel,jdbcType=INTEGER}
    </if>
    <if test="participateWay != null">
    	and   participate_way= #{participateWay,jdbcType=INTEGER}
    </if>
    order by create_time desc
    <if test="page_sql != null">
    	${page_sql}
    </if>
    
  </select>
  
   <select id="findOrgStandardCount" resultType="java.lang.Integer" parameterType="String">
   	select count(1) 
    from org_standard
    where deleted_sign = 0
    <if test="uid != null">
	    and  uid = #{uid,jdbcType=VARCHAR}
	</if>
	<if test="year != null">
	 	and  year = #{year,jdbcType=INTEGER}
	</if>
    <if test="standardName != null">
    	and  standard_name = #{standardName,jdbcType=VARCHAR}
    </if>
    <if test="standardNumber != null">
    	and   standard_number= #{standardNumber,jdbcType=VARCHAR}
    </if>
    <if test="standardLevel != null">
    	and   standard_level= #{standardLevel,jdbcType=INTEGER}
    </if>
    <if test="participateWay != null">
    	and   participate_way= #{participateWay,jdbcType=INTEGER}
    </if>
    </select>
  
   <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	update org_standard set deleted_sign = 1
  	where  id in 
	<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
		#{item}
	</foreach>
  </update>
</mapper>