using Edu.AOP.CustomerAttribute; using Edu.Common.Encrypt; using Edu.Model.ViewModel.User; using Edu.Repository.User; using System; using System.Collections.Generic; using VT.FW.DB; namespace Edu.Module.User { /// /// 账号管理处理类 /// public class AccountModule { /// /// 账号管理处理类对象 /// private readonly RB_AccountRepository accountRepository = new RB_AccountRepository(); /// /// 获取账号列表 /// /// /// public List GetAccountListModule(RB_Account_ViewModel query) { return accountRepository.GetAccountListRepository(query); } /// /// 获取指定人员的企业微信ID /// /// 教师编号 /// public string GetWorkUserIdModule(int id) { return accountRepository.GetWorkUserIdRepository(id); } /// /// 获取指定部门下员工的企业号ID /// /// /// public string GetWorkUserIdByDepartmentModule(string departmentIds) { return accountRepository.GetWorkUserIdByDepartmentRepository(departmentIds); } /// /// 获取账号列表(批量修改密码专用) /// /// /// public List GetUpdateAccountListRepository(List query) { return accountRepository.GetUpdateAccountListRepository(query); } /// /// 获取账号列表扩展列表 /// /// /// public List GetAccountListExtModule(RB_Account_ViewModel query) { return accountRepository.GetAccountListExtRepository(query); } /// /// 获取学员账号信息 /// /// /// public List GetStudentExt(RB_Account_ViewModel query) { return accountRepository.GetStudentExt(query); } /// /// 更新账户的UnionId /// /// /// public bool UpdateAccountUnionId(RB_Account_ViewModel model) { bool flag = false; if (model.Id > 0) { Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.OpenId),model.OpenId.Trim() }, {nameof(RB_Account_ViewModel.UnionId),model.UnionId.Trim() } }; flag = accountRepository.Update(fileds, new WhereHelper(nameof(RB_Account_ViewModel.Id), model.Id)); } return flag; } /// /// 添加修改账号 /// /// /// public bool SetAccountModule(RB_Account_ViewModel model) { bool flag; if (model.Id > 0) { Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.Account),model.Account.Trim() }, {nameof(RB_Account_ViewModel.UpdateBy),model.UpdateBy}, {nameof(RB_Account_ViewModel.UpdateTime),model.UpdateTime}, {nameof(RB_Account_ViewModel.DirectSupervisor),model.DirectSupervisor}, {nameof(RB_Account_ViewModel.School_Id),model.School_Id}, }; flag = accountRepository.Update(fileds, new WhereHelper(nameof(RB_Account_ViewModel.Id), model.Id)); } else { var newId = accountRepository.Insert(model); model.Id = newId; flag = newId > 0; } return flag; } /// /// 修改账号状态 /// /// /// public bool SetAccountStatusModule(RB_Account_ViewModel model) { bool flag; Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.Status),(int)model.Status }, {nameof(RB_Account_ViewModel.UpdateTime),model.UpdateTime }, }; List list = new List() { new WhereHelper(nameof(RB_Account_ViewModel.AccountId),model.AccountId), new WhereHelper(nameof(RB_Account_ViewModel.AccountType),(int)model.AccountType), }; flag = accountRepository.Update(fileds, list); return flag; } /// /// 重置密码 /// /// /// public (bool reuslt, string newPass) SetResetPassword(RB_Account_ViewModel model) { bool flag; //生成随机新密码 var newPwd = PwHelper.MakePassword(8); Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.Password), Common.DES.Encrypt(newPwd)} }; var wheres = new List { new WhereHelper(nameof(RB_Account_ViewModel.AccountId), model.AccountId), new WhereHelper(nameof(RB_Account_ViewModel.AccountType), model.AccountType), new WhereHelper(nameof(RB_Account_ViewModel.Group_Id), model.Group_Id) }; flag = accountRepository.Update(fileds, wheres); return (flag, newPwd); } /// /// 重置密码 /// /// /// [TransactionCallHandler] public virtual bool SetBatchResetPassword(List list, string newPwd) { bool flag = false; foreach (var model in list) { Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.Password), Common.DES.Encrypt(newPwd)} }; var wheres = new List { new WhereHelper(nameof(RB_Account_ViewModel.AccountId), model.AccountId), new WhereHelper(nameof(RB_Account_ViewModel.AccountType), model.AccountType), new WhereHelper(nameof(RB_Account_ViewModel.Group_Id), model.Group_Id) }; flag = accountRepository.Update(fileds, wheres); } return flag; } /// /// 修改密码以及更新激活状态 /// /// /// [TransactionCallHandler] public virtual bool SetResetPwdAndAtatus(RB_Account_ViewModel model, string newPwd) { bool flag = false; Dictionary fileds = new Dictionary() { {nameof(RB_Account_ViewModel.Password), newPwd}, {nameof(RB_Account_ViewModel.ActivationStatus), model.ActivationStatus} }; if (!string.IsNullOrWhiteSpace(model.OpenId)) { fileds.Add(nameof(RB_Account_ViewModel.OpenId), model.OpenId); } var wheres = new List { new WhereHelper(nameof(RB_Account_ViewModel.AccountId), model.AccountId), new WhereHelper(nameof(RB_Account_ViewModel.AccountType), model.AccountType), new WhereHelper(nameof(RB_Account_ViewModel.Group_Id), model.Group_Id) }; flag = accountRepository.Update(fileds, wheres); return flag; } /// /// 获取指定教师的企业微信ID /// /// 教师编号 /// public string GetWorkUserIdByTIdModule(int tid) { return accountRepository.GetWorkUserIdByTidRepository(tid); } } }