/// <summary> /// 得到职员的详细信息 /// </summary> /// <returns></returns> public async Task <List <StaffSimpleInfoDto> > GetAllStaffDetial() { var staffDetailList = new List <StaffSimpleInfoDto>(); using (StaffInfoService staffInfoService = new StaffInfoService()) { var staffList = await staffInfoService.GetAll().ToListAsync(); using (SectionService sectionService = new SectionService()) { foreach (var item in staffList) { var sn = (await sectionService.GetOneById(item.SectionId)).Name; staffDetailList.Add(new StaffSimpleInfoDto() { Id = item.Id, Name = item.Name, Tel = item.Tel, Email = item.Email, SectionName = sn, Position = item.Position, Status = item.Status, CreateTime = item.CreatTime, Address = item.Address, Photo = item.ImagePath, IdCard = item.IdCard }); } } } return(staffDetailList); }
/// <summary> /// 修改密码 /// </summary> /// <param name="tel">账号(电话)</param> /// <param name="password">新密码</param> /// <param name="key">秘钥(用于加解密)</param> /// <returns></returns> public async Task ChangePwd(string tel, string password, string key) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = await staffInfoService.GetAll().Where(p => p.Tel == tel).FirstAsync(); staff.Password = StringEncryptAndDecrypt.AESEncrypt(password, key); await staffInfoService.EditAsync(staff); } }
/// <summary> /// 冻结账号 /// </summary> /// <param name="tel">账号(电话)</param> /// <returns></returns> public async Task LockAccount(string tel) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().Where(p => p.Tel == tel).FirstOrDefault(); if (staff != null) { staff.Status = false; await staffInfoService.EditAsync(staff); } } }
public List <string> GetInitalInfo(string tel) { using (StaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().Where(p => p.Tel == tel).FirstOrDefault(); return(new List <string>() { staff.Name, staff.Position, staff.ImagePath }); } }
/// <summary> /// 职员登陆 /// </summary> /// <param name="account">账号(电话)</param> /// <param name="password">密码</param> /// <param name="key">秘钥(用于加解密)</param> /// <param name="userId">职员id(用于返回)</param> /// <returns></returns> public bool Login(string account, string password, string key, out Guid userId) { var pwd = StringEncryptAndDecrypt.AESEncrypt(password, key); using (IStaffInfoService staffInfoService = new StaffInfoService()) { var user = staffInfoService.GetAll().FirstOrDefaultAsync(p => p.Tel == account && p.Password == pwd); //user在此是一个异步方法 user.Wait(); //等待user执行结束 var data = user.Result; //拿到user执行的结果 if (data != null) { userId = data.Id; return(true); } else { userId = new Guid(); return(false); } } }
/// <summary> /// 解封职员账号(管理员操作) /// </summary> /// <param name="tel">账号(电话)</param> /// <param name="_operatorId">操作员的ID</param> /// <returns></returns> public async Task UnlockAccount(string tel, Guid _operatorId) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().FirstOrDefault(p => p.Tel == tel); if (staff != null && !staff.Status) { staff.Status = true; await staffInfoService.CreateAsync(staff); using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService()) { await accountOperateLogService.CreateAsync(new AccountOperateLog() { OperatorId = _operatorId, ModifiedId = staff.Id, OPerateType = "2" //代表update操作 }); } } } }
/// <summary> /// 根据账号得到职员基础信息 /// </summary> /// <param name="tel">账号(电话)</param> /// <returns></returns> public StaffSimpleInfoDto GetSTaffInfoByTel(string tel) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().FirstOrDefault(p => p.Tel == tel); if (staff != null) { return(new StaffSimpleInfoDto() { Id = staff.Id, Name = staff.Name, Tel = staff.Tel, Email = staff.Email, Status = staff.Status, SectionName = GetSectionNameById(staff.SectionId) }); } else { return(null); } } }