<?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="cn.com.countrygarden.bi.main.dao.ck.CkCleanerFileidRoleMapper">

    <select id="getAllFileidRole" resultType="cn.com.countrygarden.bi.main.dto.ck.CkFileidRoleListVo">
        SELECT DISTINCT
        cfc.id,
        cfc.field_code fieldCode,
        cfc.field_name fieldName,
        cfc.parent_id parentId,
        cfc.type,
        cfc. STATUS,
        cfc.soft,
        cfr.is_write isWrite
        FROM
        ck_cleaner_field_config cfc
        LEFT JOIN ck_cleaner_fileid_role cfr ON cfr.field_code = cfc.field_code   and role_code=#{query.roleCode}
        AND cfr. STATUS = 1
        <where>
            cfc.status=1

            <if test="query!=null">
                <if test="query.id!=null">
                    and cfc.id  <![CDATA[<>]]> #{query.id}
                </if>
                <if test="query.type!=null">
                    and cfc.type=#{query.type}
                </if>
                <if test="query.parentId!=null">
                    and cfc.parent_id=#{query.parentId}
                </if>
            </if>
        </where>
        ORDER BY cfc.soft,cfc.id desc
    </select>


</mapper>