| | |
| | | using Newtonsoft.Json; |
| | | using WIDESEAWCS_Common; |
| | | using FaceAI; |
| | | using WIDESEAWCS_DTO.Telescopic; |
| | | |
| | | namespace WIDESEAWCS_SystemServices |
| | | { |
| | |
| | | private readonly IRepository<Dt_FaceRecognition> _faceServer; |
| | | private readonly IRepository<Dt_Loginhsy> _LoginhsyServer; |
| | | private readonly IRepository<Dt_Maintenance> _MainServer; |
| | | public Sys_UserService(IRepository<Dt_Loginhsy> LoginhsyServer,IRepository<Dt_FaceRecognition> faceServer, IRepository<Sys_User> repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService, IRepository<Dt_Maintenance> MainServer) : base(repository) |
| | | private readonly IRepository<Sys_Role> _RoleServer; |
| | | private readonly IRepository<Dt_AuthorizationRecord> _AuthorizatRecServer; |
| | | public Sys_UserService(IRepository<Dt_AuthorizationRecord> AuthorizatRecServer ,IRepository<Sys_Role> RoleServer,IRepository<Dt_Loginhsy> LoginhsyServer,IRepository<Dt_FaceRecognition> faceServer, IRepository<Sys_User> repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService, IRepository<Dt_Maintenance> MainServer) : base(repository) |
| | | { |
| | | _faceServer = faceServer; |
| | | _LoginhsyServer = LoginhsyServer; |
| | |
| | | _cacheService = cacheService; |
| | | _menuService = menuService; |
| | | _MainServer = MainServer; |
| | | _RoleServer = RoleServer; |
| | | _AuthorizatRecServer=AuthorizatRecServer; |
| | | } |
| | | |
| | | |
| | |
| | | IsLeader = addUserDTO.IsLeader, |
| | | RoleName = addUserDTO.rolename, |
| | | Enable = addUserDTO.enable, |
| | | Unit = addUserDTO.userunit, |
| | | UserPwd = "j79rYYvCz4vdhcboB1Ausg==", |
| | | //Userteam = addUserDTO.userteam, |
| | | Userteam = addUserDTO.userteam, |
| | | Dept_Id = addUserDTO.dept_Id, |
| | | //CardNumber=addUserDTO.carnuber, |
| | | CreateDate = DateTime.Now |
| | |
| | | sys.Role_Id = addUserDTO.roleid; |
| | | sys.RoleName = addUserDTO.rolename; |
| | | //sys.CardNumber = addUserDTO.carnuber; |
| | | //sys.Userteam = addUserDTO.userteam; |
| | | sys.Userteam = addUserDTO.userteam; |
| | | sys.Unit = addUserDTO.userunit; |
| | | sys.Dept_Id = addUserDTO.dept_Id; |
| | | sys.Enable = addUserDTO.enable; |
| | | //sys.Enable = addUserDTO.enable; |
| | | sys.IsLeader = addUserDTO.IsLeader;//æ´æ°ç¨æ·è¡¨çæ¯å¦æ¯ç»é¿ |
| | | //å¦æäººè¸è¯å«æ·»å äºè¿éå°±æ³¨éæ |
| | | sys.HeadImageUrl = addUserDTO.path; |
| | |
| | | //} |
| | | |
| | | // 8. æ´æ°æ°æ®åº |
| | | BaseDal.UpdateData(sys); |
| | | |
| | | //æ´æ°Dt_Maintenance表ä¸çæ°æ®åuser表ä¸ä¿®æ¹ç䏿 · |
| | | team.UserAccount = addUserDTO.username;//è´¦å· |
| | | team.Roleid = addUserDTO.roleid;//æ´æ°æé |
| | | team.IsLeader = addUserDTO.IsLeader; |
| | | |
| | | var existAuthority = userList.FirstOrDefault(a => a.UserName == addUserDTO.username); |
| | | // å
ç¼åæ§ç enable å¼ |
| | | var oldEnable = sys.Enable; |
| | | |
| | | // ä¿®æ¹ enable |
| | | sys.Enable = addUserDTO.enable; |
| | | |
| | | // ç¶åæ¯è¾æ§å¼åæ°å¼ |
| | | if (oldEnable != addUserDTO.enable) |
| | | { |
| | | var authority = new Dt_AuthorizationRecord |
| | | { |
| | | Account = addUserDTO.username, |
| | | UserName = addUserDTO.usertruename, |
| | | UerUnit = addUserDTO.userunit, |
| | | UserTeam = addUserDTO.userteam, |
| | | EnableTime = addUserDTO.enable == 1 ? DateTime.Now : (DateTime?)null, //å¯ç¨ |
| | | DisableTime = addUserDTO.enable == 0 ? DateTime.Now : (DateTime?)null,//ä¸å¯ç¨ |
| | | }; |
| | | |
| | | _AuthorizatRecServer.AddData(authority); |
| | | } |
| | | |
| | | |
| | | BaseDal.UpdateData(sys); |
| | | _MainServer.UpdateData(team); |
| | | |
| | | return new WebResponseContent { Status = true, Data = sys }; |
| | |
| | | return new WebResponseContent { Status = false, Message="失败"}; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// è¡¨è¿æ¥è§è²è¡¨ï¼å±ç¤ºæ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent YShowUserList(PaginationDTO pagination) |
| | | { |
| | | try |
| | | { |
| | | int totalCount = 0; |
| | | var Role = _RoleServer.Db.Queryable<Sys_Role>(); |
| | | var query = Role.InnerJoin<Sys_User>((a, b) => a.RoleId == b.Role_Id); |
| | | |
| | | //æç´¢å
³é®å |
| | | if (!string.IsNullOrEmpty(pagination.searchKeyword)) |
| | | { |
| | | query = query.Where((a, b) => |
| | | b.UserName.Contains(pagination.searchKeyword) || |
| | | b.UserTrueName.Contains(pagination.searchKeyword) || |
| | | b.PhoneNo.Contains(pagination.searchKeyword) || |
| | | a.RoleName.Contains(pagination.searchKeyword)); |
| | | } |
| | | //æ¶é´æ¥è¯¢ |
| | | if (pagination.startDate.HasValue && pagination.endDate.HasValue) |
| | | { |
| | | query = query.Where((a, b) => b.CreateDate >= pagination.startDate.Value && b.CreateDate <= pagination.endDate.Value); |
| | | } |
| | | //æåº |
| | | if (!string.IsNullOrEmpty(pagination.sortField)) |
| | | { |
| | | var isAcs = pagination.sortOrder?.ToLower() == "asc"; |
| | | query = pagination.sortField.ToLower() switch |
| | | { |
| | | |
| | | |
| | | "CreateDate" => isAcs ? query.OrderBy((a, b) => b.CreateDate) : query.OrderByDescending((a, b) => b.CreateDate), |
| | | |
| | | _ => query.OrderByDescending((a, b) => b.Creater) // é»è®¤æå建æ¶é´éåº |
| | | }; |
| | | |
| | | } |
| | | else |
| | | { |
| | | query = query.OrderByDescending((a, b) => b.Creater); |
| | | } |
| | | var reslut = query.Select((a, b) => new |
| | | { |
| | | b.User_Id, |
| | | b.UserName, |
| | | b.UserTrueName, |
| | | b.Unit, |
| | | b.Userteam, |
| | | b.Role_Id, |
| | | b.IsLeader, |
| | | //b.RoleName, |
| | | b.CardNumber, |
| | | b.PhoneNo, |
| | | b.UserPwd, |
| | | b.DeptName, |
| | | b.Dept_Id, |
| | | b.Email, |
| | | b.Enable, |
| | | b.Gender, |
| | | b.HeadImageUrl, |
| | | b.Address, |
| | | b.CreateDate, |
| | | b.Creater, |
| | | a.RoleName, |
| | | |
| | | }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); |
| | | |
| | | |
| | | return new WebResponseContent |
| | | { |
| | | Status = true, |
| | | Data = new |
| | | { |
| | | totalCount = totalCount, |
| | | PageIndex = pagination.pageIndex, |
| | | PageSize = pagination.pageSize, |
| | | Items = reslut |
| | | } |
| | | }; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |