using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using MySqlX.XDevAPI; using OASystem.API.OAMethodLib.JuHeAPI; using OASystem.Domain.Dtos.Groups; using OASystem.Domain.Dtos.SmallFun; using OASystem.Domain.ViewModels.JuHeExchangeRate; using SqlSugar; using System.Buffers; using System.Collections.Generic; using System.Collections.Immutable; using System.Collections.Specialized; using System.Text.Json; using System.Text.Json.Nodes; using System.Xml.Linq; namespace OASystem.API.Controllers { /// /// 小功能接口 /// [Route("api/[controller]/[action]")] [ApiController] public class SmallFunController : ControllerBase { private readonly IJuHeApiService _juHeApiService; private readonly IConfiguration _config; /// /// 初始化 /// /// public SmallFunController(IJuHeApiService juHeApiService, IConfiguration config) { this._juHeApiService = juHeApiService; this._config = config; } #region 聚合汇率相关 /// /// 获取汇率币种 /// /// [HttpPost] [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)] public async Task GeRateCurrency() { var rateCurrencyData = AppSettingsHelper.Get("RateCurrency"); return Ok(JsonView(rateCurrencyData)); } /// /// 获取汇率费用 /// /// [HttpPost] [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)] public async Task GeExchangeRate(ExchangeRateDto rateDto) { #region 参数处理 if (string.IsNullOrEmpty(rateDto.CurrencyCodePer) || string.IsNullOrEmpty(rateDto.CurrencyCodeSuf)) { return Ok(JsonView(false, "币种参数为空!")); } if (rateDto.Money <= 0) { return Ok(JsonView(false, "转换金额 <= 0!")); } #endregion var result = await _juHeApiService.GetExchangeRateAsync(rateDto); if (result.Code != 0 || result == null) { return Ok(JsonView(false, result.Msg)); } return Ok(JsonView(result.Data)); } #endregion } }