商品模块代码提交

This commit is contained in:
谭凯凯
2025-02-11 15:16:43 +08:00
committed by Tankaikai
parent 0da6ec2890
commit 3b62eb6079
13 changed files with 472 additions and 82 deletions

View File

@@ -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());
}