修复问题

dev
wangxuanran 2023-07-14 15:27:17 +08:00
parent 45377caf4f
commit fac5e483e2
2 changed files with 40 additions and 11 deletions

View File

@ -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<String, String> 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<String, String> params){
for (Map.Entry<String, String> 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());
}
}
}

View File

@ -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;
/**
* <h1></h1>
*
* @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);
}