public async Task <IResultModel> LoginInfo(Guid accountId) { var account = await _accountRepository.GetAsync(accountId); //监测账户状态 if (!CheckAccount(account, out string msg)) { return(ResultModel.Failed(msg)); } var model = new LoginResultModel { Id = account.Id, Type = account.Type, UserName = account.UserName, Name = account.Name, Phone = account.Phone, Email = account.Email, Skin = new SkinConfigModel { //TODO:加载用户的配置信息 Name = "pretty", Theme = "", FontSize = "" } }; //加载配置信息 var config = await _accountConfigRepository.GetByAccount(accountId); if (config != null) { model.Skin.Name = config.Skin; model.Skin.Theme = config.Theme; model.Skin.FontSize = config.FontSize; } #region ==获取账户详细信息== var detailsBuilders = _serviceProvider.GetServices <ILoginInfoDetailsBuilder>().ToList(); if (detailsBuilders.Any()) { var detailsBuilder = detailsBuilders.FirstOrDefault(m => m.AccountType == account.Type); if (detailsBuilder != null) { model.Details = await detailsBuilder.Build(accountId); } } #endregion var getMenuTree = GetAccountMenuTree(accountId); var getButtonCodeList = _buttonRepository.QueryCodeByAccount(accountId); model.Menus = await getMenuTree; model.Buttons = await getButtonCodeList; return(ResultModel.Success(model)); }
public async Task <IResultModel> SkinUpdate(Guid id, AccountSkinUpdateModel model) { var configInfo = await _accountConfigRepository.GetByAccount(id); if (configInfo == null) { configInfo = new AccountConfigEntity { AccountId = id, Skin = model.Name, Theme = model.Theme, FontSize = model.FontSize }; if (await _accountConfigRepository.AddAsync(configInfo)) { return(ResultModel.Success()); } } else { configInfo.Skin = model.Name; configInfo.Theme = model.Theme; configInfo.FontSize = model.FontSize; if (await _accountConfigRepository.UpdateAsync(configInfo)) { return(ResultModel.Success()); } } return(ResultModel.Failed()); }
/// <summary> /// 获取认证信息 /// </summary> /// <returns></returns> public async Task <IResultModel> GetAuthInfo() { var account = await _accountRepository.GetAsync(_loginInfo.AccountId); if (account == null) { return(ResultModel.Failed("账户不存在")); } var result = account.Check(); //检测账户状态 if (!result.Successful) { return(result); } var model = new AuthInfoModel { Id = account.Id, Type = account.Type, UserName = account.UserName, Name = account.Name, Phone = account.Phone, Email = account.Email, }; #region ==获取账户详细信息== var detailsBuilders = _serviceProvider.GetServices <ILoginInfoDetailsBuilder>().ToList(); if (detailsBuilders.Any()) { var detailsBuilder = detailsBuilders.FirstOrDefault(m => m.AccountType == account.Type); if (detailsBuilder != null) { model.Details = await detailsBuilder.Build(_loginInfo.AccountId); } } #endregion #region ==Web端== if (_loginInfo.Platform == Platform.Web) { //加载配置信息 var config = await _configRepository.GetByAccount(_loginInfo.AccountId); if (config != null) { model.Skin = new SkinConfigModel { Name = config.Skin, Theme = config.Theme, FontSize = config.FontSize }; } else { model.Skin = new SkinConfigModel { Name = "pretty", Theme = "", FontSize = "small" }; } var getMenuTree = _permissionResolver.ResolveMenus(_loginInfo.AccountId); var getPageCodes = _permissionResolver.ResolvePages(_loginInfo.AccountId); var getButtonCodes = _permissionResolver.ResolveButtons(_loginInfo.AccountId); model.Menus = await getMenuTree; model.Pages = await getPageCodes; model.Buttons = await getButtonCodes; } #endregion return(ResultModel.Success(model)); }