Commit cda0109f by huluobin

# 汇率方法

parent 83dcd425
package com.bailuntec.api.bailuntec.oa;
import com.bailuntec.api.bailuntec.oa.response.ExchangeRate;
import com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp;
import com.bailuntec.api.bailuntec.oa.response.OaUserResp;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDate;
import java.util.List;
/**
......@@ -59,4 +62,18 @@ public interface OaApi {
@GetMapping("/api/ExchangeRate/GetExchangeRate")
String getExchangeRate(@RequestParam("fromCur") String fromCur,
@RequestParam("toCur") String toCur);
/**
* 获取汇率
*
* @param fromCur 源币种
* @param toCur 目标币种
* @param date 汇率日期
* @return {@link com.bailuntec.api.bailuntec.oa.response.ExchangeRate}
*/
@GetMapping("/api/ExchangeRate/GetExchangeRateByCurAndDate")
ExchangeRate getExchangeRateByCurAndDate(@RequestParam("fromCur") String fromCur,
@RequestParam("toCur") String toCur,
@RequestParam("date")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") LocalDate date);
}
package com.bailuntec.api.bailuntec.oa.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
......@@ -23,6 +24,7 @@ public class ExchangeRate {
@JsonProperty("ToCurName")
private String toCurName;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@JsonProperty("CreateTime")
private LocalDateTime createTime;
......
......@@ -12,6 +12,7 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.time.LocalDate;
/**
* <p>
......@@ -46,4 +47,10 @@ class OaApiTest {
ExchangeRate exchangeRate = JsonUtilByFsJson.jsonToBean(response, ExchangeRate.class);
log.info(exchangeRate.toString());
}
@Test
void GetExchangeRateByCurAndDate(){
ExchangeRate exchangeRate =oaApi.getExchangeRateByCurAndDate("CNY","USD", LocalDate.now());
log.info(JsonUtilByFsJson.beanToJson(exchangeRate));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment