
// 








namespace SafeCampus.Web.Core;

/// <summary>
/// 系统通用控制器,一般是一些公共的接口
/// </summary>
[Route("sys")]
public class CommonController : BaseController
{
    private readonly ISysOrgService _sysOrgService;
    private readonly IConfigService _configService;

    public CommonController(IConfigService configService, ISysOrgService sysOrgService)
    {
        _sysOrgService = sysOrgService;
        _configService = configService;
    }


    /// <summary>
    /// 获取系统基础配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("ico")]
    [AllowAnonymous]
    [NonUnify]
    public async Task<dynamic> Ico()
    {
        return await _configService.GetIco();
    }

    /// <summary>
    /// 获取系统基础配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("sysInfo")]
    [AllowAnonymous]
    public async Task<dynamic> SysInfo()
    {
        var sysBase = await _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_BASE);
        //排除掉一些不需要的配置
        var configKeys = new List<string>()
        {
            SysConfigConst.SYS_ICO,
            SysConfigConst.SYS_WEB_STATUS,
            SysConfigConst.SYS_WEB_CLOSE_PROMPT,
            SysConfigConst.SYS_DEFAULT_WORKBENCH_DATA
        };
        sysBase = sysBase.Where(x => !configKeys.Contains(x.ConfigKey)).ToList();
        return sysBase;
    }

    /// <summary>
    /// 获取系统基础配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("loginPolicy")]
    [AllowAnonymous]
    public async Task<dynamic> LoginPolicy()
    {
        var loginPolicy = await _configService.GetConfigsByCategory(CateGoryConst.CONFIG_LOGIN_POLICY);//登录策略
        return loginPolicy;
    }

    /// <summary>
    /// 获取租户列表
    /// </summary>
    /// <returns></returns>
    [HttpGet("tenantList")]
    [AllowAnonymous]
    public async Task<dynamic> TenantList()
    {
        return await _sysOrgService.GetTenantList();
    }
}
