90 lines
3.2 KiB
C#
90 lines
3.2 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 SqlSugar;
|
|
using System.Diagnostics;
|
|
using System.Security.Claims;
|
|
using UserCenter.Model;
|
|
using UserCenter.Model.Common;
|
|
|
|
namespace Learn.Archives.API.Controllers
|
|
{
|
|
public class SchoolBusinessController : BackController<SchoolBusiness>
|
|
{
|
|
readonly Repository<SchoolBusiness> baseService;
|
|
public SchoolBusinessController(Repository<SchoolBusiness> baseService) : base(baseService)
|
|
{
|
|
this.baseService = baseService;
|
|
}
|
|
|
|
public class QueryPageDto
|
|
{
|
|
/// <summary>
|
|
/// 学校id
|
|
/// </summary>
|
|
public long SchoolId { get; set; }
|
|
/// <summary>
|
|
/// 年级
|
|
/// </summary>
|
|
public string? Grade { get; set; }
|
|
/// <summary>
|
|
/// 赴校人员名称
|
|
/// </summary>
|
|
public string? UserName { get; set; }
|
|
/// <summary>
|
|
/// 是否查询完结
|
|
/// </summary>
|
|
public bool SolutionEnd { get; set; }
|
|
public DateTime? StartTime { get; set; }
|
|
public DateTime? EndTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 页面索引
|
|
/// </summary>
|
|
public int PageIndex { get; set; } = 0;
|
|
/// <summary>
|
|
/// 页面数量
|
|
/// </summary>
|
|
public int PageSize { get; set; } = 20;
|
|
|
|
}
|
|
|
|
public override Task<bool> Edit([FromBody] SchoolBusiness model)
|
|
{
|
|
if (model.SolutionRecord != null && model.SolutionRecord.SolutionEnd == true)
|
|
model.SolutionEnd = true;
|
|
if (!string.IsNullOrEmpty(model._grade))
|
|
{
|
|
var g = GradeHelper.GetStudentGradeBaseByGrade(model._grade);
|
|
model.GradeLevel = g.GradeLevel;
|
|
model.GradeYear = g.GradeYear;
|
|
}
|
|
return base.Edit(model);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询 赴校列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<PageResult<SchoolBusiness>> QueryPageList(QueryPageDto dto)
|
|
{
|
|
RefAsync<int> total = 0;
|
|
var resData = await baseService.AsQueryable()
|
|
.WhereIF(dto.SchoolId != 0, s => s.SchoolId == dto.SchoolId)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Grade), s => s.Grade == dto.Grade)
|
|
.WhereIF(dto.SolutionEnd, s => s.SolutionEnd == dto.SolutionEnd)
|
|
.WhereIF(dto.StartTime != null, s => s.StartTime >= dto.StartTime)
|
|
.WhereIF(dto.EndTime != null, s => s.StartTime <= dto.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.UserName), s => s.SchoolBusinessUser != null && SqlFunc.JsonLike(s.SchoolBusinessUser, dto.Grade))
|
|
.OrderByDescending(s=>s.Id)
|
|
.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
return new PageResult<SchoolBusiness>() { Data = resData, Total = total };
|
|
}
|
|
}
|
|
}
|