refactor: 重构 GetHomeUrlByAppId 接口

This commit is contained in:
Argo-Tianyi 2022-01-20 10:51:40 +08:00
parent d77d4786aa
commit f18229d58c
3 changed files with 4 additions and 14 deletions

View File

@ -162,13 +162,11 @@ class DictService : IDict
/// </summary>
/// <param name="appId"></param>
/// <returns></returns>
public string? GetHomeUrlByAppId(string? appId = null)
public string? GetHomeUrlByAppId(string appId)
{
string? url = null;
var dicts = GetAll();
// appId 为空时读取前台列表取第一个应用作为默认应用
appId ??= GetApps().FirstOrDefault(d => d.Key != "BA").Key ?? AppId;
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
return url;
}

View File

@ -242,19 +242,11 @@ class DictService : IDict
/// </summary>
/// <param name="appId"></param>
/// <returns></returns>
public string? GetHomeUrlByAppId(string? appId = null)
public string? GetHomeUrlByAppId(string appId)
{
string? url = null;
var dicts = GetAll();
// 查看是否开启默认应用
var enableDefaultApp = GetEnableDefaultApp();
if (enableDefaultApp)
{
// appId 为空时读取前台列表取第一个应用作为默认应用
appId ??= GetApps().FirstOrDefault(d => d.Key != AppId).Key ?? AppId;
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
}
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
return url;
}

View File

@ -174,7 +174,7 @@ public interface IDict
/// </summary>
/// <param name="appId"></param>
/// <returns></returns>
string? GetHomeUrlByAppId(string? appId = null);
string? GetHomeUrlByAppId(string appId);
/// <summary>
/// 是否开启默认应用