<?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="org.springblade.modules.cdglinfos.mapper.GlInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="glinfoResultMap" type="org.springblade.modules.cdglinfos.entity.GlInfoEntity">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="sort" property="sort"/>
        <result column="flag" property="flag"/>
        <result column="img" property="img"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>


    <select id="selectGlInfoPage" resultMap="glinfoResultMap">
        select * from cd_glinfo where is_deleted = 0 order by sort
    </select>


    <select id="exportGlInfo" resultType="org.springblade.modules.cdglinfos.excel.GlInfoExcel">
        SELECT * FROM cd_glinfo ${ew.customSqlSegment}
    </select>

    <select id="getAppByUserRole" resultType="org.springblade.modules.cdglinfos.entity.GlInfoEntity">
        SELECT
           name,
           sort,
           img,
           flag
        FROM
            cd_glinfo
        WHERE 1 = 1
        <if test="null != appName and '' != appName">
            AND name LIKE '%' || #{appName} || '%'
        </if>
            AND flag = '1'
    </select>

    <select id="getSydwMenu" resultType="org.springblade.modules.sqjw.sydw.pojo.vo.SydwMenuVO">
        SELECT
            zd.id,
            cg.name,
            cg.img AS icon
        FROM
            jdrh.cd_glinfo cg
        LEFT JOIN jdrh.blade_dict_biz zd ON zd.dict_value = cg.name
        WHERE
            cg.is_deleted = 0
        AND cg.flag = #{flag}
        <if test="null != appName and '' != appName">
        AND cg.name LIKE '%' || #{appName} || '%'
        </if>
        ORDER BY cg.sort
    </select>

</mapper>
