using New_College.IServices; using New_College.Model; using New_College.Model.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Linq.Expressions; using System.Threading.Tasks; using System.Collections.Generic; using New_College.Model.ViewModels; using New_College.Services; using System.Linq; using SqlSugar; namespace New_College.Api.Controllers { /// /// 专业分数线 /// [Route("api/[controller]/[action]")] [ApiController] [Authorize] public class PlanMajorScoreLineController : ControllerBase { /// /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 /// private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices; public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices) { _d_PlanMajorScoreLineServices = D_PlanMajorScoreLineServices; } /// /// 获取学校专业分数线 /// /// /// [HttpGet] public async Task>> Get([FromQuery] PlanMajorScoreLineRequest request) { if (request.Uid <= 0) { return new MessageModel>() { success = false, msg = "uid必传" }; } Expression> expression = Expressionable.Create() .And(c => c.UId == request.Uid) .AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName == request.BatchName) .AndIF(request.Year.HasValue && request.Year > 0, c => c.Years == request.Year) .ToExpression(); var response = (await _d_PlanMajorScoreLineServices.Query(expression)) .Select(c => new PlanMajorScoreLineResponse() { BatchName = c.BatchName, UId = request.Uid, LowScore = c.LowScore, LowScoreRank = c.LowScoreRank, AvgScore = c.AvgScore, Years = c.Years, FirstType = c.FirstType, HighScore = c.HighScore, Major = c.Major, MajorGroup = c.MajorGroup, Remark = c.Remark, SelectSubject = c.SelectSubject, }).ToList(); return new MessageModel>() { msg = "获取成功", success = true, response = response }; } } }