新增获取选科数据结果

develop
old易 2024-06-05 15:49:12 +08:00
parent 612bfe77ed
commit 0f40aa822f
3 changed files with 77 additions and 1 deletions

View File

@ -109,5 +109,45 @@ namespace New_College.Api.Controllers.Front
/// <summary>
/// 获取选科数据结果
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<SelectionResponseDto>>> GetSelect([FromQuery] SelectionRequest request)
{
var response = new List<SelectionResponseDto>();
Expression<Func<SubjectSelection, bool>> exp = Expressionable.Create<SubjectSelection>() //创建表达式
.AndIF(request.UniversityName != null && request.UniversityName.Count() > 0, w => SqlFunc.ContainsArray(request.UniversityName, w.UniversityName))
.AndIF(request.MajorName != null && request.MajorName.Count() > 0, w => SqlFunc.ContainsArray(request.MajorName, w.MajorName))
.AndIF(!string.IsNullOrWhiteSpace(request.LocationCode), w => w.Province == request.LocationCode)
.And(w => w.AcademicYear == DateTime.Now.Year.ToString())
.ToExpression();//注意 这一句 不能少
var subjectlist = await _selectionServices.Query(exp);
response = subjectlist.Select(c => new SelectionResponseDto()
{
MajorName = c.MajorName
}).ToList();
response.ForEach(a =>
{
a.selects = subjectlist.Where(e => e.MajorName == a.MajorName).Select(c => new SelectResponseDto()
{
Selection = c.Selection,
UniversityName = c.UniversityName
}).ToList();
});
return new MessageModel<List<SelectionResponseDto>>()
{
response = response,
success = true,
msg = "ok"
};
}
}
}

View File

@ -5,7 +5,7 @@ using System.Text;
namespace New_College.Model.Request
{
public class SelectionServiceRequest: BasePageRequest
public class SelectionServiceRequest : BasePageRequest
{
public string UniversityName { get; set; }
@ -16,4 +16,16 @@ namespace New_College.Model.Request
public int Years { get; set; }
}
public class SelectionRequest
{
/// <summary>
/// 这里
/// </summary>
public string LocationCode { get; set; }
public List<string> UniversityName { get; set; }
public List<string> MajorName { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace New_College.Model
{
public class SelectionResponseDto
{
public string MajorName { get; set; }
public List<SelectResponseDto> selects { get; set; }
}
public class SelectResponseDto
{
public string UniversityName { get; set; }
public string Selection { get; set; }
}
}