<?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.benyun.mapper.CategoryMapper">
    <resultMap type="com.ruoyi.benyun.entity.Category" id="ProvinceResult">
        <result property="code" column="addr_code"/>
        <result property="name" column="province"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="CityResult">
        <result property="code" column="addr_code"/>
        <result property="name" column="city"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="ZoneResult">
        <result property="code" column="addr_code"/>
        <result property="name" column="district"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="BigTypeResult">
        <result property="code" column="type_code_by"/>
        <result property="name" column="big_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="MidTypeResult">
        <result property="code" column="type_code_by"/>
        <result property="name" column="mid_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="SubTypeResult">
        <result property="code" column="type_code_by"/>
        <result property="name" column="sub_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="BigManageResult">
        <result property="code" column="manage_type_code"/>
        <result property="name" column="big_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="MidManageResult">
        <result property="code" column="manage_type_code"/>
        <result property="name" column="mid_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="SubManageResult">
        <result property="code" column="manage_type_code"/>
        <result property="name" column="sub_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="WdTypeResult">
        <result property="code" column="wd_type_code"/>
        <result property="name" column="wd_type_name"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="BigIndustryResult">
        <result property="code" column="industry_code"/>
        <result property="name" column="big_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="MidIndustryResult">
        <result property="code" column="industry_code"/>
        <result property="name" column="mid_category"/>
    </resultMap>
    <resultMap type="com.ruoyi.benyun.entity.Category" id="SubIndustryResult">
        <result property="code" column="industry_code"/>
        <result property="name" column="sub_category"/>
    </resultMap>
    <select id="searchProvince" resultMap="ProvinceResult">
        select * from `ddt_addr_category` where city = ''
    </select>
    <select id="searchCityByProvince" resultMap="CityResult">
        select * from`ddt_addr_category` where city <![CDATA[<>]]> '' and district = '' and province = #{province};
    </select>
    <select id="searchZoneByCity" resultMap="ZoneResult">
        select * from `ddt_addr_category` where city <![CDATA[<>]]> '' and district <![CDATA[<>]]> '' and city = #{city};
    </select>
    <select id="searchBigCategory" resultMap="BigTypeResult">
        select * from `ddt_type_by` where mid_category = ''
    </select>
    <select id="searchMidCategoryByBig" resultMap="MidTypeResult">
        select * from `ddt_type_by` where mid_category <![CDATA[<>]]> '' and sub_category = '' and big_category = #{bigCategory}
    </select>
    <select id="searchSubCategoryByMid" resultMap="SubTypeResult">
        select * from `ddt_type_by` where mid_category <![CDATA[<>]]> '' and sub_category <![CDATA[<>]]> '' and mid_category = #{midCategory}
    </select>
    <select id="searchWdType" resultMap="WdTypeResult">
        SELECT * FROM `ddt_wd_type`;
    </select>
    <select id="searchBigManage" resultMap="BigManageResult">
        select * from `ddt_manage_type` where mid_category = ''
    </select>
    <select id="searchMidManageByBig" resultMap="MidManageResult">
        select * from `ddt_manage_type` where mid_category <![CDATA[<>]]> '' and sub_category = '' and big_category = #{bigCategory}
    </select>
    <select id="searchSubManageByMid" resultMap="SubManageResult">
        select * from `ddt_manage_type` where mid_category <![CDATA[<>]]> '' and sub_category <![CDATA[<>]]> '' and mid_category = #{midCategory}
    </select>
    <select id="searchBigIndustry" resultMap="BigIndustryResult">
        select * from `ddt_industry_category` where mid_category = ''
    </select>
    <select id="searchMidIndustryByBig" resultMap="MidIndustryResult">
        select * from `ddt_industry_category` where mid_category <![CDATA[<>]]> '' and sub_category = '' and big_category = #{bigCategory}
    </select>
    <select id="searchSubIndustryByMid" resultMap="SubIndustryResult">
        select * from `ddt_industry_category` where mid_category <![CDATA[<>]]> '' and sub_category <![CDATA[<>]]> '' and mid_category = #{midCategory}
    </select>
    <select id="searchSubIndustryByCode" resultMap="SubIndustryResult">
        select * from `ddt_industry_category` where industry_code = #{industryCode}
    </select>
</mapper>
