90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using Microsoft.Extensions.Caching.Distributed;
|
|
using Newtonsoft.Json.Serialization;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Flurl;
|
|
using Flurl.Http;
|
|
using MongoDB.Bson;
|
|
|
|
namespace Admin.NET.Core.Service;
|
|
|
|
|
|
/// <summary>
|
|
/// 选科模块
|
|
/// </summary>
|
|
[ApiDescriptionSettings(ApplicationConst.ZYGroupName, Order = 900)]
|
|
[Route("api/ZySelectSubject")]
|
|
public class ZYSelectSubjectService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly IDistributedCache _distributed;
|
|
private const string _cachekey = "news_";
|
|
public ZYSelectSubjectService(IDistributedCache distributedCache)
|
|
{
|
|
_distributed = distributedCache;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据院校和专业名称查询选科组合情况
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<dynamic> Selection([FromQuery] SelectionRequest request)
|
|
{
|
|
try
|
|
{
|
|
var baseurl = App.GetConfig<OutExApi>("OutExApi", true).BaseUrl;
|
|
var _option = new DistributedCacheEntryOptions()
|
|
.SetSlidingExpiration(TimeSpan.FromHours(4));
|
|
var result = await string.Format("{0}api/FrontSelection", baseurl)
|
|
.SetQueryParams(request).
|
|
GetJsonAsync<CustomPropertyResult<dynamic>>();
|
|
return result.response;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw Oops.Oh("网络开小差了~");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 根据院校和专业名称List查询选科组合情况
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<dynamic> NewSelection([FromBody] SelectionRequestDto request)
|
|
{
|
|
try
|
|
{
|
|
var baseurl = App.GetConfig<OutExApi>("OutExApi", true).BaseUrl;
|
|
var _option = new DistributedCacheEntryOptions()
|
|
.SetSlidingExpiration(TimeSpan.FromHours(4));
|
|
var flurResponse = await string.Format("{0}api/FrontSelection/GetSelect", baseurl)
|
|
.PostJsonAsync(request);
|
|
var result = await flurResponse.GetJsonAsync<CustomPropertyResult<dynamic>>();
|
|
|
|
return result.response;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw Oops.Oh("网络开小差了~");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|