Commit a8b0fd68 authored by 332784038@qq.com's avatar 332784038@qq.com

提供全部可用货币汇率信息查询接口

parent f4f5c988
...@@ -69,4 +69,4 @@ ALTER TABLE `ecw_currency_rate` ADD COLUMN `target_currency_code` varchar(255) C ...@@ -69,4 +69,4 @@ ALTER TABLE `ecw_currency_rate` ADD COLUMN `target_currency_code` varchar(255) C
update `ecw_currency_rate` r left join `ecw_currency` c1 on r.source_id = c1.id left join `ecw_currency` c2 on r.target_id = c2.id update `ecw_currency_rate` r left join `ecw_currency` c1 on r.source_id = c1.id left join `ecw_currency` c2 on r.target_id = c2.id
set r.`source_currency_code` = c1.fuhao, r.`target_currency_code` = c2.fuhao set r.`source_currency_code` = c1.fuhao, r.`target_currency_code` = c2.fuhao;
\ No newline at end of file \ No newline at end of file
...@@ -26,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated @Validated
...@@ -69,6 +71,13 @@ public class CurrencyRateController { ...@@ -69,6 +71,13 @@ public class CurrencyRateController {
return success(service.query(param)); return success(service.query(param));
} }
@GetMapping("/all/available")
@ApiOperation("获取全部的未过期的可用汇率信息列表")
public CommonResult<List<CurrencyRateDO>> allAvailable(@Valid CurrencyRateQueryParamVO param) {
return success(service.allAvailable());
}
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("根据币种获取汇率信息") @ApiOperation("根据币种获取汇率信息")
@PreAuthorize("@ss.hasPermission('ecw:currency:rate:query')") @PreAuthorize("@ss.hasPermission('ecw:currency:rate:query')")
......
...@@ -34,4 +34,13 @@ public interface CurrencyRateMapper extends AbstractMapper<CurrencyRateDO> { ...@@ -34,4 +34,13 @@ public interface CurrencyRateMapper extends AbstractMapper<CurrencyRateDO> {
.orderByDesc(Arrays.asList(CurrencyRateDO::getUpdateTime, CurrencyRateDO::getExpiration)); .orderByDesc(Arrays.asList(CurrencyRateDO::getUpdateTime, CurrencyRateDO::getExpiration));
return selectPage(param, wrapper); return selectPage(param, wrapper);
} }
default List<CurrencyRateDO> allAvailable() {
Date now = new Date();
LambdaQueryWrapper<CurrencyRateDO> wrapper = Wrappers.lambdaQuery(CurrencyRateDO.class)
.gt( CurrencyRateDO::getExpiration, now)
.orderByDesc(CurrencyRateDO::getId);
return selectList(wrapper);
}
} }
...@@ -172,4 +172,8 @@ public interface CurrencyRateService { ...@@ -172,4 +172,8 @@ public interface CurrencyRateService {
* @return 分页结果 * @return 分页结果
*/ */
PageResult<CurrencyRateLogDO> history(long id, PageParam param); PageResult<CurrencyRateLogDO> history(long id, PageParam param);
List<CurrencyRateDO> allAvailable();
} }
...@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -152,4 +153,9 @@ public class CurrencyRateServiceImpl implements CurrencyRateService { ...@@ -152,4 +153,9 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
.orderByDesc(CurrencyRateLogDO::getCreateTime); .orderByDesc(CurrencyRateLogDO::getCreateTime);
return logMapper.selectPage(param, wrapper); return logMapper.selectPage(param, wrapper);
} }
@Override
public List<CurrencyRateDO> allAvailable() {
return mapper.allAvailable();
}
} }
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