fix
This commit is contained in:
@@ -49,9 +49,6 @@
|
||||
is_terminated = #{isTerminated},
|
||||
remark = #{remark},
|
||||
actual_complete_time = if(is_terminated, now(), null)
|
||||
<if test="auditId != null">
|
||||
, audit_id = #{auditId}
|
||||
</if>
|
||||
where
|
||||
shop_id = #{shopId} and shop_sub_stage = #{shopSubStage}
|
||||
</update>
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
package com.cool.store.handler;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.response.error.ErrorResponse;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
@@ -38,6 +39,22 @@ public class CustomExceptionHandler {
|
||||
responseResult(httpServletResponse, responseResult);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
public void handleCustomException(MethodArgumentNotValidException e, HttpServletResponse httpServletResponse) {
|
||||
log.error(e.getMessage(), e);
|
||||
ResponseResult responseResult = new ResponseResult(500, String.join(",", getErrorMessages(e)));
|
||||
responseResult(httpServletResponse, responseResult);
|
||||
}
|
||||
|
||||
private List<String> getErrorMessages(MethodArgumentNotValidException ex) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
ex.getBindingResult().getAllErrors().forEach((error) -> {
|
||||
FieldError fieldError = (FieldError) error;
|
||||
errors.add(fieldError.getObjectName() + " " + fieldError.getDefaultMessage());
|
||||
});
|
||||
return errors;
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ApiException.class)
|
||||
public void handleCustomException(ApiException e, HttpServletResponse httpServletResponse) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user