<?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.cool.store.mapper.config.ConfigItemCategoryMapper">

    <resultMap id="BaseResultMap" type="com.cool.store.entity.config.ConfigItemCategoryDO">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="category_code" property="categoryCode" jdbcType="VARCHAR"/>
        <result column="category_name" property="categoryName" jdbcType="VARCHAR"/>
        <result column="sort_no" property="sortNo" jdbcType="INTEGER"/>
        <result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
        <result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="INTEGER"/>
        <result column="is_deleted" property="isDeleted" jdbcType="INTEGER"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="created_user_id" property="createdUserId" jdbcType="VARCHAR"/>
        <result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
        <result column="updated_user_id" property="updatedUserId" jdbcType="VARCHAR"/>
        <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <resultMap id="CategoryVOResultMap" type="com.cool.store.vo.config.ConfigItemCategoryVO">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="category_code" property="categoryCode" jdbcType="VARCHAR"/>
        <result column="category_name" property="categoryName" jdbcType="VARCHAR"/>
        <result column="sort_no" property="sortNo" jdbcType="INTEGER"/>
        <result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
        <result column="video_url" property="videoUrl" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="INTEGER"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="created_user_id" property="createdUserId" jdbcType="VARCHAR"/>
        <result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
        <result column="updated_user_id" property="updatedUserId" jdbcType="VARCHAR"/>
        <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, category_code, category_name, sort_no, image_url, video_url,
        status, is_deleted, remark, created_user_id, created_time, updated_user_id, updated_time
    </sql>

    <select id="queryByCondition" resultMap="CategoryVOResultMap">
        SELECT id, category_code, category_name, sort_no, image_url, video_url,
               status, remark, created_user_id, created_time, updated_user_id, updated_time
        FROM zxjp_cfg_item_category
        WHERE is_deleted = 0
        <if test="categoryName != null and categoryName != ''">
            AND category_name LIKE CONCAT('%', #{categoryName}, '%')
        </if>
        <if test="status != null">
            AND status = #{status}
        </if>
        ORDER BY sort_no ASC, id DESC
    </select>

    <select id="queryAllActiveList" resultType="com.cool.store.vo.config.ConfigItemCategoryBaseInfoVO">
        SELECT category_code, category_name
        FROM zxjp_cfg_item_category
        WHERE is_deleted = 0 AND status = 1 ORDER BY sort_no ASC, id DESC
    </select>

</mapper>
