<?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.usky.system.mapper.SysTenantConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.usky.system.domain.SysTenantConfig">
        <id column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="login_title" property="loginTitle"/>
        <result column="login_logo" property="loginLogo"/>
        <result column="login_back_url" property="loginBackUrl"/>
        <result column="login_footer" property="loginFooter"/>
        <result column="login_type" property="loginType"/>
        <result column="middle_logo" property="middleLogo"/>
        <result column="middle_back_url" property="middleBackUrl"/>
        <result column="middle_title" property="middleTitle"/>
        <result column="middle_footer" property="middleFooter"/>
        <result column="home_logo" property="homeLogo"/>
        <result column="home_page_url" property="homePageUrl"/>
        <result column="home_layout" property="homeLayout"/>
        <result column="home_style" property="homeStyle"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="label_icon" property="labelIcon"/>
        <result column="middle_status" property="middleStatus"/>
        <result column="large_screen_url" property="largeScreenUrl"/>
        <result column="cloud_type" property="cloudType"/>
        <result column="cloud_url" property="cloudUrl"/>
        <result column="message_status" property="messageStatus"/>
    </resultMap>
    <select id="getTenantConfig" resultType="com.usky.system.service.vo.SysTenantConfigVo">
        SELECT
        b.id as id,a.id as tenantId,ifNULL(b.login_title,a.tenant_name) as loginTitle,b.login_logo,b.login_back_url,b.login_footer,b.login_type,b.label_icon
        FROM
        sys_tenant AS a
        LEFT JOIN sys_tenant_config AS b ON a.id = b.tenant_id
        <where>
            a. STATUS = 0
            AND a.domain = #{url}
        </where>
    </select>

    <select id="getTenantConfig1" resultType="com.usky.system.service.vo.SysTenantConfigVo">
        SELECT
        b.id as id,a.id as tenantId,ifNULL(b.login_title,a.tenant_name) as loginTitle,b.login_logo,b.login_back_url,b.login_footer,b.login_type,b.label_icon
        FROM
        sys_tenant AS a
        LEFT JOIN sys_tenant_config AS b ON a.id = b.tenant_id
        LIMIT 1
    </select>

    <select id="getMenuBoxList" resultType="com.usky.system.domain.SysMenu">
        SELECT a.*
        FROM sys_menu AS a
                 JOIN sys_tenant_menu AS b ON a.menu_id = b.menu_id
        WHERE a.status = 0
          AND a.visible = 0
          AND a.menu_type = #{menuType}
          and b.tenant_id = #{tenantId}
    </select>
</mapper>
