149 lines
4.8 KiB
C#
149 lines
4.8 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;
|
||
|
||
public SeVolunteerInitializationController(ID_SeVolunteerInitializationServices D_SeVolunteerInitializationServices)
|
||
{
|
||
_d_SeVolunteerInitializationServices = D_SeVolunteerInitializationServices;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 志愿填报省份数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public async Task<MessageModel<List<SeVolunterInitializationDto>>> Get()
|
||
{
|
||
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 = c.Id
|
||
|
||
}).ToList();
|
||
int nowyear = DateTime.Now.Year;
|
||
int month = DateTime.Now.Month;
|
||
sevolunterlist.ForEach(a =>
|
||
{
|
||
var list = new List<LizationDto>();
|
||
if (month < 8)//大于8月份则高考时间已过,为往届高考生
|
||
{
|
||
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.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
|
||
});
|
||
|
||
}
|
||
else
|
||
{
|
||
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
|
||
|
||
});
|
||
list.Add(new LizationDto()
|
||
{
|
||
name = (nowyear + 3).ToString() + "(现高一)",
|
||
code = nowyear + 3,
|
||
Policy = nowyear + 3 < a.Years ? 0 : a.Policy
|
||
});
|
||
}
|
||
a.lizations = list;
|
||
|
||
});
|
||
|
||
data.response = sevolunterlist;
|
||
data.msg = "ok";
|
||
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;
|
||
}
|
||
|
||
|
||
}
|
||
} |