using EntrustSettle.IRepository.Base; using EntrustSettle.IServices; using EntrustSettle.Model.Models; using EntrustSettle.Services.Base; using System.Linq; using System.Threading.Tasks; namespace EntrustSettle.FrameWork.Services { /// /// sysUserInfoServices /// public class SysUserInfoServices : BaseServices, ISysUserInfoServices { private readonly IBaseRepository _userRoleRepository; private readonly IBaseRepository _roleRepository; public SysUserInfoServices(IBaseRepository userRoleRepository, IBaseRepository roleRepository) { _userRoleRepository = userRoleRepository; _roleRepository = roleRepository; } /// /// /// /// /// /// public async Task GetUserRoleNameStr(string loginName, string loginPwd) { string roleName = ""; var user = (await base.Query(a => a.LoginName == loginName && a.LoginPWD == loginPwd)).FirstOrDefault(); var roleList = await _roleRepository.Query(a => a.IsDeleted == false); if (user != null) { var userRoles = await _userRoleRepository.Query(ur => ur.UserId == user.Id); if (userRoles.Count > 0) { var arr = userRoles.Select(ur => ur.RoleId.ObjToString()).ToList(); var roles = roleList.Where(d => arr.Contains(d.Id.ObjToString())); roleName = string.Join(',', roles.Select(r => r.Name).ToArray()); } } return roleName; } } }