<?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.BdCalbodyDaoImpl">

    <resultMap id="get-BdCalbodyEntity-result" type="com.hzya.frame.plugin.lets.entity.BdCalbodyEntity" >
       <result property="aheaddays" column="aheaddays" jdbcType="INTEGER"/>
           <result property="area" column="area" jdbcType="VARCHAR"/>
           <result property="bodycode" column="bodycode" jdbcType="VARCHAR"/>
           <result property="bodyname" column="bodyname" 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="INTEGER"/>
           <result property="isuseretail" column="isuseretail" jdbcType="VARCHAR"/>
           <result property="pkAddress" column="pk_address" jdbcType="VARCHAR"/>
           <result property="pkAreacl" column="pk_areacl" jdbcType="VARCHAR"/>
           <result property="pkCalbody" column="pk_calbody" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="property" column="property" jdbcType="INTEGER"/>
           <result property="rationmny" column="rationmny" jdbcType="NUMERIC"/>
           <result property="sealflag" column="sealflag" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
           <result property="vnote" column="vnote" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdCalbodyEntity_Base_Column_List">
        aheaddays
       ,area 
        ,bodycode 
        ,bodyname 
        ,createdate 
        ,def1 
        ,def2 
        ,def3 
        ,def4 
        ,def5 
        ,dr 
        ,isuseretail 
        ,pk_address 
        ,pk_areacl 
        ,pk_calbody 
        ,pk_corp 
        ,property 
        ,rationmny 
        ,sealflag 
        ,ts 
        ,vnote 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdCalbodyEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity">
    select
    <include refid="BdCalbodyEntity_Base_Column_List" />
    from bd_calbody
    <trim prefix="where" prefixOverrides="and"> 
        <if test="aheaddays != null"> and aheaddays = #{aheaddays} </if>
            <if test="area != null and area != ''"> and area = #{area} </if>
            <if test="bodycode != null and bodycode != ''"> and bodycode = #{bodycode} </if>
            <if test="bodyname != null and bodyname != ''"> and bodyname = #{bodyname} </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 = #{dr} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkAreacl != null and pkAreacl != ''"> and pk_areacl = #{pkAreacl} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="property != null"> and property = #{property} </if>
            <if test="rationmny != null"> and rationmny = #{rationmny} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </if>
    </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>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity">
        select  count(1)   from bd_calbody
    <trim prefix="where" prefixOverrides="and"> 
        <if test="aheaddays != null"> and aheaddays = #{aheaddays} </if>
            <if test="area != null and area != ''"> and area = #{area} </if>
            <if test="bodycode != null and bodycode != ''"> and bodycode = #{bodycode} </if>
            <if test="bodyname != null and bodyname != ''"> and bodyname = #{bodyname} </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 = #{dr} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkAreacl != null and pkAreacl != ''"> and pk_areacl = #{pkAreacl} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="property != null"> and property = #{property} </if>
            <if test="rationmny != null"> and rationmny = #{rationmny} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </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-BdCalbodyEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity">
    select
    <include refid="BdCalbodyEntity_Base_Column_List" />
    from bd_calbody
    <trim prefix="where" prefixOverrides="and"> 
        <if test="aheaddays != null"> and aheaddays like concat('%',#{aheaddays},'%') </if>
            <if test="area != null and area != ''"> and area like concat('%',#{area},'%') </if>
            <if test="bodycode != null and bodycode != ''"> and bodycode like concat('%',#{bodycode},'%') </if>
            <if test="bodyname != null and bodyname != ''"> and bodyname like concat('%',#{bodyname},'%') </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 like concat('%',#{dr},'%') </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail like concat('%',#{isuseretail},'%') </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address like concat('%',#{pkAddress},'%') </if>
            <if test="pkAreacl != null and pkAreacl != ''"> and pk_areacl like concat('%',#{pkAreacl},'%') </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody like concat('%',#{pkCalbody},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </if>
            <if test="property != null"> and property like concat('%',#{property},'%') </if>
            <if test="rationmny != null"> and rationmny like concat('%',#{rationmny},'%') </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag like concat('%',#{sealflag},'%') </if>
            <if test="ts != null and ts != ''"> and ts like concat('%',#{ts},'%') </if>
            <if test="vnote != null and vnote != ''"> and vnote like concat('%',#{vnote},'%') </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="BdCalbodyentity_list_or" resultMap="get-BdCalbodyEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity">
    select
    <include refid="BdCalbodyEntity_Base_Column_List" />
    from bd_calbody
    <trim prefix="where" prefixOverrides="and"> 
         <if test="aheaddays != null"> or aheaddays = #{aheaddays} </if>
             <if test="area != null and area != ''"> or area = #{area} </if>
             <if test="bodycode != null and bodycode != ''"> or bodycode = #{bodycode} </if>
             <if test="bodyname != null and bodyname != ''"> or bodyname = #{bodyname} </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"> or dr = #{dr} </if>
             <if test="isuseretail != null and isuseretail != ''"> or isuseretail = #{isuseretail} </if>
             <if test="pkAddress != null and pkAddress != ''"> or pk_address = #{pkAddress} </if>
             <if test="pkAreacl != null and pkAreacl != ''"> or pk_areacl = #{pkAreacl} </if>
             <if test="pkCalbody != null and pkCalbody != ''"> or pk_calbody = #{pkCalbody} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </if>
             <if test="property != null"> or property = #{property} </if>
             <if test="rationmny != null"> or rationmny = #{rationmny} </if>
             <if test="sealflag != null and sealflag != ''"> or sealflag = #{sealflag} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </if>
             <if test="vnote != null and vnote != ''"> or vnote = #{vnote} </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.BdCalbodyEntity" keyProperty="pkCalbody" useGeneratedKeys="true">
    insert into bd_calbody(
  <trim suffix="" suffixOverrides=",">
       <if test="aheaddays != null"> aheaddays , </if>
            <if test="area != null and area != ''"> area , </if>
            <if test="bodycode != null and bodycode != ''"> bodycode , </if>
            <if test="bodyname != null and bodyname != ''"> bodyname , </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"> dr , </if>
            <if test="isuseretail != null and isuseretail != ''"> isuseretail , </if>
            <if test="pkAddress != null and pkAddress != ''"> pk_address , </if>
            <if test="pkAreacl != null and pkAreacl != ''"> pk_areacl , </if>
            <if test="pkCalbody != null and pkCalbody != ''"> pk_calbody , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </if>
            <if test="property != null"> property , </if>
            <if test="rationmny != null"> rationmny , </if>
            <if test="sealflag != null and sealflag != ''"> sealflag , </if>
            <if test="ts != null and ts != ''"> ts , </if>
            <if test="vnote != null and vnote != ''"> vnote , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="aheaddays != null"> #{aheaddays} ,</if>
            <if test="area != null and area != ''"> #{area} ,</if>
            <if test="bodycode != null and bodycode != ''"> #{bodycode} ,</if>
            <if test="bodyname != null and bodyname != ''"> #{bodyname} ,</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"> #{dr} ,</if>
            <if test="isuseretail != null and isuseretail != ''"> #{isuseretail} ,</if>
            <if test="pkAddress != null and pkAddress != ''"> #{pkAddress} ,</if>
            <if test="pkAreacl != null and pkAreacl != ''"> #{pkAreacl} ,</if>
            <if test="pkCalbody != null and pkCalbody != ''"> #{pkCalbody} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="property != null"> #{property} ,</if>
            <if test="rationmny != null"> #{rationmny} ,</if>
            <if test="sealflag != null and sealflag != ''"> #{sealflag} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="vnote != null and vnote != ''"> #{vnote} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from bd_calbody a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkCalbody" useGeneratedKeys="true">
  insert into bd_calbody(aheaddays, area, bodycode, bodyname, createdate, def1, def2, def3, def4, def5, dr, isuseretail, pk_address, pk_areacl, pk_corp, property, rationmny, sealflag, ts, vnote,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.aheaddays},#{entity.area},#{entity.bodycode},#{entity.bodyname},#{entity.createdate},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.isuseretail},#{entity.pkAddress},#{entity.pkAreacl},#{entity.pkCorp},#{entity.property},#{entity.rationmny},#{entity.sealflag},#{entity.ts},#{entity.vnote}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkCalbody" useGeneratedKeys="true">
    insert into bd_calbody(aheaddays, area, bodycode, bodyname, createdate, def1, def2, def3, def4, def5, dr, isuseretail, pk_address, pk_areacl, pk_corp, property, rationmny, sealflag, ts, vnote)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.aheaddays},#{entity.area},#{entity.bodycode},#{entity.bodyname},#{entity.createdate},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.isuseretail},#{entity.pkAddress},#{entity.pkAreacl},#{entity.pkCorp},#{entity.property},#{entity.rationmny},#{entity.sealflag},#{entity.ts},#{entity.vnote})
    </foreach>
    on duplicate key update
    aheaddays = values(aheaddays),
    area = values(area),
    bodycode = values(bodycode),
    bodyname = values(bodyname),
    createdate = values(createdate),
    def1 = values(def1),
    def2 = values(def2),
    def3 = values(def3),
    def4 = values(def4),
    def5 = values(def5),
    dr = values(dr),
    isuseretail = values(isuseretail),
    pk_address = values(pk_address),
    pk_areacl = values(pk_areacl),
    pk_corp = values(pk_corp),
    property = values(property),
    rationmny = values(rationmny),
    sealflag = values(sealflag),
    ts = values(ts),
    vnote = values(vnote)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity" >
update bd_calbody  set
<trim suffix="" suffixOverrides=",">
  <if test="aheaddays != null"> aheaddays = #{aheaddays},</if>
  <if test="area != null and area != ''"> area = #{area},</if>
  <if test="bodycode != null and bodycode != ''"> bodycode = #{bodycode},</if>
  <if test="bodyname != null and bodyname != ''"> bodyname = #{bodyname},</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"> dr = #{dr},</if>
  <if test="isuseretail != null and isuseretail != ''"> isuseretail = #{isuseretail},</if>
  <if test="pkAddress != null and pkAddress != ''"> pk_address = #{pkAddress},</if>
  <if test="pkAreacl != null and pkAreacl != ''"> pk_areacl = #{pkAreacl},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="property != null"> property = #{property},</if>
  <if test="rationmny != null"> rationmny = #{rationmny},</if>
  <if test="sealflag != null and sealflag != ''"> sealflag = #{sealflag},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
  <if test="vnote != null and vnote != ''"> vnote = #{vnote},</if>
</trim>
where pk_calbody = #{pkCalbody}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity" >
update bd_calbody  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where pk_calbody = #{pkCalbody}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdCalbodyEntity" >
update bd_calbody  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="aheaddays != null"> and aheaddays = #{aheaddays} </if>
            <if test="area != null and area != ''"> and area = #{area} </if>
            <if test="bodycode != null and bodycode != ''"> and bodycode = #{bodycode} </if>
            <if test="bodyname != null and bodyname != ''"> and bodyname = #{bodyname} </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 = #{dr} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkAreacl != null and pkAreacl != ''"> and pk_areacl = #{pkAreacl} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="property != null"> and property = #{property} </if>
            <if test="rationmny != null"> and rationmny = #{rationmny} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from bd_calbody where pk_calbody = #{pkCalbody}
</delete>

</mapper>

