114 lines
3.7 KiB
C#
114 lines
3.7 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 Org.BouncyCastle.Asn1.Ocsp;
|
|
using System.Linq;
|
|
|
|
namespace New_College.Api.Controllers
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
|
|
public class SeVolunteerInitializationController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
|
|
/// </summary>
|
|
private readonly ID_SeVolunteerInitializationServices _d_SeVolunteerInitializationServices;
|
|
private readonly ISysRegionServices _sysRegionServices;
|
|
public SeVolunteerInitializationController(ID_SeVolunteerInitializationServices D_SeVolunteerInitializationServices, ISysRegionServices sysRegionServices)
|
|
{
|
|
_d_SeVolunteerInitializationServices = D_SeVolunteerInitializationServices;
|
|
_sysRegionServices = sysRegionServices;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 志愿填报省份数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<MessageModel<List<SeVolunterInitializationDto>>> Get()
|
|
{
|
|
var sysregion = await _sysRegionServices.Query(e => e.Level == 1);
|
|
var data = new MessageModel<List<SeVolunterInitializationDto>>();
|
|
var sevolunterlist = (await _d_SeVolunteerInitializationServices.Query(E => E.IsDelete == false)).Select(c => new SeVolunterInitializationDto()
|
|
{
|
|
AllScore = c.AllScore,
|
|
IsOpen = c.IsOpen,
|
|
ProvinceName = c.ProvinceName,
|
|
Policy = c.PolicyType,
|
|
Years = c.Years,
|
|
Code = sysregion.Where(e => e.RegionName == c.ProvinceName).FirstOrDefault().RegionCode
|
|
}).ToList();
|
|
|
|
DateTime dt = DateTime.Now;
|
|
DateTime fixedDate = new DateTime(dt.Year, 9, 10); // 创建当前年份的9月10日
|
|
int nowyear = dt > fixedDate ? dt.Year + 1 : dt.Year; // 比较当前日期与固定日期
|
|
sevolunterlist.ForEach(a =>
|
|
{
|
|
|
|
var list = new List<LizationDto>();
|
|
|
|
list.Add(new LizationDto()
|
|
{
|
|
name = nowyear.ToString() + "(现高三)",
|
|
code = nowyear,
|
|
Policy = nowyear < a.Years ? 0 : a.Policy
|
|
|
|
});
|
|
list.Add(new LizationDto()
|
|
{
|
|
name = (nowyear - 1).ToString() + "(现高二)",
|
|
code = nowyear - 1,
|
|
Policy = nowyear - 1 < a.Years ? 0 : a.Policy
|
|
|
|
});
|
|
list.Add(new LizationDto()
|
|
{
|
|
name = (nowyear - 2).ToString() + "(现高一)",
|
|
code = nowyear - 2,
|
|
Policy = nowyear - 2 < a.Years ? 0 : a.Policy
|
|
});
|
|
a.lizations = list;
|
|
|
|
});
|
|
|
|
data.response = sevolunterlist;
|
|
data.msg = "ok";
|
|
data.success = true;
|
|
return data;
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<MessageModel<string>> Post([FromBody] D_SeVolunteerInitialization request)
|
|
{
|
|
var data = new MessageModel<string>();
|
|
|
|
var id = await _d_SeVolunteerInitializationServices.Add(request);
|
|
data.success = id > 0;
|
|
|
|
if (data.success)
|
|
{
|
|
data.response = id.ObjToString();
|
|
data.msg = "添加成功";
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
}
|
|
} |