修复问题

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.ApiResult;
import aiyh.utils.Util; 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 io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -21,6 +25,9 @@ import java.util.Map;
@Path("/wxr/eny/workflow/rate") @Path("/wxr/eny/workflow/rate")
public class GetExchangeRate { public class GetExchangeRate {
private final Logger log = Util.getLogger();
private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class);
@POST @POST
@Path("/exchange") @Path("/exchange")
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
@ -28,17 +35,22 @@ public class GetExchangeRate {
public String exchangeRate(@Context HttpServletRequest request, public String exchangeRate(@Context HttpServletRequest request,
@Context HttpServletResponse response, @Context HttpServletResponse response,
@RequestBody Map<String, String> params){ @RequestBody Map<String, String> params){
String baseCurrency = request.getParameter("baseCurrency"); try {
String interfaceCurrency = request.getParameter("interfaceCurrency"); // 地区
params.get("area"); String area = Util.null2DefaultStr(params.get("area"),"");
if(StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){ // 本位币
return ApiResult.error("本位币或接口响应币种为空!"); 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));
private void checkParams(Map<String, String> params){ throw new CustomerException("参数不可为空!");
for (Map.Entry<String, String> entry : params.entrySet()) { }
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);
}