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

    <resultMap id="get-IcGeneralBb1Entity-result" type="com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity" >
       <result property="cgeneralbb1" column="cgeneralbb1" jdbcType="VARCHAR"/>
           <result property="cgeneralbid" column="cgeneralbid" jdbcType="VARCHAR"/>
           <result property="cspaceid" column="cspaceid" jdbcType="VARCHAR"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="ningrossnum" column="ningrossnum" jdbcType="NUMERIC"/>
           <result property="ninspaceassistnum" column="ninspaceassistnum" jdbcType="NUMERIC"/>
           <result property="ninspacenum" column="ninspacenum" jdbcType="NUMERIC"/>
           <result property="noutgrossnum" column="noutgrossnum" jdbcType="NUMERIC"/>
           <result property="noutspaceassistnum" column="noutspaceassistnum" jdbcType="NUMERIC"/>
           <result property="noutspacenum" column="noutspacenum" jdbcType="NUMERIC"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "IcGeneralBb1Entity_Base_Column_List">
        cgeneralbb1
       ,cgeneralbid 
        ,cspaceid 
        ,dr 
        ,ningrossnum 
        ,ninspaceassistnum 
        ,ninspacenum 
        ,noutgrossnum 
        ,noutspaceassistnum 
        ,noutspacenum 
        ,pk_corp 
        ,ts 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-IcGeneralBb1Entity-result" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity">
    select
    <include refid="IcGeneralBb1Entity_Base_Column_List" />
    from ic_general_bb1
    <trim prefix="where" prefixOverrides="and"> 
        <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> and cgeneralbb1 = #{cgeneralbb1} </if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> and cgeneralbid = #{cgeneralbid} </if>
            <if test="cspaceid != null and cspaceid != ''"> and cspaceid = #{cspaceid} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="ningrossnum != null"> and ningrossnum = #{ningrossnum} </if>
            <if test="ninspaceassistnum != null"> and ninspaceassistnum = #{ninspaceassistnum} </if>
            <if test="ninspacenum != null"> and ninspacenum = #{ninspacenum} </if>
            <if test="noutgrossnum != null"> and noutgrossnum = #{noutgrossnum} </if>
            <if test="noutspaceassistnum != null"> and noutspaceassistnum = #{noutspaceassistnum} </if>
            <if test="noutspacenum != null"> and noutspacenum = #{noutspacenum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
    </trim>
    <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.IcGeneralBb1Entity">
        select  count(1)   from ic_general_bb1
    <trim prefix="where" prefixOverrides="and"> 
        <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> and cgeneralbb1 = #{cgeneralbb1} </if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> and cgeneralbid = #{cgeneralbid} </if>
            <if test="cspaceid != null and cspaceid != ''"> and cspaceid = #{cspaceid} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="ningrossnum != null"> and ningrossnum = #{ningrossnum} </if>
            <if test="ninspaceassistnum != null"> and ninspaceassistnum = #{ninspaceassistnum} </if>
            <if test="ninspacenum != null"> and ninspacenum = #{ninspacenum} </if>
            <if test="noutgrossnum != null"> and noutgrossnum = #{noutgrossnum} </if>
            <if test="noutspaceassistnum != null"> and noutspaceassistnum = #{noutspaceassistnum} </if>
            <if test="noutspacenum != null"> and noutspacenum = #{noutspacenum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </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-IcGeneralBb1Entity-result" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity">
    select
    <include refid="IcGeneralBb1Entity_Base_Column_List" />
    from ic_general_bb1
    <trim prefix="where" prefixOverrides="and"> 
        <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> and cgeneralbb1 like concat('%',#{cgeneralbb1},'%') </if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> and cgeneralbid like concat('%',#{cgeneralbid},'%') </if>
            <if test="cspaceid != null and cspaceid != ''"> and cspaceid like concat('%',#{cspaceid},'%') </if>
            <if test="dr != null"> and dr like concat('%',#{dr},'%') </if>
            <if test="ningrossnum != null"> and ningrossnum like concat('%',#{ningrossnum},'%') </if>
            <if test="ninspaceassistnum != null"> and ninspaceassistnum like concat('%',#{ninspaceassistnum},'%') </if>
            <if test="ninspacenum != null"> and ninspacenum like concat('%',#{ninspacenum},'%') </if>
            <if test="noutgrossnum != null"> and noutgrossnum like concat('%',#{noutgrossnum},'%') </if>
            <if test="noutspaceassistnum != null"> and noutspaceassistnum like concat('%',#{noutspaceassistnum},'%') </if>
            <if test="noutspacenum != null"> and noutspacenum like concat('%',#{noutspacenum},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </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="IcGeneralBb1entity_list_or" resultMap="get-IcGeneralBb1Entity-result" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity">
    select
    <include refid="IcGeneralBb1Entity_Base_Column_List" />
    from ic_general_bb1
    <trim prefix="where" prefixOverrides="and"> 
         <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> or cgeneralbb1 = #{cgeneralbb1} </if>
             <if test="cgeneralbid != null and cgeneralbid != ''"> or cgeneralbid = #{cgeneralbid} </if>
             <if test="cspaceid != null and cspaceid != ''"> or cspaceid = #{cspaceid} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="ningrossnum != null"> or ningrossnum = #{ningrossnum} </if>
             <if test="ninspaceassistnum != null"> or ninspaceassistnum = #{ninspaceassistnum} </if>
             <if test="ninspacenum != null"> or ninspacenum = #{ninspacenum} </if>
             <if test="noutgrossnum != null"> or noutgrossnum = #{noutgrossnum} </if>
             <if test="noutspaceassistnum != null"> or noutspaceassistnum = #{noutspaceassistnum} </if>
             <if test="noutspacenum != null"> or noutspacenum = #{noutspacenum} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </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.IcGeneralBb1Entity" keyProperty="cgeneralbb1" useGeneratedKeys="true">
    insert into ic_general_bb1(
  <trim suffix="" suffixOverrides=",">
       <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> cgeneralbb1 , </if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> cgeneralbid , </if>
            <if test="cspaceid != null and cspaceid != ''"> cspaceid , </if>
            <if test="dr != null"> dr , </if>
            <if test="ningrossnum != null"> ningrossnum , </if>
            <if test="ninspaceassistnum != null"> ninspaceassistnum , </if>
            <if test="ninspacenum != null"> ninspacenum , </if>
            <if test="noutgrossnum != null"> noutgrossnum , </if>
            <if test="noutspaceassistnum != null"> noutspaceassistnum , </if>
            <if test="noutspacenum != null"> noutspacenum , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </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="cgeneralbb1 != null and cgeneralbb1 != ''"> #{cgeneralbb1} ,</if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> #{cgeneralbid} ,</if>
            <if test="cspaceid != null and cspaceid != ''"> #{cspaceid} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="ningrossnum != null"> #{ningrossnum} ,</if>
            <if test="ninspaceassistnum != null"> #{ninspaceassistnum} ,</if>
            <if test="ninspacenum != null"> #{ninspacenum} ,</if>
            <if test="noutgrossnum != null"> #{noutgrossnum} ,</if>
            <if test="noutspaceassistnum != null"> #{noutspaceassistnum} ,</if>
            <if test="noutspacenum != null"> #{noutspacenum} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from ic_general_bb1 a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="cgeneralbb1" useGeneratedKeys="true">
  insert into ic_general_bb1(cgeneralbid, cspaceid, dr, ningrossnum, ninspaceassistnum, ninspacenum, noutgrossnum, noutspaceassistnum, noutspacenum, pk_corp, ts,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.cgeneralbid},#{entity.cspaceid},#{entity.dr},#{entity.ningrossnum},#{entity.ninspaceassistnum},#{entity.ninspacenum},#{entity.noutgrossnum},#{entity.noutspaceassistnum},#{entity.noutspacenum},#{entity.pkCorp},#{entity.ts}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="cgeneralbb1" useGeneratedKeys="true">
    insert into ic_general_bb1(cgeneralbid, cspaceid, dr, ningrossnum, ninspaceassistnum, ninspacenum, noutgrossnum, noutspaceassistnum, noutspacenum, pk_corp, ts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.cgeneralbid},#{entity.cspaceid},#{entity.dr},#{entity.ningrossnum},#{entity.ninspaceassistnum},#{entity.ninspacenum},#{entity.noutgrossnum},#{entity.noutspaceassistnum},#{entity.noutspacenum},#{entity.pkCorp},#{entity.ts})
    </foreach>
    on duplicate key update
    cgeneralbid = values(cgeneralbid),
    cspaceid = values(cspaceid),
    dr = values(dr),
    ningrossnum = values(ningrossnum),
    ninspaceassistnum = values(ninspaceassistnum),
    ninspacenum = values(ninspacenum),
    noutgrossnum = values(noutgrossnum),
    noutspaceassistnum = values(noutspaceassistnum),
    noutspacenum = values(noutspacenum),
    pk_corp = values(pk_corp),
    ts = values(ts)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity" >
update ic_general_bb1  set
<trim suffix="" suffixOverrides=",">
  <if test="cgeneralbid != null and cgeneralbid != ''"> cgeneralbid = #{cgeneralbid},</if>
  <if test="cspaceid != null and cspaceid != ''"> cspaceid = #{cspaceid},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="ningrossnum != null"> ningrossnum = #{ningrossnum},</if>
  <if test="ninspaceassistnum != null"> ninspaceassistnum = #{ninspaceassistnum},</if>
  <if test="ninspacenum != null"> ninspacenum = #{ninspacenum},</if>
  <if test="noutgrossnum != null"> noutgrossnum = #{noutgrossnum},</if>
  <if test="noutspaceassistnum != null"> noutspaceassistnum = #{noutspaceassistnum},</if>
  <if test="noutspacenum != null"> noutspacenum = #{noutspacenum},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
</trim>
where cgeneralbb1 = #{cgeneralbb1}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity" >
update ic_general_bb1  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where cgeneralbb1 = #{cgeneralbb1}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.IcGeneralBb1Entity" >
update ic_general_bb1  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="cgeneralbb1 != null and cgeneralbb1 != ''"> and cgeneralbb1 = #{cgeneralbb1} </if>
            <if test="cgeneralbid != null and cgeneralbid != ''"> and cgeneralbid = #{cgeneralbid} </if>
            <if test="cspaceid != null and cspaceid != ''"> and cspaceid = #{cspaceid} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="ningrossnum != null"> and ningrossnum = #{ningrossnum} </if>
            <if test="ninspaceassistnum != null"> and ninspaceassistnum = #{ninspaceassistnum} </if>
            <if test="ninspacenum != null"> and ninspacenum = #{ninspacenum} </if>
            <if test="noutgrossnum != null"> and noutgrossnum = #{noutgrossnum} </if>
            <if test="noutspaceassistnum != null"> and noutspaceassistnum = #{noutspaceassistnum} </if>
            <if test="noutspacenum != null"> and noutspacenum = #{noutspacenum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from ic_general_bb1 where cgeneralbb1 = #{cgeneralbb1}
</delete>

</mapper>

