<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.skin.dao.ibatis.SkinDaoImpl">

    <!-- 字段和属性映射 -->
    <resultMap type="SkinEntity" id="SkinEntity-Map">
            <id  property="id" column="id" />
            <result property="categoryId" column="categoryId" />
            <result property="productId" column="productId" />
            <result property="productName" column="productName" />
            <result property="cssFilePath" column="cssFilePath" />
            <result property="name" column="name" />
            <result property="imageResolution" column="imageResolution" />
            <result property="previewImagePath" column="previewImagePath" />
            <result property="sortNum" column="sortNum" />
            <result property="used" column="used" />
            <result property="createTime" column="createTime" />
            <result property="createUserId" column="createUserId" />
            <result property="updateTime" column="updateTime" />
            
    </resultMap>


    <!-- 表所有列 -->
    <sql id="_columns">
        <trim suffixOverrides="," suffix="">
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
                    a.id,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('categoryId') or colPickMode == 1 and data.containsKey('categoryId')))">
                    a.categoryId,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('productId') or colPickMode == 1 and data.containsKey('productId')))">
                    a.productId,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('productName') or colPickMode == 1 and data.containsKey('productName')))">
                    a.productName,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('cssFilePath') or colPickMode == 1 and data.containsKey('cssFilePath')))">
                    a.cssFilePath,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('name') or colPickMode == 1 and data.containsKey('name')))">
                    a.name,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('imageResolution') or colPickMode == 1 and data.containsKey('imageResolution')))">
                    a.imageResolution,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('previewImagePath') or colPickMode == 1 and data.containsKey('previewImagePath')))">
                    a.previewImagePath,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('sortNum') or colPickMode == 1 and data.containsKey('sortNum')))">
                    a.sortNum,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('used') or colPickMode == 1 and data.containsKey('used')))">
                    a.used,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
                    a.createTime,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))">
                    a.createUserId,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
                    a.updateTime,
                </if>
        </trim>
    </sql>
    <!-- 新增 区分主键自增加还是业务插入 -->
    <insert id="insert" parameterType="SkinEntity">
        insert into mortals_sys_skin
        (id,categoryId,productId,productName,cssFilePath,name,imageResolution,previewImagePath,sortNum,used,createTime,createUserId,updateTime)
        VALUES
        (#{id},#{categoryId},#{productId},#{productName},#{cssFilePath},#{name},#{imageResolution},#{previewImagePath},#{sortNum},#{used},#{createTime},#{createUserId},#{updateTime})
    </insert>

    <!-- 批量新增 -->
    <insert id="insertBatch" parameterType="paramDto">
        insert into mortals_sys_skin
        (id,categoryId,productId,productName,cssFilePath,name,imageResolution,previewImagePath,sortNum,used,createTime,createUserId,updateTime)
        VALUES
        <foreach collection="data.dataList" item="item" index="index" separator="," >
            (#{item.id},#{item.categoryId},#{item.productId},#{item.productName},#{item.cssFilePath},#{item.name},#{item.imageResolution},#{item.previewImagePath},#{item.sortNum},#{item.used},#{item.createTime},#{item.createUserId},#{item.updateTime})
        </foreach>
    </insert>


    <!-- 根据ParamDto更新 -->
    <update id="update" parameterType="paramDto">
        update mortals_sys_skin as a
        set
        <trim suffixOverrides="," suffix="">
            <if test="(colPickMode==0 and data.containsKey('categoryId')) or (colPickMode==1 and !data.containsKey('categoryId'))">
                a.categoryId=#{data.categoryId},
            </if>
            <if test="(colPickMode==0 and data.containsKey('categoryIdIncrement')) or (colPickMode==1 and !data.containsKey('categoryIdIncrement'))">
                a.categoryId=ifnull(a.categoryId,0) + #{data.categoryIdIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('productId')) or (colPickMode==1 and !data.containsKey('productId'))">
                a.productId=#{data.productId},
            </if>
            <if test="(colPickMode==0 and data.containsKey('productIdIncrement')) or (colPickMode==1 and !data.containsKey('productIdIncrement'))">
                a.productId=ifnull(a.productId,0) + #{data.productIdIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('productName')) or (colPickMode==1 and !data.containsKey('productName'))">
                a.productName=#{data.productName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('cssFilePath')) or (colPickMode==1 and !data.containsKey('cssFilePath'))">
                a.cssFilePath=#{data.cssFilePath},
            </if>
            <if test="(colPickMode==0 and data.containsKey('name')) or (colPickMode==1 and !data.containsKey('name'))">
                a.name=#{data.name},
            </if>
            <if test="(colPickMode==0 and data.containsKey('imageResolution')) or (colPickMode==1 and !data.containsKey('imageResolution'))">
                a.imageResolution=#{data.imageResolution},
            </if>
            <if test="(colPickMode==0 and data.containsKey('previewImagePath')) or (colPickMode==1 and !data.containsKey('previewImagePath'))">
                a.previewImagePath=#{data.previewImagePath},
            </if>
            <if test="(colPickMode==0 and data.containsKey('sortNum')) or (colPickMode==1 and !data.containsKey('sortNum'))">
                a.sortNum=#{data.sortNum},
            </if>
            <if test="(colPickMode==0 and data.containsKey('sortNumIncrement')) or (colPickMode==1 and !data.containsKey('sortNumIncrement'))">
                a.sortNum=ifnull(a.sortNum,0) + #{data.sortNumIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('used')) or (colPickMode==1 and !data.containsKey('used'))">
                a.used=#{data.used},
            </if>
            <if test="(colPickMode==0 and data.containsKey('usedIncrement')) or (colPickMode==1 and !data.containsKey('usedIncrement'))">
                a.used=ifnull(a.used,0) + #{data.usedIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))">
                a.createTime=#{data.createTime},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createUserId')) or (colPickMode==1 and !data.containsKey('createUserId'))">
                a.createUserId=#{data.createUserId},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createUserIdIncrement')) or (colPickMode==1 and !data.containsKey('createUserIdIncrement'))">
                a.createUserId=ifnull(a.createUserId,0) + #{data.createUserIdIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
                a.updateTime=#{data.updateTime},
            </if>
        </trim>
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </update>
    <!-- 批量更新 -->
    <update id="updateBatch" parameterType="paramDto">
        update mortals_sys_skin as a
        <trim prefix="set" suffixOverrides=",">
                        <trim prefix="categoryId=(case" suffix="ELSE categoryId end),">
                            <foreach collection="data.dataList" item="item" index="index" separator="" >
                                <choose>
                                    <when test="(colPickMode==0 and item.containsKey('categoryId')) or (colPickMode==1 and !item.containsKey('categoryId'))">
                                        when a.id=#{item.id} then #{item.categoryId}
                                    </when>
                                    <when test="(colPickMode==0 and item.containsKey('categoryIdIncrement')) or (colPickMode==1 and !item.containsKey('categoryIdIncrement'))">
                                        when a.id=#{item.id} then ifnull(a.categoryId,0) + #{item.categoryIdIncrement}
                                    </when>
                                </choose>
                            </foreach>
                        </trim>
                        <trim prefix="productId=(case" suffix="ELSE productId end),">
                            <foreach collection="data.dataList" item="item" index="index" separator="" >
                                <choose>
                                    <when test="(colPickMode==0 and item.containsKey('productId')) or (colPickMode==1 and !item.containsKey('productId'))">
                                        when a.id=#{item.id} then #{item.productId}
                                    </when>
                                    <when test="(colPickMode==0 and item.containsKey('productIdIncrement')) or (colPickMode==1 and !item.containsKey('productIdIncrement'))">
                                        when a.id=#{item.id} then ifnull(a.productId,0) + #{item.productIdIncrement}
                                    </when>
                                </choose>
                            </foreach>
                        </trim>
                <trim prefix="productName=(case" suffix="ELSE productName end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('productName')) or (colPickMode==1 and !item.containsKey('productName'))">
                            when a.id=#{item.id} then #{item.productName}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="cssFilePath=(case" suffix="ELSE cssFilePath end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('cssFilePath')) or (colPickMode==1 and !item.containsKey('cssFilePath'))">
                            when a.id=#{item.id} then #{item.cssFilePath}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="name=(case" suffix="ELSE name end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('name')) or (colPickMode==1 and !item.containsKey('name'))">
                            when a.id=#{item.id} then #{item.name}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="imageResolution=(case" suffix="ELSE imageResolution end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('imageResolution')) or (colPickMode==1 and !item.containsKey('imageResolution'))">
                            when a.id=#{item.id} then #{item.imageResolution}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="previewImagePath=(case" suffix="ELSE previewImagePath end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('previewImagePath')) or (colPickMode==1 and !item.containsKey('previewImagePath'))">
                            when a.id=#{item.id} then #{item.previewImagePath}
                        </if>
                    </foreach>
                </trim>
                        <trim prefix="sortNum=(case" suffix="ELSE sortNum end),">
                            <foreach collection="data.dataList" item="item" index="index" separator="" >
                                <choose>
                                    <when test="(colPickMode==0 and item.containsKey('sortNum')) or (colPickMode==1 and !item.containsKey('sortNum'))">
                                        when a.id=#{item.id} then #{item.sortNum}
                                    </when>
                                    <when test="(colPickMode==0 and item.containsKey('sortNumIncrement')) or (colPickMode==1 and !item.containsKey('sortNumIncrement'))">
                                        when a.id=#{item.id} then ifnull(a.sortNum,0) + #{item.sortNumIncrement}
                                    </when>
                                </choose>
                            </foreach>
                        </trim>
                        <trim prefix="used=(case" suffix="ELSE used end),">
                            <foreach collection="data.dataList" item="item" index="index" separator="" >
                                <choose>
                                    <when test="(colPickMode==0 and item.containsKey('used')) or (colPickMode==1 and !item.containsKey('used'))">
                                        when a.id=#{item.id} then #{item.used}
                                    </when>
                                    <when test="(colPickMode==0 and item.containsKey('usedIncrement')) or (colPickMode==1 and !item.containsKey('usedIncrement'))">
                                        when a.id=#{item.id} then ifnull(a.used,0) + #{item.usedIncrement}
                                    </when>
                                </choose>
                            </foreach>
                        </trim>
                <trim prefix="createTime=(case" suffix="ELSE createTime end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('createTime')) or (colPickMode==1 and !item.containsKey('createTime'))">
                            when a.id=#{item.id} then #{item.createTime}
                        </if>
                    </foreach>
                </trim>
                        <trim prefix="createUserId=(case" suffix="ELSE createUserId end),">
                            <foreach collection="data.dataList" item="item" index="index" separator="" >
                                <choose>
                                    <when test="(colPickMode==0 and item.containsKey('createUserId')) or (colPickMode==1 and !item.containsKey('createUserId'))">
                                        when a.id=#{item.id} then #{item.createUserId}
                                    </when>
                                    <when test="(colPickMode==0 and item.containsKey('createUserIdIncrement')) or (colPickMode==1 and !item.containsKey('createUserIdIncrement'))">
                                        when a.id=#{item.id} then ifnull(a.createUserId,0) + #{item.createUserIdIncrement}
                                    </when>
                                </choose>
                            </foreach>
                        </trim>
                <trim prefix="updateTime=(case" suffix="ELSE updateTime end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('updateTime')) or (colPickMode==1 and !item.containsKey('updateTime'))">
                            when a.id=#{item.id} then #{item.updateTime}
                        </if>
                    </foreach>
                </trim>
        </trim>
        where id in
        <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </update>
    <!-- 根据主健查询 -->
    <select id="getByKey" parameterType="paramDto" resultMap="SkinEntity-Map">
        select <include refid="_columns"/>
        from mortals_sys_skin as a
        where a.id=#{condition.id}
    </select>
    <!-- 根据主健删除 -->
    <delete id="deleteByKey" parameterType="paramDto">
        delete a.* from mortals_sys_skin as a where a.id=#{condition.id}
    </delete>
    <!-- 根据主健删除一批，针对单一主健有效 -->
    <delete id="deleteByKeys">
        delete from mortals_sys_skin where id in
        <foreach collection="array" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <!-- 根据主健列表删除一批，针对单一主健有效 -->
    <delete id="deleteByKeyList">
        delete from mortals_sys_skin where id in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <!-- 根据对象列表删除一批，针对单一主健有效 -->
    <delete id="deleteByEntityList">
        delete from mortals_sys_skin where id in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </delete>
    <!-- 根据paramDto删除一批 -->
    <delete id="deleteByMap" parameterType="paramDto">
        delete a.* from mortals_sys_skin as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </delete>
    <!-- 获取列表 -->
    <select id="getList" parameterType="paramDto" resultMap="SkinEntity-Map">
        select <include refid="_columns"/>
        from mortals_sys_skin as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
        <include refid="_orderCols_"/>
    </select>



    <!-- 获取 -->
    <select id="getListCount" parameterType="paramDto" resultType="int">
        select count(1)
        from mortals_sys_skin as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </select>
    <!-- 条件映射 -->
    <sql id="_condition_">
        <if test="condition != null and !condition.isEmpty()">
            <!-- 条件映射-普通条件 -->
            <include refid="_condition_param_">
                <property name="_conditionParam_" value="condition"/>
                <property name="_conditionType_" value="and"/>
            </include>
            <!-- 条件映射-集合之间使用AND，集合中元素使用OR-(list[0].1 or list[0].2) and (list[1].3 or list[1].4) -->
            <if test="condition.containsKey('andConditionList') and !condition.andConditionList.isEmpty()">
                and
                <foreach collection="condition.andConditionList" open="(" close=")" index="index" item="andCondition" separator=" and ">
                    <trim prefixOverrides="or" prefix="(" suffix=")">
                        <include refid="_condition_param_">
                            <property name="_conditionParam_" value="andCondition"/>
                            <property name="_conditionType_" value="or"/>
                        </include>
                    </trim>
                </foreach>
            </if>
            <!-- 条件映射-集合之间使用OR，集合中元素使用AND-(list[0].1 and list[0].2) or (list[1].3 and list[1].4) -->
            <if test="condition.containsKey('orConditionList') and !condition.orConditionList.isEmpty()">
                and
                <foreach collection="condition.orConditionList" open="(" close=")" index="index" item="orCondition" separator=" or ">
                    <trim prefixOverrides="and" prefix="(" suffix=")">
                        <include refid="_condition_param_">
                            <property name="_conditionParam_" value="orCondition"/>
                            <property name="_conditionType_" value="and"/>
                        </include>
                    </trim>
                </foreach>
            </if>
        </if>
    </sql>
    <!-- 条件映射-代参数 -->
    <sql id="_condition_param_">
        <bind name="conditionParamRef" value="${_conditionParam_}"/>
        <if test="conditionParamRef.containsKey('id')">
            <if test="conditionParamRef.id != null">
                ${_conditionType_} a.id=#{${_conditionParam_}.id}
            </if>
        </if>
            <if test="conditionParamRef.containsKey('id')">
                <if test="conditionParamRef.id != null ">
                    ${_conditionType_} a.id = #{${_conditionParam_}.id}
                </if>
                <if test="conditionParamRef.id == null">
                    ${_conditionType_} a.id is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('idList') and conditionParamRef.idList.size() > 0">
                ${_conditionType_} a.id in
                <foreach collection="conditionParamRef.idList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('idNotList') and conditionParamRef.idNotList.size() > 0">
                ${_conditionType_} a.id not in
                <foreach collection="conditionParamRef.idNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('idStart') and conditionParamRef.idStart != null">
                ${_conditionType_} a.id <![CDATA[ >= ]]> #{${_conditionParam_}.idStart}
            </if>
            <if test="conditionParamRef.containsKey('idEnd') and conditionParamRef.idEnd != null">
                ${_conditionType_} a.id <![CDATA[ <= ]]> #{${_conditionParam_}.idEnd}
            </if>

            <if test="conditionParamRef.containsKey('categoryId')">
                <if test="conditionParamRef.categoryId != null ">
                    ${_conditionType_} a.categoryId = #{${_conditionParam_}.categoryId}
                </if>
                <if test="conditionParamRef.categoryId == null">
                    ${_conditionType_} a.categoryId is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('categoryIdList') and conditionParamRef.categoryIdList.size() > 0">
                ${_conditionType_} a.categoryId in
                <foreach collection="conditionParamRef.categoryIdList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('categoryIdNotList') and conditionParamRef.categoryIdNotList.size() > 0">
                ${_conditionType_} a.categoryId not in
                <foreach collection="conditionParamRef.categoryIdNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('categoryIdStart') and conditionParamRef.categoryIdStart != null">
                ${_conditionType_} a.categoryId <![CDATA[ >= ]]> #{${_conditionParam_}.categoryIdStart}
            </if>
            <if test="conditionParamRef.containsKey('categoryIdEnd') and conditionParamRef.categoryIdEnd != null">
                ${_conditionType_} a.categoryId <![CDATA[ <= ]]> #{${_conditionParam_}.categoryIdEnd}
            </if>

            <if test="conditionParamRef.containsKey('productId')">
                <if test="conditionParamRef.productId != null ">
                    ${_conditionType_} a.productId = #{${_conditionParam_}.productId}
                </if>
                <if test="conditionParamRef.productId == null">
                    ${_conditionType_} a.productId is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('productIdList') and conditionParamRef.productIdList.size() > 0">
                ${_conditionType_} a.productId in
                <foreach collection="conditionParamRef.productIdList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('productIdNotList') and conditionParamRef.productIdNotList.size() > 0">
                ${_conditionType_} a.productId not in
                <foreach collection="conditionParamRef.productIdNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('productIdStart') and conditionParamRef.productIdStart != null">
                ${_conditionType_} a.productId <![CDATA[ >= ]]> #{${_conditionParam_}.productIdStart}
            </if>
            <if test="conditionParamRef.containsKey('productIdEnd') and conditionParamRef.productIdEnd != null">
                ${_conditionType_} a.productId <![CDATA[ <= ]]> #{${_conditionParam_}.productIdEnd}
            </if>


            <if test="conditionParamRef.containsKey('productName')">
                <if test="conditionParamRef.productName != null and conditionParamRef.productName != ''">
                    ${_conditionType_} a.productName like #{${_conditionParam_}.productName}
                </if>
                <if test="conditionParamRef.productName == null">
                    ${_conditionType_} a.productName is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('productNameList') and conditionParamRef.productNameList.size() > 0">
                ${_conditionType_} a.productName in
                <foreach collection="conditionParamRef.productNameList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('productNameNotList') and conditionParamRef.productNameNotList.size() > 0">
                ${_conditionType_} a.productName not in
                <foreach collection="conditionParamRef.productNameNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>

            <if test="conditionParamRef.containsKey('cssFilePath')">
                <if test="conditionParamRef.cssFilePath != null and conditionParamRef.cssFilePath != ''">
                    ${_conditionType_} a.cssFilePath like #{${_conditionParam_}.cssFilePath}
                </if>
                <if test="conditionParamRef.cssFilePath == null">
                    ${_conditionType_} a.cssFilePath is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('cssFilePathList') and conditionParamRef.cssFilePathList.size() > 0">
                ${_conditionType_} a.cssFilePath in
                <foreach collection="conditionParamRef.cssFilePathList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('cssFilePathNotList') and conditionParamRef.cssFilePathNotList.size() > 0">
                ${_conditionType_} a.cssFilePath not in
                <foreach collection="conditionParamRef.cssFilePathNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>

            <if test="conditionParamRef.containsKey('name')">
                <if test="conditionParamRef.name != null and conditionParamRef.name != ''">
                    ${_conditionType_} a.name like #{${_conditionParam_}.name}
                </if>
                <if test="conditionParamRef.name == null">
                    ${_conditionType_} a.name is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('nameList') and conditionParamRef.nameList.size() > 0">
                ${_conditionType_} a.name in
                <foreach collection="conditionParamRef.nameList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('nameNotList') and conditionParamRef.nameNotList.size() > 0">
                ${_conditionType_} a.name not in
                <foreach collection="conditionParamRef.nameNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>

            <if test="conditionParamRef.containsKey('imageResolution')">
                <if test="conditionParamRef.imageResolution != null and conditionParamRef.imageResolution != ''">
                    ${_conditionType_} a.imageResolution like #{${_conditionParam_}.imageResolution}
                </if>
                <if test="conditionParamRef.imageResolution == null">
                    ${_conditionType_} a.imageResolution is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('imageResolutionList') and conditionParamRef.imageResolutionList.size() > 0">
                ${_conditionType_} a.imageResolution in
                <foreach collection="conditionParamRef.imageResolutionList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('imageResolutionNotList') and conditionParamRef.imageResolutionNotList.size() > 0">
                ${_conditionType_} a.imageResolution not in
                <foreach collection="conditionParamRef.imageResolutionNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>

            <if test="conditionParamRef.containsKey('previewImagePath')">
                <if test="conditionParamRef.previewImagePath != null and conditionParamRef.previewImagePath != ''">
                    ${_conditionType_} a.previewImagePath like #{${_conditionParam_}.previewImagePath}
                </if>
                <if test="conditionParamRef.previewImagePath == null">
                    ${_conditionType_} a.previewImagePath is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('previewImagePathList') and conditionParamRef.previewImagePathList.size() > 0">
                ${_conditionType_} a.previewImagePath in
                <foreach collection="conditionParamRef.previewImagePathList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('previewImagePathNotList') and conditionParamRef.previewImagePathNotList.size() > 0">
                ${_conditionType_} a.previewImagePath not in
                <foreach collection="conditionParamRef.previewImagePathNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('sortNum')">
                <if test="conditionParamRef.sortNum != null ">
                    ${_conditionType_} a.sortNum = #{${_conditionParam_}.sortNum}
                </if>
                <if test="conditionParamRef.sortNum == null">
                    ${_conditionType_} a.sortNum is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('sortNumList') and conditionParamRef.sortNumList.size() > 0">
                ${_conditionType_} a.sortNum in
                <foreach collection="conditionParamRef.sortNumList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('sortNumNotList') and conditionParamRef.sortNumNotList.size() > 0">
                ${_conditionType_} a.sortNum not in
                <foreach collection="conditionParamRef.sortNumNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('sortNumStart') and conditionParamRef.sortNumStart != null">
                ${_conditionType_} a.sortNum <![CDATA[ >= ]]> #{${_conditionParam_}.sortNumStart}
            </if>
            <if test="conditionParamRef.containsKey('sortNumEnd') and conditionParamRef.sortNumEnd != null">
                ${_conditionType_} a.sortNum <![CDATA[ <= ]]> #{${_conditionParam_}.sortNumEnd}
            </if>

            <if test="conditionParamRef.containsKey('used')">
                <if test="conditionParamRef.used != null ">
                    ${_conditionType_} a.used = #{${_conditionParam_}.used}
                </if>
                <if test="conditionParamRef.used == null">
                    ${_conditionType_} a.used is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('usedList') and conditionParamRef.usedList.size() > 0">
                ${_conditionType_} a.used in
                <foreach collection="conditionParamRef.usedList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('usedNotList') and conditionParamRef.usedNotList.size() > 0">
                ${_conditionType_} a.used not in
                <foreach collection="conditionParamRef.usedNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('usedStart') and conditionParamRef.usedStart != null">
                ${_conditionType_} a.used <![CDATA[ >= ]]> #{${_conditionParam_}.usedStart}
            </if>
            <if test="conditionParamRef.containsKey('usedEnd') and conditionParamRef.usedEnd != null">
                ${_conditionType_} a.used <![CDATA[ <= ]]> #{${_conditionParam_}.usedEnd}
            </if>


            <if test="conditionParamRef.containsKey('createTime')">
                <if test="conditionParamRef.createTime != null ">
                    ${_conditionType_} a.createTime = #{${_conditionParam_}.createTime}
                </if>
                <if test="conditionParamRef.createTime == null">
                    ${_conditionType_} a.createTime is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('createTimeStart') and conditionParamRef.createTimeStart != null and conditionParamRef.createTimeStart!=''">
                ${_conditionType_} a.createTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
            </if>
            <if test="conditionParamRef.containsKey('createTimeEnd') and conditionParamRef.createTimeEnd != null and conditionParamRef.createTimeEnd!=''">
                ${_conditionType_} a.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
            </if>
            <if test="conditionParamRef.containsKey('createUserId')">
                <if test="conditionParamRef.createUserId != null ">
                    ${_conditionType_} a.createUserId = #{${_conditionParam_}.createUserId}
                </if>
                <if test="conditionParamRef.createUserId == null">
                    ${_conditionType_} a.createUserId is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('createUserIdList') and conditionParamRef.createUserIdList.size() > 0">
                ${_conditionType_} a.createUserId in
                <foreach collection="conditionParamRef.createUserIdList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('createUserIdNotList') and conditionParamRef.createUserIdNotList.size() > 0">
                ${_conditionType_} a.createUserId not in
                <foreach collection="conditionParamRef.createUserIdNotList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="conditionParamRef.containsKey('createUserIdStart') and conditionParamRef.createUserIdStart != null">
                ${_conditionType_} a.createUserId <![CDATA[ >= ]]> #{${_conditionParam_}.createUserIdStart}
            </if>
            <if test="conditionParamRef.containsKey('createUserIdEnd') and conditionParamRef.createUserIdEnd != null">
                ${_conditionType_} a.createUserId <![CDATA[ <= ]]> #{${_conditionParam_}.createUserIdEnd}
            </if>


            <if test="conditionParamRef.containsKey('updateTime')">
                <if test="conditionParamRef.updateTime != null ">
                    ${_conditionType_} a.updateTime = #{${_conditionParam_}.updateTime}
                </if>
                <if test="conditionParamRef.updateTime == null">
                    ${_conditionType_} a.updateTime is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('updateTimeStart') and conditionParamRef.updateTimeStart != null and conditionParamRef.updateTimeStart!=''">
                ${_conditionType_} a.updateTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
            </if>
            <if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
                ${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
            </if>
    </sql>
    <sql id="_orderCols_">
        <if test="orderColList != null and !orderColList.isEmpty()">
            order by
            <trim suffixOverrides=","  suffix="">
                <foreach collection="orderColList" open="" close="" index="index" item="item" separator=",">
                     ${item.colName} ${item.sortKind}
                </foreach>
            </trim>
        </if>
        <if test="(orderColList == null or orderColList.isEmpty()) and orderCol != null and !orderCol.isEmpty()">
            order by
            <trim suffixOverrides=","  suffix="">
                    <if test="orderCol.containsKey('id')">
                        a.id
                        <if test='orderCol.id != null and "DESC".equalsIgnoreCase(orderCol.id)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('categoryId')">
                        a.categoryId
                        <if test='orderCol.categoryId != null and "DESC".equalsIgnoreCase(orderCol.categoryId)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('productId')">
                        a.productId
                        <if test='orderCol.productId != null and "DESC".equalsIgnoreCase(orderCol.productId)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('productName')">
                        a.productName
                        <if test='orderCol.productName != null and "DESC".equalsIgnoreCase(orderCol.productName)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('cssFilePath')">
                        a.cssFilePath
                        <if test='orderCol.cssFilePath != null and "DESC".equalsIgnoreCase(orderCol.cssFilePath)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('name')">
                        a.name
                        <if test='orderCol.name != null and "DESC".equalsIgnoreCase(orderCol.name)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('imageResolution')">
                        a.imageResolution
                        <if test='orderCol.imageResolution != null and "DESC".equalsIgnoreCase(orderCol.imageResolution)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('previewImagePath')">
                        a.previewImagePath
                        <if test='orderCol.previewImagePath != null and "DESC".equalsIgnoreCase(orderCol.previewImagePath)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('sortNum')">
                        a.sortNum
                        <if test='orderCol.sortNum != null and "DESC".equalsIgnoreCase(orderCol.sortNum)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('used')">
                        a.used
                        <if test='orderCol.used != null and "DESC".equalsIgnoreCase(orderCol.used)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('createTime')">
                        a.createTime
                        <if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('createUserId')">
                        a.createUserId
                        <if test='orderCol.createUserId != null and "DESC".equalsIgnoreCase(orderCol.createUserId)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('updateTime')">
                        a.updateTime
                        <if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
                        ,
                    </if>
            </trim>
        </if>
    </sql>
    <sql id="_group_by_">
        <if test="groupList != null and !groupList.isEmpty()">
            GROUP BY
            <trim suffixOverrides=","  suffix="">
                <foreach collection="groupList" open="" close="" index="index" item="item" separator=",">
                    ${item}
                </foreach>
            </trim>
        </if>
    </sql>
</mapper>