<?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.sysnew.dictionaryshop.dao.impl.SysDictionaryshopDaoImpl">

    <resultMap id="get-SysDictionaryshopEntity-result"
               type="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="tabName" column="tab_name" jdbcType="VARCHAR"/>
        <result property="columnName" column="column_name" jdbcType="VARCHAR"/>
        <result property="columnContent" column="column_content" jdbcType="VARCHAR"/>
        <result property="columnValue" column="column_value" jdbcType="VARCHAR"/>
        <result property="columnNumValue" column="column_num_value" jdbcType="INTEGER"/>
        <result property="upId" column="up_id" jdbcType="INTEGER"/>
        <result property="memo" column="memo" jdbcType="VARCHAR"/>
        <result property="usedSts" column="used_sts" jdbcType="VARCHAR"/>
        <result property="sorts" column="sorts" jdbcType="INTEGER"/>
        <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
        <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
        <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
        <result property="sts" column="sts" jdbcType="VARCHAR"/>
        <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
        <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id="SysDictionaryshopEntity_Base_Column_List">
        id
       ,tab_name 
        ,column_name 
        ,column_content 
        ,column_value 
        ,column_num_value 
        ,up_id 
        ,memo 
        ,used_sts 
        ,sorts 
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
        ,company_id 
     </sql>
    <!-- 查询 采用==查询 -->
    <select id="entity_list_base" resultMap="get-SysDictionaryshopEntity-result"
            parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        select
        <include refid="SysDictionaryshopEntity_Base_Column_List"/>
        from sys_dictionaryshop
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="tabName != null and tabName != ''">and tab_name = #{tabName}</if>
            <if test="columnName != null and columnName != ''">and column_name = #{columnName}</if>
            <if test="columnContent != null and columnContent != ''">and column_content = #{columnContent}</if>
            <if test="columnValue != null and columnValue != ''">and column_value = #{columnValue}</if>
            <if test="columnNumValue != null">and column_num_value = #{columnNumValue}</if>
            <if test="upId != null">and up_id = #{upId}</if>
            <if test="memo != null and memo != ''">and memo = #{memo}</if>
            <if test="usedSts != null and usedSts != ''">and used_sts = #{usedSts}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</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>

    <!-- 查询符合条件的数量 -->
    <select id="entity_count" resultType="Integer"
            parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        select count(1) from sys_dictionaryshop
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="tabName != null and tabName != ''">and tab_name = #{tabName}</if>
            <if test="columnName != null and columnName != ''">and column_name = #{columnName}</if>
            <if test="columnContent != null and columnContent != ''">and column_content = #{columnContent}</if>
            <if test="columnValue != null and columnValue != ''">and column_value = #{columnValue}</if>
            <if test="columnNumValue != null">and column_num_value = #{columnNumValue}</if>
            <if test="upId != null">and up_id = #{upId}</if>
            <if test="memo != null and memo != ''">and memo = #{memo}</if>
            <if test="usedSts != null and usedSts != ''">and used_sts = #{usedSts}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</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-SysDictionaryshopEntity-result"
            parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        select
        <include refid="SysDictionaryshopEntity_Base_Column_List"/>
        from sys_dictionaryshop
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
            <if test="tabName != null and tabName != ''">and tab_name like concat('%',#{tabName},'%')</if>
            <if test="columnName != null and columnName != ''">and column_name like concat('%',#{columnName},'%')</if>
            <if test="columnContent != null and columnContent != ''">and column_content like
                concat('%',#{columnContent},'%')
            </if>
            <if test="columnValue != null and columnValue != ''">and column_value like concat('%',#{columnValue},'%')
            </if>
            <if test="columnNumValue != null">and column_num_value like concat('%',#{columnNumValue},'%')</if>
            <if test="upId != null">and up_id like concat('%',#{upId},'%')</if>
            <if test="memo != null and memo != ''">and memo like concat('%',#{memo},'%')</if>
            <if test="usedSts != null and usedSts != ''">and used_sts like concat('%',#{usedSts},'%')</if>
            <if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
            <if test="companyId != null and companyId != ''">and company_id like concat('%',#{companyId},'%')</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="SysDictionaryshopentity_list_or" resultMap="get-SysDictionaryshopEntity-result"
            parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        select
        <include refid="SysDictionaryshopEntity_Base_Column_List"/>
        from sys_dictionaryshop
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">or id = #{id}</if>
            <if test="tabName != null and tabName != ''">or tab_name = #{tabName}</if>
            <if test="columnName != null and columnName != ''">or column_name = #{columnName}</if>
            <if test="columnContent != null and columnContent != ''">or column_content = #{columnContent}</if>
            <if test="columnValue != null and columnValue != ''">or column_value = #{columnValue}</if>
            <if test="columnNumValue != null">or column_num_value = #{columnNumValue}</if>
            <if test="upId != null">or up_id = #{upId}</if>
            <if test="memo != null and memo != ''">or memo = #{memo}</if>
            <if test="usedSts != null and usedSts != ''">or used_sts = #{usedSts}</if>
            <if test="sorts != null">or sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">or create_user_id = #{create_user_id}</if>
            <if test="create_time != null">or create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">or modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">or modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">or sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">or org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">or company_id = #{companyId}</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.sysnew.dictionaryshop.entity.SysDictionaryshopEntity"
            >
        insert into sys_dictionaryshop(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">id ,</if>
            <if test="tabName != null and tabName != ''">tab_name ,</if>
            <if test="columnName != null and columnName != ''">column_name ,</if>
            <if test="columnContent != null and columnContent != ''">column_content ,</if>
            <if test="columnValue != null and columnValue != ''">column_value ,</if>
            <if test="columnNumValue != null">column_num_value ,</if>
            <if test="upId != null">up_id ,</if>
            <if test="memo != null and memo != ''">memo ,</if>
            <if test="usedSts != null and usedSts != ''">used_sts ,</if>
            <if test="sorts != null">sorts ,</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
            <if test="create_time != null">create_time ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
            <if test="modify_time != null">modify_time ,</if>
            <if test="sts != null and sts != ''">sts ,</if>
            <if test="org_id != null and org_id != ''">org_id ,</if>
            <if test="companyId != null and companyId != ''">company_id ,</if>
            <if test="sorts == null ">sorts,</if>
            <if test="sts == null ">sts,</if>
        </trim>
        )values(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">#{id} ,</if>
            <if test="tabName != null and tabName != ''">#{tabName} ,</if>
            <if test="columnName != null and columnName != ''">#{columnName} ,</if>
            <if test="columnContent != null and columnContent != ''">#{columnContent} ,</if>
            <if test="columnValue != null and columnValue != ''">#{columnValue} ,</if>
            <if test="columnNumValue != null">#{columnNumValue} ,</if>
            <if test="upId != null">#{upId} ,</if>
            <if test="memo != null and memo != ''">#{memo} ,</if>
            <if test="usedSts != null and usedSts != ''">#{usedSts} ,</if>
            <if test="sorts != null">#{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
            <if test="create_time != null">#{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
            <if test="modify_time != null">#{modify_time} ,</if>
            <if test="sts != null and sts != ''">#{sts} ,</if>
            <if test="org_id != null and org_id != ''">#{org_id} ,</if>
            <if test="companyId != null and companyId != ''">#{companyId} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_dictionaryshop a WHERE
                a.sts = 'Y' ),
            </if>
            <if test="sts == null ">'Y',</if>
        </trim>
        )
    </insert>
    <!-- 批量新增 -->
    <insert id="entityInsertBatch" >
        insert into sys_dictionaryshop(tab_name, column_name, column_content, column_value, column_num_value, up_id,
        memo, used_sts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, sts)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.tabName},#{entity.columnName},#{entity.columnContent},#{entity.columnValue},#{entity.columnNumValue},#{entity.upId},#{entity.memo},#{entity.usedSts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},
            'Y')
        </foreach>
    </insert>
    <!-- 批量新增或者修改-->
    <insert id="entityInsertOrUpdateBatch" >
        insert into sys_dictionaryshop(tab_name, column_name, column_content, column_value, column_num_value, up_id,
        memo, used_sts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.tabName},#{entity.columnName},#{entity.columnContent},#{entity.columnValue},#{entity.columnNumValue},#{entity.upId},#{entity.memo},#{entity.usedSts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
        </foreach>
        on duplicate key update
        tab_name = values(tab_name),
        column_name = values(column_name),
        column_content = values(column_content),
        column_value = values(column_value),
        column_num_value = values(column_num_value),
        up_id = values(up_id),
        memo = values(memo),
        used_sts = values(used_sts),
        create_user_id = values(create_user_id),
        create_time = values(create_time),
        modify_user_id = values(modify_user_id),
        modify_time = values(modify_time),
        sts = values(sts),
        org_id = values(org_id),
        company_id = values(company_id)
    </insert>
    <!--通过主键修改方法-->
    <update id="entity_update" parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        update sys_dictionaryshop set
        <trim suffix="" suffixOverrides=",">
            <if test="tabName != null and tabName != ''">tab_name = #{tabName},</if>
            <if test="columnName != null and columnName != ''">column_name = #{columnName},</if>
            <if test="columnContent != null and columnContent != ''">column_content = #{columnContent},</if>
            <if test="columnValue != null and columnValue != ''">column_value = #{columnValue},</if>
            <if test="columnNumValue != null">column_num_value = #{columnNumValue},</if>
            <if test="upId != null">up_id = #{upId},</if>
            <if test="memo != null and memo != ''">memo = #{memo},</if>
            <if test="usedSts != null and usedSts != ''">used_sts = #{usedSts},</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id = #{modify_user_id},</if>
            <if test="modify_time != null">modify_time = #{modify_time},</if>
            <if test="sts != null and sts != ''">sts = #{sts},</if>
            <if test="org_id != null and org_id != ''">org_id = #{org_id},</if>
            <if test="companyId != null and companyId != ''">company_id = #{companyId},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 逻辑删除 -->
    <update id="entity_logicDelete" parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
update sys_dictionaryshop  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
    <!-- 多条件逻辑删除 -->
    <update id="entity_logicDelete_Multi_Condition"
            parameterType="com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity">
        update sys_dictionaryshop set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="tabName != null and tabName != ''">and tab_name = #{tabName}</if>
            <if test="columnName != null and columnName != ''">and column_name = #{columnName}</if>
            <if test="columnContent != null and columnContent != ''">and column_content = #{columnContent}</if>
            <if test="columnValue != null and columnValue != ''">and column_value = #{columnValue}</if>
            <if test="columnNumValue != null">and column_num_value = #{columnNumValue}</if>
            <if test="upId != null">and up_id = #{upId}</if>
            <if test="memo != null and memo != ''">and memo = #{memo}</if>
            <if test="usedSts != null and usedSts != ''">and used_sts = #{usedSts}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
            and sts='Y'
        </trim>
    </update>
    <!--通过主键删除-->
    <delete id="entity_delete">
    delete from sys_dictionaryshop where id = #{id}
</delete>

</mapper>

