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; /// /// 选科模块 /// [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; } /// /// 根据院校和专业名称查询选科组合情况 /// /// /// [HttpGet] public async Task Selection([FromQuery] SelectionRequest request) { try { var baseurl = App.GetConfig("OutExApi", true).BaseUrl; var _option = new DistributedCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromHours(4)); var result = await string.Format("{0}api/FrontSelection", baseurl) .SetQueryParams(request). GetJsonAsync>(); return result.response; } catch (Exception ex) { throw Oops.Oh("网络开小差了~"); } } /// /// 根据院校和专业名称List查询选科组合情况 /// /// /// [HttpPost] public async Task NewSelection([FromBody] SelectionRequestDto request) { try { var baseurl = App.GetConfig("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>(); return result.response; } catch (Exception ex) { throw Oops.Oh("网络开小差了~"); } } }