<?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.ruoyi.web.modules.category.mapper.BizInformationCategoryMapper">

    <resultMap type="com.ruoyi.web.modules.category.domain.BizInformationCategory" id="BizInformationCategoryResult">
        <id     property="id"             column="id"/>
        <result property="categoryCode"   column="category_code"/>
        <result property="categoryName"   column="category_name"/>
        <result property="parentCode"     column="parent_code"/>
        <result property="categoryType"   column="category_type"/>
        <result property="moduleId"       column="module_id"/>
        <result property="visible"        column="visible"/>
        <result property="delFlag"        column="del_flag"/>
        <result property="createBy"       column="create_by"/>
        <result property="createTime"     column="create_time"/>
        <result property="updateBy"       column="update_by"/>
        <result property="updateTime"     column="update_time"/>
        <result property="remark"         column="remark"/>
    </resultMap>

    <sql id="selectCategoryColumns">
        id, category_code, category_name, parent_code, category_type, module_id, visible, del_flag,
        create_by, create_time, update_by, update_time, remark
    </sql>

    <select id="selectVisibleActiveForTree" parameterType="com.ruoyi.web.modules.category.domain.BizInformationCategory"
            resultMap="BizInformationCategoryResult">
        select <include refid="selectCategoryColumns"/>
        from biz_information_category
        where del_flag = '0'
          and visible = '1'
        <if test="categoryType != null and categoryType != ''">
            and category_type = #{categoryType}
        </if>
        <if test="moduleId != null and moduleId != ''">
            and module_id = #{moduleId}
        </if>
        order by category_code asc
    </select>

    <select id="selectChildrenByParent" parameterType="com.ruoyi.web.modules.category.domain.BizInformationCategory"
            resultMap="BizInformationCategoryResult">
        select <include refid="selectCategoryColumns"/>
        from biz_information_category
        where del_flag = '0'
          and parent_code = #{parentCode}
        <if test="categoryType != null and categoryType != ''">
            and category_type = #{categoryType}
        </if>
        order by category_code asc
    </select>

</mapper>
