Archived
refactor: streaming download, Git LFS templates, deploy workflow
- Replace base64 JSON response with StreamingResponseBody (zero-buffer) - Error responses return JSON via GlobalExceptionHandler (400/404) - Add git-lfs track for *.docx to keep repo lean - Add deploy/deploy.sh: one-click build + restart - Add deploy/clean-lfs.sh: periodic LFS cache cleanup - Add deploy/gmp-service.service: systemd service unit - Remove unused ApiResponse and DocxExportData DTOs - Fix build.sh/run.sh jar name (gmp-mock-service -> gmp-service) - Add TemplateNotFoundException for missing templates
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.gmp.mock.handler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -7,16 +8,23 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import com.gmp.mock.dto.ApiResponse;
|
||||
import com.gmp.mock.service.TemplateNotFoundException;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleValidation(MethodArgumentNotValidException ex) {
|
||||
public ResponseEntity<Map<String, Object>> handleValidation(MethodArgumentNotValidException ex) {
|
||||
String message = ex.getBindingResult().getFieldErrors().stream()
|
||||
.map(e -> e.getDefaultMessage())
|
||||
.collect(Collectors.joining("; "));
|
||||
return ResponseEntity.ok(ApiResponse.error(400, message));
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("code", 400, "msg", message));
|
||||
}
|
||||
|
||||
@ExceptionHandler(TemplateNotFoundException.class)
|
||||
public ResponseEntity<Map<String, Object>> handleTemplateNotFound(TemplateNotFoundException ex) {
|
||||
return ResponseEntity.status(404)
|
||||
.body(Map.of("code", 404, "msg", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user