diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java index c0bcc2a..2bac670 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java @@ -2,8 +2,12 @@ package com.api.xuanran.wang.eny.workflow.controller; import aiyh.utils.ApiResult; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -21,6 +25,9 @@ import java.util.Map; @Path("/wxr/eny/workflow/rate") public class GetExchangeRate { + private final Logger log = Util.getLogger(); + private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class); + @POST @Path("/exchange") @Produces(MediaType.APPLICATION_OCTET_STREAM) @@ -28,17 +35,22 @@ public class GetExchangeRate { public String exchangeRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map params){ - String baseCurrency = request.getParameter("baseCurrency"); - String interfaceCurrency = request.getParameter("interfaceCurrency"); - params.get("area"); - if(StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){ - return ApiResult.error("本位币或接口响应币种为空!"); - } - - } - - private void checkParams(Map params){ - for (Map.Entry entry : params.entrySet()) { + try { + // 地区 + String area = Util.null2DefaultStr(params.get("area"),""); + // 本位币 + String baseCurrency = Util.null2DefaultStr(params.get("baseCurrency"),""); + // 接口币种 + String interfaceCurrency = Util.null2DefaultStr(params.get("interfaceCurrency"),""); + if(StringUtils.isBlank(area) || StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){ + log.error("params : " + JSONObject.toJSONString(params)); + throw new CustomerException("参数不可为空!"); + } + String interfac = mapper.selectCurrencyIdByCurrencyName(interfaceCurrency); + return ""; + }catch (Exception e){ + return ApiResult.error("汇率转换error : " + e.getMessage()); } } + } diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java new file mode 100644 index 0000000..8fe3999 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java @@ -0,0 +1,17 @@ +package com.api.xuanran.wang.eny.workflow.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/14 15:23 + */ +@SqlMapper +public interface ExchangeRateMapper { + @Select("select id from fnacurrency where currencyname = #{currencyName}") + String selectCurrencyIdByCurrencyName(@ParamMapper("currencyName") String currencyName); +}