70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
using Learn.Archives.API.Controllers.Dto;
|
|
using Learn.Archives.API.Expand;
|
|
using Learn.Archives.Core.Common;
|
|
using Learn.Archives.Core.Model;
|
|
using Learn.Archives.Core.Model.Dto;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Security.Claims;
|
|
using UserCenter.Model;
|
|
using UserCenter.Model.Common;
|
|
using UserCenter.Model.Enum;
|
|
|
|
namespace Learn.Archives.API.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 年级控制器
|
|
/// </summary>
|
|
public class ExamUserInfoController : BackController<ExamUserInfo>
|
|
{
|
|
readonly Repository<ExamUserInfo> baseService;
|
|
readonly LiveUserInfo userInfo;
|
|
public ExamUserInfoController(Repository<ExamUserInfo> baseService, LiveUserInfo userInfo) : base(baseService)
|
|
{
|
|
this.baseService = baseService;
|
|
this.userInfo = userInfo;
|
|
}
|
|
public override async Task<dynamic> PageList([FromBody] QueryRequestBase model)
|
|
{
|
|
var c = model.Conditions.FirstOrDefault(s => s.FieldName == "Grade");
|
|
if (c != null)
|
|
{
|
|
var gInfo = GradeHelper.GetStudentGradeBaseByGrade(c.FieldValue);
|
|
if (gInfo != null)
|
|
{
|
|
model.Conditions = model.Conditions.Where(s => s != c).ToList();
|
|
model.Conditions.Add(new SqlSugar.ConditionalModel()
|
|
{
|
|
FieldName = "GradeLevel",
|
|
FieldValue = gInfo.GradeLevel,
|
|
});
|
|
model.Conditions.Add(new SqlSugar.ConditionalModel()
|
|
{
|
|
FieldName = "GradeYear",
|
|
FieldValue = gInfo.GradeYear.ToString(),
|
|
CSharpTypeName = "int"
|
|
});
|
|
}
|
|
else
|
|
{
|
|
Oh.ModelError($"传入了无法识别的 年级 => {c.FieldValue}");
|
|
}
|
|
}
|
|
var oldSer = model.OrderBy.ToEnum<SubjectEnum>();
|
|
if (oldSer != null)
|
|
{
|
|
model.OrderBy = "id";
|
|
var res = (PageResult<ExamUserInfo>)await base.PageList(model);
|
|
if (model.OrderByType == SqlSugar.OrderByType.Asc)
|
|
res.Data = res.Data.OrderBy(s => s.SubjectDic?[oldSer.Value]).ToList();
|
|
else
|
|
res.Data = res.Data.OrderByDescending(s => s.SubjectDic?[oldSer.Value]).ToList();
|
|
return res;
|
|
}
|
|
return await base.PageList(model);
|
|
}
|
|
}
|
|
}
|