diff --git a/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml index 4ee6379d5..9267cd2bd 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml @@ -49,9 +49,6 @@ is_terminated = #{isTerminated}, remark = #{remark}, actual_complete_time = if(is_terminated, now(), null) - - , audit_id = #{auditId} - where shop_id = #{shopId} and shop_sub_stage = #{shopSubStage} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/handler/CustomExceptionHandler.java b/coolstore-partner-service/src/main/java/com/cool/store/handler/CustomExceptionHandler.java index 40f4357ef..89053a448 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/handler/CustomExceptionHandler.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/handler/CustomExceptionHandler.java @@ -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 getErrorMessages(MethodArgumentNotValidException ex) { + List 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);