商品模块代码提交
This commit is contained in:
@@ -7,6 +7,7 @@ import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@@ -82,6 +83,11 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public CzgResult handleDuplicateKeyException(DuplicateKeyException ex) {
|
||||
return CzgResult.failure(CzgRespCode.RECORD_EXISTED);
|
||||
}
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user