Commit 80a1c938 authored by 黄奎's avatar 黄奎

页面修改

parent 966f9d2f
......@@ -53,6 +53,16 @@ namespace Edu.Module.User
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 讲师仓储层对象
/// </summary>
private readonly RB_TeacherRepository teacherRepository = new RB_TeacherRepository();
/// <summary>
/// 助教仓储层对象
/// </summary>
private readonly RB_AssistRepository assistRepository = new RB_AssistRepository();
/// <summary>
/// 获取管理者列表
/// </summary>
......@@ -408,121 +418,180 @@ namespace Edu.Module.User
/// 修改员工类型
/// </summary>
/// <param name="targetAccountType">目标用户类型</param>
/// <param name="Id">编号</param>
/// <param name="AccountId">编号</param>
/// <param name="AccountType">类型</param>
/// <param name="Remark">调整原因</param>
/// <returns></returns>
[TransactionCallHandler]
public virtual bool SetEmployeeTypeModule(AccountTypeEnum targetAccountType, int Id,string Remark)
public virtual bool SetEmployeeTypeModule(AccountTypeEnum targetAccountType, int AccountId, AccountTypeEnum AccountType, string Remark)
{
bool flag = false;
var model = accountRepository.GetEmployeeInfo(Id);
var model = accountRepository.GetEmployeeListRepository(new Employee_ViewModel()
{
AccountId = AccountId,
AccountTypeStr = ((int)AccountType).ToString()
})?.FirstOrDefault();
if (model != null && model.Id > 0)
{
if (targetAccountType == AccountTypeEnum.Admin)
#region 删除原来的数据
if (model.AccountType == AccountTypeEnum.Admin)
{
RB_Manager_ViewModel manager = new RB_Manager_ViewModel()
{
MId = 0,
MName = model.EmployeeName,
MTel = model.EmployeeTel,
MHead = model.UserIcon,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
UpdateBy = model.UpdateBy,
UpdateTime = DateTime.Now,
Status = model.Status,
Dept_Id = model.Dept_Id,
Post_Id = model.Post_Id,
IDCard = model.IDCard,
Sex = model.Sex,
EntryTime = model.EntryTime,
Address = model.Address,
BirthDate = model.BirthDate,
LeaveStatus = model.LeaveStatus,
LeaveTime = model.LeaveTime,
Education = model.Education,
Email = model.Email
};
flag = managerRepository.Delete(model.AccountId) > 0;
}
else if (targetAccountType == AccountTypeEnum.Teacher)
else if (model.AccountType == AccountTypeEnum.Teacher)
{
RB_Teacher_ViewModel teacher = new RB_Teacher_ViewModel()
{
TId=0,
School_Id=model.School_Id,
TeacherName=model.EmployeeName,
TeacherTel=model.EmployeeTel,
TeacherHead=model.UserIcon,
TeacherIcon=model.UserIcon,
TeacherSay="",
TeacherIntro="",
Status=model.Status,
AuditStatus= AccountStatusEnum.Pass,
AuditRemark="",
IsShow=1,
IsRecommend=0,
SortNum=1,
CreateBy=model.CreateBy,
CreateTime=DateTime.Now,
UpdateBy=model.UpdateBy,
UpdateTime=DateTime.Now,
Group_Id=model.Group_Id,
TeachTag="",
Dept_Id=model.Dept_Id,
Post_Id=model.Post_Id,
IDCard=model.IDCard,
Sex=model.Sex,
EntryTime=model.EntryTime,
Address=model.Address,
BirthDate=model.BirthDate,
LeaveStatus=model.LeaveStatus,
LeaveTime=model.LeaveTime,
Education=model.Education,
BaseStuNum=13,
Email=model.Email,
BaseHourFee=0,
Nationality="",
ForeignersUrl="",
Specialty="1,2,3,4",
BaseHoursEnabled=1,
EnableTime=model.EnableTime,
};
flag = teacherRepository.Delete(model.AccountId) > 0;
}
else if (targetAccountType == AccountTypeEnum.Assist)
else if (model.AccountType == AccountTypeEnum.Assist)
{
RB_Assist_ViewModel assist = new RB_Assist_ViewModel()
flag = assistRepository.Delete(model.AccountId) > 0;
}
#endregion
if (flag)
{
#region 添加新数据
var newId = 0;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
AId = 0,
School_Id = model.School_Id,
Teacher_Id = 0,
AssistName = model.EmployeeName,
AssistTel = model.EmployeeTel,
AssistIcon = model.UserIcon,
AssistIntro = "",
AuditStatus = AccountStatusEnum.Pass,
Status = model.Status,
Remark = "",
Group_Id = model.Group_Id,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
UpdateBy = model.UpdateBy,
UpdateTime = DateTime.Now,
Dept_Id = model.Dept_Id,
Post_Id = model.Post_Id,
IDCard = model.IDCard,
Sex = model.Sex,
EntryTime = model.EntryTime,
Address = model.Address,
BirthDate = model.BirthDate,
LeaveStatus = model.LeaveStatus,
LeaveTime = model.LeaveTime,
Education = model.Education,
Email = model.Email
{nameof(RB_Account_ViewModel.AccountType),(int)targetAccountType }
};
if (targetAccountType == AccountTypeEnum.Admin)
{
RB_Manager_ViewModel manager = new RB_Manager_ViewModel()
{
MId = 0,
MName = model.EmployeeName,
MTel = model.EmployeeTel,
MHead = model.UserIcon,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
UpdateBy = model.UpdateBy,
UpdateTime = DateTime.Now,
Status = DateStateEnum.Normal,
Dept_Id = model.Dept_Id,
Post_Id = model.Post_Id,
IDCard = model.IDCard,
Sex = model.Sex,
EntryTime = model.EntryTime,
Address = model.Address,
BirthDate = model.BirthDate,
LeaveStatus = model.LeaveStatus,
LeaveTime = model.LeaveTime,
Education = model.Education,
Email = model.Email
};
newId = managerRepository.Insert(manager);
flag = newId > 0;
manager.MId = newId;
fileds.Add(nameof(RB_Account_ViewModel.AccountId), newId);
}
else if (targetAccountType == AccountTypeEnum.Teacher)
{
RB_Teacher_ViewModel teacher = new RB_Teacher_ViewModel()
{
TId = 0,
School_Id = model.School_Id,
TeacherName = model.EmployeeName,
TeacherTel = model.EmployeeTel,
TeacherHead = model.UserIcon,
TeacherIcon = model.UserIcon,
TeacherSay = "",
TeacherIntro = "",
Status = model.Status,
AuditStatus = AccountStatusEnum.Pass,
AuditRemark = "",
IsShow = 1,
IsRecommend = 0,
SortNum = 1,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
UpdateBy = model.UpdateBy,
UpdateTime = DateTime.Now,
Group_Id = model.Group_Id,
TeachTag = "",
Dept_Id = model.Dept_Id,
Post_Id = model.Post_Id,
IDCard = model.IDCard,
Sex = model.Sex,
EntryTime = model.EntryTime,
Address = model.Address,
BirthDate = model.BirthDate,
LeaveStatus = model.LeaveStatus,
LeaveTime = model.LeaveTime,
Education = model.Education,
BaseStuNum = 13,
Email = model.Email,
BaseHourFee = 0,
Nationality = "",
ForeignersUrl = "",
Specialty = "1,2,3,4",
BaseHoursEnabled = 1,
EnableTime = model.EnableTime,
};
newId = teacherRepository.Insert(teacher);
flag = newId > 0;
teacher.TId = newId;
fileds.Add(nameof(RB_Account_ViewModel.AccountId), newId);
}
else if (targetAccountType == AccountTypeEnum.Assist)
{
RB_Assist_ViewModel assist = new RB_Assist_ViewModel()
{
AId = 0,
School_Id = model.School_Id,
Teacher_Id = 0,
AssistName = model.EmployeeName,
AssistTel = model.EmployeeTel,
AssistIcon = model.UserIcon,
AssistIntro = "",
AuditStatus = AccountStatusEnum.Pass,
Status = model.Status,
Remark = "",
Group_Id = model.Group_Id,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
UpdateBy = model.UpdateBy,
UpdateTime = DateTime.Now,
Dept_Id = model.Dept_Id,
Post_Id = model.Post_Id,
IDCard = model.IDCard,
Sex = model.Sex,
EntryTime = model.EntryTime,
Address = model.Address,
BirthDate = model.BirthDate,
LeaveStatus = model.LeaveStatus,
LeaveTime = model.LeaveTime,
Education = model.Education,
Email = model.Email
};
newId = assistRepository.Insert(assist);
flag = newId > 0;
assist.AId = newId;
fileds.Add(nameof(RB_Account_ViewModel.AccountId), newId);
}
if (fileds != null && fileds.Count > 0 && flag)
{
//更新关联编号
flag = accountRepository.Update(fileds, new WhereHelper(nameof(RB_Account_ViewModel.Id), model.Id));
}
string logContent = Remark;
if (model.AccountType != targetAccountType)
{
logContent += string.Format(",将在由【{0}】修改为【{1}】。", model.AccountType.ToName(), targetAccountType.ToName());
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
userChangeLogModule.SetUserChangeLogModule(model.CreateBy, model.Group_Id, model.School_Id, logContent, newId, targetAccountType);
}
#endregion
}
}
return flag;
......
......@@ -1555,10 +1555,12 @@ namespace Edu.WebApi.Controllers.User
/// <returns></returns>
public ApiResult SetEmployeeType()
{
var Id = base.ParmJObj.GetInt("Id");
var AccountId = base.ParmJObj.GetInt("AccountId");
var AccountType = (AccountTypeEnum)base.ParmJObj.GetInt("AccountType");
var Remark = base.ParmJObj.GetStringValue("Remark");
var targetAccountType = (AccountTypeEnum)base.ParmJObj.GetInt("TargetAccountType");
var flag = managerModule.SetEmployeeTypeModule(targetAccountType, Id,Remark);
var flag = managerModule.SetEmployeeTypeModule(targetAccountType, AccountId, AccountType,Remark);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment