using Microsoft.AspNetCore.Http; using ERP.Core.Dto; using ERP.Core.Entity; using ERP.Core.Repository; using ERP.Framework.Constants; using ERP.Framework.WebApi; namespace ERP.Core.Service { public class SysUserService { private SysUserRepository SysUserRepository; public SysUserService(SysUserRepository SysUserRepository) { this.SysUserRepository = SysUserRepository; } public async Task GetUserInfo(string loginName) { var user = SysUserRepository.FirstOrDefault(t => t.UserName == loginName); //if (user == null) //{ // throw new Exception(string.Format(_localizer["User.NotExist"], loginName))); //} //CheckUserStatus(user); //var roleList = SysRoleRepository.SelectRoleListByUserId(user.Id); //var roleKeyList = roleList.Select(t => t.RoleKey).ToList(); //var permissions = new List(); //if (roleList.Any(t => t.RoleKey == FrameworkConstant.Admin)) //{ // permissions.Add(FrameworkConstant.AdminPermission); //} //else //{ // var roleIds = roleList.Select(t => t.Id).ToList(); // permissions = SysMenuRepository.SelectPermissionsByRoleIds(roleIds); //} return new LoginUser(); } private void CheckUserStatus(SysUser user) { //if (user.UserStatus == UserStatusEnum.Enable) //{ // return; //} //else if (user.UserStatus == UserStatusEnum.Disable) //{ // throw new RpcException(new Status(StatusCode.Unknown, string.Format(_localizer["User.Bloked"], user.LoginName))); //} //else if (user.UserStatus == UserStatusEnum.Effact) //{ // CheckEffective(user.EffectiveDate, user.LoginName); //} //else if (user.UserStatus == UserStatusEnum.Expiry) //{ // CheckExpiry(user.ExpiryDate, user.LoginName); //} //else if (user.UserStatus == UserStatusEnum.Temporary) //{ // CheckEffective(user.EffectiveDate, user.LoginName); // CheckExpiry(user.ExpiryDate, user.LoginName); //} } } }