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;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using New_College.Common;
namespace New_College.Api.Controllers
{
///
/// 专业分数线
///
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize]
public class PlanMajorScoreLineController : ControllerBase
{
///
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
///
private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices;
///
///
///
private readonly ID_ScoreLineServices id_coreLineServices;
public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices, ID_ScoreLineServices _ScoreLineServices)
{
_d_PlanMajorScoreLineServices = D_PlanMajorScoreLineServices;
id_coreLineServices = _ScoreLineServices;
}
///
/// 导入专业最低录取位次表=同步更新专业数据与学校专业分数线(--高考时可通用此功能)
///
///
///
[HttpPost]
public async Task> ImportMajorData(IFormFile file)
{
var _list = new List();
var list = ExcelProUtil.InputExcel(file);
//1. 查询匹配一分一段表数据
//2. 更新招生计划专业数据
//3. 更新学校最低专业录取线
// await _d_PlanMajorScoreLineServices.Add(_list);
return new MessageModel()
{
success = true,
response = true,
status = 200,
msg = "ok"
};
}
///
/// 获取学校专业分数线
///
///
///
[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
};
}
}
}