<?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.ankaibei.workFlow.common.flow.dao.FlowCategoryMapper">
    <resultMap id="BaseResultMap" type="com.ankaibei.workFlow.common.flow.model.FlowCategory">
        <id column="category_id" jdbcType="BIGINT" property="categoryId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="code" jdbcType="VARCHAR" property="code"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
    </resultMap>

    <!-- 如果有逻辑删除字段过滤，请写到这里 -->
    <sql id="filterRef">
        <!-- 这里必须加上全包名，否则当filterRef被其他Mapper.xml包含引用的时候，就会调用Mapper.xml中的该SQL片段 -->
        <include refid="com.ankaibei.workFlow.common.flow.dao.FlowCategoryMapper.inputFilterRef"/>
    </sql>

    <!-- 这里仅包含调用接口输入的主表过滤条件 -->
    <sql id="inputFilterRef">
        <if test="flowCategoryFilter != null">
            <if test="flowCategoryFilter.name != null and flowCategoryFilter.name != ''">
                AND zz_flow_category.name like "%"#{flowCategoryFilter.name}"%"
            </if>
            <if test="flowCategoryFilter.code != null and flowCategoryFilter.code != ''">
                AND zz_flow_category.code like "%"#{flowCategoryFilter.code}"%"
            </if>
        </if>
    </sql>

    <select id="getFlowCategoryList" resultMap="BaseResultMap"
            parameterType="com.ankaibei.workFlow.common.flow.model.FlowCategory">
        SELECT * FROM zz_flow_category
        <where>
            <include refid="filterRef"/>
        </where>
        ORDER BY create_time desc
    </select>
</mapper>
