<?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.hzya.frame.plugin.lets.dao.impl.BdPurorgDaoImpl">

    <resultMap id="get-BdPurorgEntity-result" type="com.hzya.frame.plugin.lets.entity.BdPurorgEntity" >
       <result property="code" column="CODE" jdbcType="VARCHAR"/>
           <result property="createdate" column="CREATEDATE" jdbcType="VARCHAR"/>
           <result property="def1" column="DEF1" jdbcType="VARCHAR"/>
           <result property="def2" column="DEF2" jdbcType="VARCHAR"/>
           <result property="def3" column="DEF3" jdbcType="VARCHAR"/>
           <result property="def4" column="DEF4" jdbcType="VARCHAR"/>
           <result property="def5" column="DEF5" jdbcType="VARCHAR"/>
           <result property="dr" column="DR" jdbcType="VARCHAR"/>
           <result property="memo" column="MEMO" jdbcType="VARCHAR"/>
           <result property="mobile" column="MOBILE" jdbcType="VARCHAR"/>
           <result property="name" column="NAME" jdbcType="VARCHAR"/>
           <result property="officeaddr" column="OFFICEADDR" jdbcType="VARCHAR"/>
           <result property="ownercorp" column="OWNERCORP" jdbcType="VARCHAR"/>
           <result property="pkPurorg" column="PK_PURORG" jdbcType="VARCHAR"/>
           <result property="pkResppsn" column="PK_RESPPSN" jdbcType="VARCHAR"/>
           <result property="sealdate" column="SEALDATE" jdbcType="VARCHAR"/>
           <result property="settlestockorg" column="SETTLESTOCKORG" jdbcType="VARCHAR"/>
           <result property="ts" column="TS" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdPurorgEntity_Base_Column_List">
        CODE
       ,CREATEDATE 
        ,DEF1 
        ,DEF2 
        ,DEF3 
        ,DEF4 
        ,DEF5 
        ,DR 
        ,MEMO 
        ,MOBILE 
        ,NAME 
        ,OFFICEADDR 
        ,OWNERCORP 
        ,PK_PURORG 
        ,PK_RESPPSN 
        ,SEALDATE 
        ,SETTLESTOCKORG 
        ,TS 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdPurorgEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity">
    select
    <include refid="BdPurorgEntity_Base_Column_List" />
    from BD_PURORG
    <trim prefix="where" prefixOverrides="and"> 
        <if test="code != null and code != ''"> and CODE = #{code} </if>
            <if test="createdate != null and createdate != ''"> and CREATEDATE = #{createdate} </if>
            <if test="def1 != null and def1 != ''"> and DEF1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and DEF2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and DEF3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and DEF4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and DEF5 = #{def5} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="memo != null and memo != ''"> and MEMO = #{memo} </if>
            <if test="mobile != null and mobile != ''"> and MOBILE = #{mobile} </if>
            <if test="name != null and name != ''"> and NAME = #{name} </if>
            <if test="officeaddr != null and officeaddr != ''"> and OFFICEADDR = #{officeaddr} </if>
            <if test="ownercorp != null and ownercorp != ''"> and OWNERCORP = #{ownercorp} </if>
            <if test="pkPurorg != null and pkPurorg != ''"> and PK_PURORG = #{pkPurorg} </if>
            <if test="pkResppsn != null and pkResppsn != ''"> and PK_RESPPSN = #{pkResppsn} </if>
            <if test="sealdate != null and sealdate != ''"> and SEALDATE = #{sealdate} </if>
            <if test="settlestockorg != null and settlestockorg != ''"> and SETTLESTOCKORG = #{settlestockorg} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
--             and sts='Y'
    </trim>
<!--&#45;&#45;     <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>-->
<!--&#45;&#45;     <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>-->
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity">
        select  count(1)   from BD_PURORG
    <trim prefix="where" prefixOverrides="and"> 
        <if test="code != null and code != ''"> and CODE = #{code} </if>
            <if test="createdate != null and createdate != ''"> and CREATEDATE = #{createdate} </if>
            <if test="def1 != null and def1 != ''"> and DEF1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and DEF2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and DEF3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and DEF4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and DEF5 = #{def5} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="memo != null and memo != ''"> and MEMO = #{memo} </if>
            <if test="mobile != null and mobile != ''"> and MOBILE = #{mobile} </if>
            <if test="name != null and name != ''"> and NAME = #{name} </if>
            <if test="officeaddr != null and officeaddr != ''"> and OFFICEADDR = #{officeaddr} </if>
            <if test="ownercorp != null and ownercorp != ''"> and OWNERCORP = #{ownercorp} </if>
            <if test="pkPurorg != null and pkPurorg != ''"> and PK_PURORG = #{pkPurorg} </if>
            <if test="pkResppsn != null and pkResppsn != ''"> and PK_RESPPSN = #{pkResppsn} </if>
            <if test="sealdate != null and sealdate != ''"> and SEALDATE = #{sealdate} </if>
            <if test="settlestockorg != null and settlestockorg != ''"> and SETTLESTOCKORG = #{settlestockorg} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
--             and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-BdPurorgEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity">
    select
    <include refid="BdPurorgEntity_Base_Column_List" />
    from BD_PURORG
    <trim prefix="where" prefixOverrides="and"> 
        <if test="code != null and code != ''"> and CODE like concat('%',#{code},'%') </if>
            <if test="createdate != null and createdate != ''"> and CREATEDATE like concat('%',#{createdate},'%') </if>
            <if test="def1 != null and def1 != ''"> and DEF1 like concat('%',#{def1},'%') </if>
            <if test="def2 != null and def2 != ''"> and DEF2 like concat('%',#{def2},'%') </if>
            <if test="def3 != null and def3 != ''"> and DEF3 like concat('%',#{def3},'%') </if>
            <if test="def4 != null and def4 != ''"> and DEF4 like concat('%',#{def4},'%') </if>
            <if test="def5 != null and def5 != ''"> and DEF5 like concat('%',#{def5},'%') </if>
            <if test="dr != null and dr != ''"> and DR like concat('%',#{dr},'%') </if>
            <if test="memo != null and memo != ''"> and MEMO like concat('%',#{memo},'%') </if>
            <if test="mobile != null and mobile != ''"> and MOBILE like concat('%',#{mobile},'%') </if>
            <if test="name != null and name != ''"> and NAME like concat('%',#{name},'%') </if>
            <if test="officeaddr != null and officeaddr != ''"> and OFFICEADDR like concat('%',#{officeaddr},'%') </if>
            <if test="ownercorp != null and ownercorp != ''"> and OWNERCORP like concat('%',#{ownercorp},'%') </if>
            <if test="pkPurorg != null and pkPurorg != ''"> and PK_PURORG like concat('%',#{pkPurorg},'%') </if>
            <if test="pkResppsn != null and pkResppsn != ''"> and PK_RESPPSN like concat('%',#{pkResppsn},'%') </if>
            <if test="sealdate != null and sealdate != ''"> and SEALDATE like concat('%',#{sealdate},'%') </if>
            <if test="settlestockorg != null and settlestockorg != ''"> and SETTLESTOCKORG like concat('%',#{settlestockorg},'%') </if>
            <if test="ts != null and ts != ''"> and TS like concat('%',#{ts},'%') </if>
--             and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="BdPurorgentity_list_or" resultMap="get-BdPurorgEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity">
    select
    <include refid="BdPurorgEntity_Base_Column_List" />
    from BD_PURORG
    <trim prefix="where" prefixOverrides="and"> 
         <if test="code != null and code != ''"> or CODE = #{code} </if>
             <if test="createdate != null and createdate != ''"> or CREATEDATE = #{createdate} </if>
             <if test="def1 != null and def1 != ''"> or DEF1 = #{def1} </if>
             <if test="def2 != null and def2 != ''"> or DEF2 = #{def2} </if>
             <if test="def3 != null and def3 != ''"> or DEF3 = #{def3} </if>
             <if test="def4 != null and def4 != ''"> or DEF4 = #{def4} </if>
             <if test="def5 != null and def5 != ''"> or DEF5 = #{def5} </if>
             <if test="dr != null and dr != ''"> or DR = #{dr} </if>
             <if test="memo != null and memo != ''"> or MEMO = #{memo} </if>
             <if test="mobile != null and mobile != ''"> or MOBILE = #{mobile} </if>
             <if test="name != null and name != ''"> or NAME = #{name} </if>
             <if test="officeaddr != null and officeaddr != ''"> or OFFICEADDR = #{officeaddr} </if>
             <if test="ownercorp != null and ownercorp != ''"> or OWNERCORP = #{ownercorp} </if>
             <if test="pkPurorg != null and pkPurorg != ''"> or PK_PURORG = #{pkPurorg} </if>
             <if test="pkResppsn != null and pkResppsn != ''"> or PK_RESPPSN = #{pkResppsn} </if>
             <if test="sealdate != null and sealdate != ''"> or SEALDATE = #{sealdate} </if>
             <if test="settlestockorg != null and settlestockorg != ''"> or SETTLESTOCKORG = #{settlestockorg} </if>
             <if test="ts != null and ts != ''"> or TS = #{ts} </if>
--             and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString()  "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity" keyProperty="pkPurorg" useGeneratedKeys="true">
    insert into BD_PURORG(
  <trim suffix="" suffixOverrides=",">
       <if test="code != null and code != ''"> CODE , </if>
            <if test="createdate != null and createdate != ''"> CREATEDATE , </if>
            <if test="def1 != null and def1 != ''"> DEF1 , </if>
            <if test="def2 != null and def2 != ''"> DEF2 , </if>
            <if test="def3 != null and def3 != ''"> DEF3 , </if>
            <if test="def4 != null and def4 != ''"> DEF4 , </if>
            <if test="def5 != null and def5 != ''"> DEF5 , </if>
            <if test="dr != null and dr != ''"> DR , </if>
            <if test="memo != null and memo != ''"> MEMO , </if>
            <if test="mobile != null and mobile != ''"> MOBILE , </if>
            <if test="name != null and name != ''"> NAME , </if>
            <if test="officeaddr != null and officeaddr != ''"> OFFICEADDR , </if>
            <if test="ownercorp != null and ownercorp != ''"> OWNERCORP , </if>
            <if test="pkPurorg != null and pkPurorg != ''"> PK_PURORG , </if>
            <if test="pkResppsn != null and pkResppsn != ''"> PK_RESPPSN , </if>
            <if test="sealdate != null and sealdate != ''"> SEALDATE , </if>
            <if test="settlestockorg != null and settlestockorg != ''"> SETTLESTOCKORG , </if>
            <if test="ts != null and ts != ''"> TS , </if>
            <if test="sorts == null ">sorts,</if>
<!--    <if test="sts == null ">sts,</if>-->
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="code != null and code != ''"> #{code} ,</if>
            <if test="createdate != null and createdate != ''"> #{createdate} ,</if>
            <if test="def1 != null and def1 != ''"> #{def1} ,</if>
            <if test="def2 != null and def2 != ''"> #{def2} ,</if>
            <if test="def3 != null and def3 != ''"> #{def3} ,</if>
            <if test="def4 != null and def4 != ''"> #{def4} ,</if>
            <if test="def5 != null and def5 != ''"> #{def5} ,</if>
            <if test="dr != null and dr != ''"> #{dr} ,</if>
            <if test="memo != null and memo != ''"> #{memo} ,</if>
            <if test="mobile != null and mobile != ''"> #{mobile} ,</if>
            <if test="name != null and name != ''"> #{name} ,</if>
            <if test="officeaddr != null and officeaddr != ''"> #{officeaddr} ,</if>
            <if test="ownercorp != null and ownercorp != ''"> #{ownercorp} ,</if>
            <if test="pkPurorg != null and pkPurorg != ''"> #{pkPurorg} ,</if>
            <if test="pkResppsn != null and pkResppsn != ''"> #{pkResppsn} ,</if>
            <if test="sealdate != null and sealdate != ''"> #{sealdate} ,</if>
            <if test="settlestockorg != null and settlestockorg != ''"> #{settlestockorg} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from BD_PURORG a WHERE a.sts = 'Y' ),</if>
--     <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkPurorg" useGeneratedKeys="true">
  insert into BD_PURORG(CODE, CREATEDATE, DEF1, DEF2, DEF3, DEF4, DEF5, DR, MEMO, MOBILE, NAME, OFFICEADDR, OWNERCORP, PK_RESPPSN, SEALDATE, SETTLESTOCKORG, TS)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.code},#{entity.createdate},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.memo},#{entity.mobile},#{entity.name},#{entity.officeaddr},#{entity.ownercorp},#{entity.pkResppsn},#{entity.sealdate},#{entity.settlestockorg},#{entity.ts})
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkPurorg" useGeneratedKeys="true">
    insert into BD_PURORG(CODE, CREATEDATE, DEF1, DEF2, DEF3, DEF4, DEF5, DR, MEMO, MOBILE, NAME, OFFICEADDR, OWNERCORP, PK_RESPPSN, SEALDATE, SETTLESTOCKORG, TS)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.code},#{entity.createdate},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.memo},#{entity.mobile},#{entity.name},#{entity.officeaddr},#{entity.ownercorp},#{entity.pkResppsn},#{entity.sealdate},#{entity.settlestockorg},#{entity.ts})
    </foreach>
    on duplicate key update
    CODE = values(CODE),
    CREATEDATE = values(CREATEDATE),
    DEF1 = values(DEF1),
    DEF2 = values(DEF2),
    DEF3 = values(DEF3),
    DEF4 = values(DEF4),
    DEF5 = values(DEF5),
    DR = values(DR),
    MEMO = values(MEMO),
    MOBILE = values(MOBILE),
    NAME = values(NAME),
    OFFICEADDR = values(OFFICEADDR),
    OWNERCORP = values(OWNERCORP),
    PK_RESPPSN = values(PK_RESPPSN),
    SEALDATE = values(SEALDATE),
    SETTLESTOCKORG = values(SETTLESTOCKORG),
    TS = values(TS)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity" >
update BD_PURORG  set
<trim suffix="" suffixOverrides=",">
  <if test="code != null and code != ''"> CODE = #{code},</if>
  <if test="createdate != null and createdate != ''"> CREATEDATE = #{createdate},</if>
  <if test="def1 != null and def1 != ''"> DEF1 = #{def1},</if>
  <if test="def2 != null and def2 != ''"> DEF2 = #{def2},</if>
  <if test="def3 != null and def3 != ''"> DEF3 = #{def3},</if>
  <if test="def4 != null and def4 != ''"> DEF4 = #{def4},</if>
  <if test="def5 != null and def5 != ''"> DEF5 = #{def5},</if>
  <if test="dr != null and dr != ''"> DR = #{dr},</if>
  <if test="memo != null and memo != ''"> MEMO = #{memo},</if>
  <if test="mobile != null and mobile != ''"> MOBILE = #{mobile},</if>
  <if test="name != null and name != ''"> NAME = #{name},</if>
  <if test="officeaddr != null and officeaddr != ''"> OFFICEADDR = #{officeaddr},</if>
  <if test="ownercorp != null and ownercorp != ''"> OWNERCORP = #{ownercorp},</if>
  <if test="pkResppsn != null and pkResppsn != ''"> PK_RESPPSN = #{pkResppsn},</if>
  <if test="sealdate != null and sealdate != ''"> SEALDATE = #{sealdate},</if>
  <if test="settlestockorg != null and settlestockorg != ''"> SETTLESTOCKORG = #{settlestockorg},</if>
  <if test="ts != null and ts != ''"> TS = #{ts},</if>
</trim>
where PK_PURORG = #{pkPurorg}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity" >
update BD_PURORG  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where PK_PURORG = #{pkPurorg}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdPurorgEntity" >
update BD_PURORG  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="code != null and code != ''"> and CODE = #{code} </if>
            <if test="createdate != null and createdate != ''"> and CREATEDATE = #{createdate} </if>
            <if test="def1 != null and def1 != ''"> and DEF1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and DEF2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and DEF3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and DEF4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and DEF5 = #{def5} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="memo != null and memo != ''"> and MEMO = #{memo} </if>
            <if test="mobile != null and mobile != ''"> and MOBILE = #{mobile} </if>
            <if test="name != null and name != ''"> and NAME = #{name} </if>
            <if test="officeaddr != null and officeaddr != ''"> and OFFICEADDR = #{officeaddr} </if>
            <if test="ownercorp != null and ownercorp != ''"> and OWNERCORP = #{ownercorp} </if>
            <if test="pkPurorg != null and pkPurorg != ''"> and PK_PURORG = #{pkPurorg} </if>
            <if test="pkResppsn != null and pkResppsn != ''"> and PK_RESPPSN = #{pkResppsn} </if>
            <if test="sealdate != null and sealdate != ''"> and SEALDATE = #{sealdate} </if>
            <if test="settlestockorg != null and settlestockorg != ''"> and SETTLESTOCKORG = #{settlestockorg} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from BD_PURORG where PK_PURORG = #{pkPurorg}
</delete>

</mapper>

