|
|
|
@ -13,7 +13,6 @@ using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
|
|
using Stateless;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
@ -90,6 +89,8 @@ namespace TeacherExt.Controllers
|
|
|
|
|
.OrderBy(o => o.OrganId)
|
|
|
|
|
.ThenBy(o => o.CreateAt);
|
|
|
|
|
var query = from person in personQuery
|
|
|
|
|
join organ in this._organizationRepo.ReadOnlyTable() on person.BureauId equals organ.OrganId
|
|
|
|
|
join department in this._organizationRepo.ReadOnlyTable() on person.OrganId equals department.OrganId
|
|
|
|
|
join login in this._loginRepo.ReadOnlyTable() on person.Id equals login.PersonId
|
|
|
|
|
orderby person.OrganId ascending, person.CreateAt ascending
|
|
|
|
|
select new TeacherListItem
|
|
|
|
@ -101,7 +102,9 @@ namespace TeacherExt.Controllers
|
|
|
|
|
sex = person.Sex,
|
|
|
|
|
nation = person.Nation,
|
|
|
|
|
placeofbirth = person.NativePlace,
|
|
|
|
|
person_id = person.Id
|
|
|
|
|
person_id = person.Id,
|
|
|
|
|
org_name = organ.Name,
|
|
|
|
|
department_name = department.Name
|
|
|
|
|
};
|
|
|
|
|
var count = query.Count();
|
|
|
|
|
var list = query
|
|
|
|
@ -158,7 +161,7 @@ namespace TeacherExt.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Update(int id,string access_token)
|
|
|
|
|
public IActionResult Update(int id, string access_token)
|
|
|
|
|
{
|
|
|
|
|
var person = this._personRepo.ReadOnlyTable().Where(o => o.Id == id).FirstOrDefault();
|
|
|
|
|
var organ = this._organizationRepo.ReadOnlyTable().Where(o => o.Id == person.OrganId).FirstOrDefault();
|
|
|
|
@ -167,7 +170,7 @@ namespace TeacherExt.Controllers
|
|
|
|
|
this.EntityToModel(person, model);
|
|
|
|
|
this.ToEditModel(person, model);
|
|
|
|
|
model.LoginName = this._loginRepo.ReadOnlyTable().Where(o => o.PersonId == model.Id).Select(o => o.LoginName).FirstOrDefault();
|
|
|
|
|
if(!string.IsNullOrEmpty(access_token))
|
|
|
|
|
if (!string.IsNullOrEmpty(access_token))
|
|
|
|
|
{
|
|
|
|
|
var httpContext = this.Request.HttpContext;
|
|
|
|
|
var token = access_token;
|
|
|
|
@ -210,7 +213,7 @@ namespace TeacherExt.Controllers
|
|
|
|
|
ToStatus = model.CheckStatus
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.UpdateInternal(entity,model);
|
|
|
|
|
this.UpdateInternal(entity, model);
|
|
|
|
|
//entity.From(model);
|
|
|
|
|
//this.ModelToEntity(model, entity);
|
|
|
|
|
this._personRepo.SaveChanges();
|
|
|
|
@ -228,18 +231,18 @@ namespace TeacherExt.Controllers
|
|
|
|
|
private void UpdateInternal(Person entity, EditTeacherModel model)
|
|
|
|
|
{
|
|
|
|
|
var self = this.HttpContext.Request.Query.ContainsKey("self") || (this.HttpContext.Request.Method == "POST" && this.HttpContext.Request.Form.ContainsKey("self"));
|
|
|
|
|
if(self)
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
if (entity.CheckStatus==model.CheckStatus)
|
|
|
|
|
if (entity.CheckStatus == model.CheckStatus)
|
|
|
|
|
{
|
|
|
|
|
if(model.CheckStatus== "未提交"||model.CheckStatus== "审核失败")
|
|
|
|
|
if (model.CheckStatus == "未提交" || model.CheckStatus == "审核失败")
|
|
|
|
|
{
|
|
|
|
|
entity.From(model);
|
|
|
|
|
this.ModelToEntity(model, entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(entity.RequestEditStatus!=model.RequestEditStatus)
|
|
|
|
|
if (entity.RequestEditStatus != model.RequestEditStatus)
|
|
|
|
|
{
|
|
|
|
|
entity.RequestEditStatus = model.RequestEditStatus;
|
|
|
|
|
}
|
|
|
|
@ -255,13 +258,20 @@ namespace TeacherExt.Controllers
|
|
|
|
|
this.ModelToEntity(model, entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (entity.CheckStatus == "待审核")
|
|
|
|
|
{
|
|
|
|
|
if (model.CheckStatus == "未提交")
|
|
|
|
|
{
|
|
|
|
|
entity.CheckStatus = model.CheckStatus;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (User.IsInRole("城中区教育局管理员"))
|
|
|
|
|
{
|
|
|
|
|
if (model.CheckStatus == "审核失败"&&model.RequestEditStatus== "未申请")
|
|
|
|
|
if (model.CheckStatus == "审核失败" && model.RequestEditStatus == "未申请")
|
|
|
|
|
{
|
|
|
|
|
entity.Comment = model.Comment;
|
|
|
|
|
entity.CheckStatus = model.CheckStatus;
|
|
|
|
@ -276,9 +286,9 @@ namespace TeacherExt.Controllers
|
|
|
|
|
entity.Comment = model.Comment;
|
|
|
|
|
entity.CheckStatus = model.CheckStatus;
|
|
|
|
|
entity.RequestEditStatus = model.RequestEditStatus;
|
|
|
|
|
entity.FromWhere(model,(s,t)=>s.Name.EndsWith("Checked"));
|
|
|
|
|
entity.FromWhere(model, (s, t) => s.Name.EndsWith("Checked"));
|
|
|
|
|
}
|
|
|
|
|
if (entity.RequestEditStatus!=model.RequestEditStatus)
|
|
|
|
|
if (entity.RequestEditStatus != model.RequestEditStatus)
|
|
|
|
|
{
|
|
|
|
|
entity.CheckStatus = model.CheckStatus;
|
|
|
|
|
entity.RequestEditStatus = model.RequestEditStatus;
|
|
|
|
@ -292,7 +302,7 @@ namespace TeacherExt.Controllers
|
|
|
|
|
var self = this.HttpContext.Request.Query.ContainsKey("self") || (this.HttpContext.Request.Method == "POST" && this.HttpContext.Request.Form.ContainsKey("self"));
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
if (entity.CheckStatus!=model.CheckStatus)
|
|
|
|
|
if (entity.CheckStatus != model.CheckStatus)
|
|
|
|
|
{
|
|
|
|
|
if (model.CheckStatus == "待审核")
|
|
|
|
|
{
|
|
|
|
@ -301,15 +311,22 @@ namespace TeacherExt.Controllers
|
|
|
|
|
ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (model.CheckStatus == "未提交")
|
|
|
|
|
{
|
|
|
|
|
if (entity.CheckStatus != "待审核")
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(entity.RequestEditStatus!=model.RequestEditStatus)
|
|
|
|
|
if (entity.RequestEditStatus != model.RequestEditStatus)
|
|
|
|
|
{
|
|
|
|
|
if(entity.CheckStatus== "未提交"||entity.CheckStatus=="审核失败")
|
|
|
|
|
if (entity.CheckStatus == "未提交" || entity.CheckStatus == "审核失败")
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.RequestEditStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.RequestEditStatus}]状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(model.LoginName!=User.Identity.Name)
|
|
|
|
|
if (model.LoginName != User.Identity.Name)
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.RealName), $"当前用户不是[{model.RealName}]无法修改登录名其的个人信息");
|
|
|
|
|
}
|
|
|
|
@ -318,9 +335,9 @@ namespace TeacherExt.Controllers
|
|
|
|
|
{
|
|
|
|
|
if (User.IsInRole("城中区教育局管理员"))
|
|
|
|
|
{
|
|
|
|
|
if(model.CheckStatus== "审核失败")
|
|
|
|
|
if (model.CheckStatus == "审核失败")
|
|
|
|
|
{
|
|
|
|
|
if(entity.CheckStatus!= "审核成功")
|
|
|
|
|
if (entity.CheckStatus != "审核成功")
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态");
|
|
|
|
|
}
|
|
|
|
@ -328,16 +345,16 @@ namespace TeacherExt.Controllers
|
|
|
|
|
}
|
|
|
|
|
else if (User.IsInRole("学校管理员"))
|
|
|
|
|
{
|
|
|
|
|
if(model.CheckStatus== "审核成功"||model.CheckStatus=="审核失败")
|
|
|
|
|
if (model.CheckStatus == "审核成功" || model.CheckStatus == "审核失败")
|
|
|
|
|
{
|
|
|
|
|
if (entity.CheckStatus != "待审核")
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(entity.RequestEditStatus != model.RequestEditStatus)
|
|
|
|
|
if (entity.RequestEditStatus != model.RequestEditStatus)
|
|
|
|
|
{
|
|
|
|
|
if(entity.CheckStatus!="待审核"&& entity.CheckStatus != "审核成功")
|
|
|
|
|
if (entity.CheckStatus != "待审核" && entity.CheckStatus != "审核成功")
|
|
|
|
|
{
|
|
|
|
|
ModelState.AddModelError(nameof(model.RequestEditStatus), $"无法从[{entity.RequestEditStatus}]状态修改为[{model.RequestEditStatus}]状态");
|
|
|
|
|
}
|
|
|
|
@ -553,7 +570,7 @@ namespace TeacherExt.Controllers
|
|
|
|
|
var organQuery = this._organizationRepo.ReadOnlyTable();
|
|
|
|
|
var query = from person in personQuery
|
|
|
|
|
join organ in organQuery on person.OrganId equals organ.OrganId
|
|
|
|
|
orderby person.BureauId, person.CreateAt
|
|
|
|
|
orderby person.AreaId, person.CreateAt
|
|
|
|
|
select new { organ.Name, person = person };
|
|
|
|
|
//
|
|
|
|
|
var nations = this.GetNation();
|
|
|
|
@ -670,25 +687,19 @@ namespace TeacherExt.Controllers
|
|
|
|
|
var name = model.person_name?.Trim();
|
|
|
|
|
var personQuery = this._personRepo.ReadOnlyTable()
|
|
|
|
|
.Where(o => o.IsUsed)
|
|
|
|
|
.Where(o => o.BureauId == bureau_id);
|
|
|
|
|
if (User.IsInRole("城中区教育局管理员"))
|
|
|
|
|
{
|
|
|
|
|
if (model.bureau_id.Value != bureau_id)
|
|
|
|
|
{
|
|
|
|
|
personQuery = personQuery.Where(o => o.OrganId == model.bureau_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (User.IsInRole("学校管理员"))
|
|
|
|
|
.Where(o => o.AreaId == bureau_id);
|
|
|
|
|
if (model.bureau_id.Value != bureau_id)
|
|
|
|
|
{
|
|
|
|
|
personQuery = personQuery.Where(o => o.OrganId == model.bureau_id);
|
|
|
|
|
personQuery = personQuery.Where(o => o.BureauId == model.bureau_id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
if (!User.IsInRole("城中区教育局管理员") && !User.IsInRole("学校管理员"))
|
|
|
|
|
{
|
|
|
|
|
var personId= Convert.ToInt32(User.Claims.Where(o => o.Type == "PersonId").Select(o => o.Value).FirstOrDefault());
|
|
|
|
|
var personId = Convert.ToInt32(User.Claims.Where(o => o.Type == "PersonId").Select(o => o.Value).FirstOrDefault());
|
|
|
|
|
personQuery = personQuery.Where(o => o.Id == personId);
|
|
|
|
|
}
|
|
|
|
|
personQuery = personQuery
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.person_name), o => o.RealName.Contains(name))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(name), o => o.RealName.Contains(name))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.RequestEditStatus), o => o.RequestEditStatus == model.RequestEditStatus)
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.CheckStatus), o => o.CheckStatus == model.CheckStatus);
|
|
|
|
|
return personQuery;
|
|
|
|
|