refactor: 根包由 com.bestsch.bschclassmanage 重命名为 com.yunhai.bschclassmanage
- git mv src/main/java/com/bestsch/bschclassmanage -> src/main/java/com/yunhai/bschclassmanage - 255 个 Java 文件的 package/import 同步替换为 com.yunhai.bschclassmanage - pom.xml 项目 groupId 设为 com.yunhai(与外部依赖 com.bestsch:bsch-* 无关,未改动) - IDE 缓存 workspace.xml 路径同步更新(外部依赖坐标 com.bestsch:bsch-* 保持不动)
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
package com.yunhai.bschclassmanage.controller.Handler;
|
||||
|
||||
import com.yunhai.platform.utils.exception.ErrorCode;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class ValidationExceptionHandler {
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<Map<String, Object>> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||
List<String> msgList = new ArrayList<>();
|
||||
ex.getBindingResult().getAllErrors().forEach(error -> {
|
||||
String errorMessage = error.getDefaultMessage();
|
||||
msgList.add(errorMessage);
|
||||
});
|
||||
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("code", ErrorCode.ERROR.getCode());
|
||||
response.put("msg", String.join(";", msgList));
|
||||
response.put("data", null);
|
||||
response.put("timeNow", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
|
||||
return new ResponseEntity(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user