Commit c9200409 authored by 杨钧's avatar 杨钧

修改get请求验证方式

parent 06af8c41
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IOrderService; import cn.quantgroup.customer.service.IOrderService;
import cn.quantgroup.customer.service.IXyqbService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/** /**
* @author Wang Xiangwei * @author Wang Xiangwei
......
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.rest.param.card.ModifyCardsQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
...@@ -9,7 +8,7 @@ import cn.quantgroup.customer.service.IRepayService; ...@@ -9,7 +8,7 @@ import cn.quantgroup.customer.service.IRepayService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -17,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -17,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.StringJoiner;
import static cn.quantgroup.customer.constant.Constant.GSON; import static cn.quantgroup.customer.constant.Constant.GSON;
@Slf4j @Slf4j
...@@ -50,8 +51,14 @@ public class RepayRest { ...@@ -50,8 +51,14 @@ public class RepayRest {
* @return * @return
*/ */
@GetMapping("/info") @GetMapping("/info")
public JsonResult queryRepayInfo(@Valid RepayOrderInfoQuery repayOrderQuery) { public JsonResult queryRepayInfo(@Valid RepayOrderInfoQuery repayOrderQuery, BindingResult bindingResult) {
log.info("[查询还款信息],请求参数:repayOrderQuery={}", repayOrderQuery); log.info("[查询还款信息],请求参数:repayOrderQuery={}", repayOrderQuery);
if(bindingResult.hasErrors()){
StringJoiner errorStr = new StringJoiner(";");
bindingResult.getFieldErrors().forEach(fieldError -> errorStr.add(fieldError.getDefaultMessage()));
log.info("[查询还款信息],请求参数验证异常:errorStr={}", errorStr);
return JsonResult.buildErrorStateResult(errorStr.toString(),ErrorCodeEnum.PARAM_ERROR.getCode());
}
return repayService.queryRepayInfo(repayOrderQuery); return repayService.queryRepayInfo(repayOrderQuery);
} }
......
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