1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Added UserManagement

This commit is contained in:
2023-05-17 15:39:28 +08:00
parent e1bdb21756
commit e5a3cb83be
13 changed files with 656 additions and 58 deletions

View File

@@ -1,6 +1,8 @@
package com.cfive.pinnacle.handler;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -8,6 +10,9 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
public class CustomExceptionHandler {
@ExceptionHandler(value = Exception.class)
public ResponseResult exceptionHandler(Exception e) {
if (e instanceof DuplicateKeyException) {
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "无法添加重复数据", null);
}
return ResponseResult.fail(e.getClass().toString() + ": " + e.getMessage());
}
}