<?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.slodon.b2b2c.dao.read.cms.HelpArticleCategoryReadMapper">
    <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.StoreCmsArticleCategory">
        <id column="category_id" property="categoryId" />
        <result column="category_name" property="categoryName" />
        <result column="sort" property="sort" />
        <result column="is_show" property="isShow" />
        <result column="create_id" property="createId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <!--按照主键值进行操作-->
    <sql id="pkWhere">
        WHERE `category_id` = #{primaryKey}
    </sql>
    <!--操作条件-->
    <sql id="whereCondition">
        <if test="example != null">
            <trim prefix="WHERE" prefixOverrides="AND|OR">
                <if test="example.categoryIdNotEquals != null">
                    AND `category_id` != #{example.categoryIdNotEquals}
                </if>
                <if test="example.categoryIdIn != null">
                    AND `category_id` in (${example.categoryIdIn})
                </if>
                <if test="example.categoryName != null">
                    AND `category_name` = #{example.categoryName}
                </if>
                <if test="example.categoryNameLike != null">
                    AND `category_name` like concat('%',#{example.categoryNameLike},'%')
                </if>
                <if test="example.sort != null">
                    AND `sort` = #{example.sort}
                </if>
                <if test="example.isShow != null">
                    AND `is_show` = #{example.isShow}
                </if>
                <if test="example.createId != null">
                    AND `create_id` = #{example.createId}
                </if>
                <if test="example.createTimeAfter != null">
                    AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
                </if>
                <if test="example.createTimeBefore != null">
                    AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
                </if>
                <if test="example.updateTimeAfter != null">
                    AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
                </if>
                <if test="example.updateTimeBefore != null">
                    AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
                </if>
            </trim>
        </if>
    </sql>
    <!--排序条件-->
    <sql id="orderBy">
        ORDER BY `sort`
    </sql>
    <sql id="orderByOther">
        order by ${example.orderBy}
    </sql>
    <!--分组条件-->
    <sql id="groupBy">
        group by ${example.groupBy}
    </sql>
    <!--分页条件-->
    <sql id="limit">
        <if test="size != null and size &gt; 0">
            limit #{startRow},#{size}
        </if>
    </sql>
    <!--查询符合条件的记录数-->
    <select id="countByExample" parameterType="com.slodon.b2b2c.cms.example.HelpArticleCategoryExample" resultType="java.lang.Integer">
        SELECT
        COUNT(*)
        FROM `store_cms_article_category`
        <include refid="whereCondition" />
    </select>
    <!--根据主键查询记录-->
    <select id="getByPrimaryKey" resultMap="resultMap">
        SELECT
        *
        FROM `store_cms_article_category`
        <include refid="pkWhere" />
    </select>
    <!--查询符合条件的记录(所有字段)-->
    <select id="listByExample" resultMap="resultMap">
        SELECT
        *
        FROM `store_cms_article_category`
        <include refid="whereCondition" />
        <if test="example.groupBy != null">
            <include refid="groupBy" />
        </if>
        <choose>
            <when test="example.orderBy != null">
                <include refid="orderByOther" />
            </when>
            <otherwise>
                <include refid="orderBy" />
            </otherwise>
        </choose>
    </select>
    <!--分页查询符合条件的记录(所有字段)-->
    <select id="listPageByExample" resultMap="resultMap">
        SELECT
        *
        FROM `store_cms_article_category`
        <include refid="whereCondition" />
        <if test="example.groupBy != null">
            <include refid="groupBy" />
        </if>
        <choose>
            <when test="example.orderBy != null">
                <include refid="orderByOther" />
            </when>
            <otherwise>
                <include refid="orderBy" />
            </otherwise>
        </choose>
        <include refid="limit" />
    </select>
    <!--查询符合条件的记录(指定字段)-->
    <select id="listFieldsByExample" resultMap="resultMap">
        SELECT
        ${fields}
        FROM `store_cms_article_category`
        <include refid="whereCondition" />
        <if test="example.groupBy != null">
            <include refid="groupBy" />
        </if>
        <choose>
            <when test="example.orderBy != null">
                <include refid="orderByOther" />
            </when>
            <otherwise>
                <include refid="orderBy" />
            </otherwise>
        </choose>
    </select>
    <!--分页查询符合条件的记录(指定字段)-->
    <select id="listFieldsPageByExample" resultMap="resultMap">
        SELECT
        ${fields}
        FROM `store_cms_article_category`
        <include refid="whereCondition" />
        <if test="example.groupBy != null">
            <include refid="groupBy" />
        </if>
        <choose>
            <when test="example.orderBy != null">
                <include refid="orderByOther" />
            </when>
            <otherwise>
                <include refid="orderBy" />
            </otherwise>
        </choose>
        <include refid="limit" />
    </select>
</mapper>