132 lines
4.1 KiB
C#
132 lines
4.1 KiB
C#
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
|
|
{
|
|
|
|
/// <summary>
|
|
/// 专业分数线
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class PlanMajorScoreLineController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
|
|
/// </summary>
|
|
private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private readonly ID_ScoreLineServices id_coreLineServices;
|
|
public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices, ID_ScoreLineServices _ScoreLineServices)
|
|
{
|
|
_d_PlanMajorScoreLineServices = D_PlanMajorScoreLineServices;
|
|
id_coreLineServices = _ScoreLineServices;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 导入专业最低录取位次表=同步更新专业数据与学校专业分数线(--高考时可通用此功能)
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<MessageModel<bool>> ImportMajorData(IFormFile file)
|
|
{
|
|
var _list = new List<D_PlanMajorScoreLine>();
|
|
var list = ExcelProUtil<ImportPlanMajorScoreRequest>.InputExcel(file);
|
|
//1. 查询匹配一分一段表数据
|
|
|
|
|
|
|
|
|
|
|
|
//2. 更新招生计划专业数据
|
|
|
|
|
|
|
|
//3. 更新学校最低专业录取线
|
|
|
|
|
|
|
|
// await _d_PlanMajorScoreLineServices.Add(_list);
|
|
return new MessageModel<bool>()
|
|
{
|
|
success = true,
|
|
response = true,
|
|
status = 200,
|
|
msg = "ok"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取学校专业分数线
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<MessageModel<List<PlanMajorScoreLineResponse>>> Get([FromQuery] PlanMajorScoreLineRequest request)
|
|
{
|
|
if (request.Uid <= 0)
|
|
{
|
|
return new MessageModel<List<PlanMajorScoreLineResponse>>()
|
|
{
|
|
success = false,
|
|
msg = "uid必传"
|
|
};
|
|
}
|
|
Expression<Func<D_PlanMajorScoreLine, bool>> expression = Expressionable.Create<D_PlanMajorScoreLine>()
|
|
.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<List<PlanMajorScoreLineResponse>>()
|
|
{
|
|
msg = "获取成功",
|
|
success = true,
|
|
response = response
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
} |