| | |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.ExchangeRate; |
| | | import com.nq.service.ExchangeRateService; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | @ResponseBody |
| | | public ServerResponse getInfo(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) { |
| | | return exchangeRateService.getInfo(pageNum, pageSize); |
| | | return exchangeRateService.getInfoPage(pageNum, pageSize); |
| | | } |
| | | |
| | | //修改汇率 |
| | | @RequestMapping({"editRate.do"}) |
| | | @PostMapping({"editRate.do"}) |
| | | @ResponseBody |
| | | public ServerResponse editRate(ExchangeRate model, HttpServletRequest request) { |
| | | if (model == null) { |
| | | return ServerResponse.createByErrorMsg("editRate model is null"); |
| | | } |
| | | if (model.getRata() == null || model.getCurrency().isEmpty() || model.getConversionCurrency().isEmpty()) { |
| | | if (model.getRata() == null || StringUtils.isBlank(model.getCurrency()) || StringUtils.isBlank(model.getConversionCurrency())) { |
| | | return ServerResponse.createByErrorMsg("请输入货币和汇率参数不能为空"); |
| | | } |
| | | if (model.getCurrency().equals(model.getConversionCurrency())) { |
| | | return ServerResponse.createByErrorMsg("原始货币和转换货币不能相同"); |
| | | } |
| | | //货币只能为US或MX |
| | | if (!model.getCurrency().equals(EStockType.US.getSymbol()) && !model.getCurrency().equals(EStockType.MX.getSymbol())) { |
| | | return ServerResponse.createByErrorMsg("货币只能为:" + EStockType.US.getSymbol() + " 或 " + EStockType.MX.getSymbol()); |
| | | |
| | | if (EStockType.getEStockTypeBySymbol(model.getCurrency()) == null) { |
| | | return ServerResponse.createByErrorMsg("货币不能为:" + model.getCurrency()); |
| | | } |
| | | if (!model.getConversionCurrency().equals(EStockType.US.getSymbol()) && !model.getConversionCurrency().equals(EStockType.MX.getSymbol())) { |
| | | return ServerResponse.createByErrorMsg("转换货币只能为:" + EStockType.US.getSymbol() + " 或 " + EStockType.MX.getSymbol()); |
| | | if (EStockType.getEStockTypeBySymbol(model.getConversionCurrency()) == null) { |
| | | return ServerResponse.createByErrorMsg("转换货币不能为:" + model.getConversionCurrency()); |
| | | } |
| | | return exchangeRateService.updateRate(model, request); |
| | | } |