now can only add payload for enrolment request log auto generate requestID and always have the imei and ip in request payload for every request
parent
2255ffe2f9
commit
e7c633e10d
@ -0,0 +1,24 @@
|
||||
package com.example.Public.Configuration.config;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<?> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||
List<String> errors = ex.getBindingResult()
|
||||
.getAllErrors()
|
||||
.stream()
|
||||
.map(error -> ((FieldError) error).getField() + ": " + error.getDefaultMessage())
|
||||
.collect(Collectors.toList());
|
||||
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
@ -1,37 +1,29 @@
|
||||
package com.example.Public.Configuration.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EnrolmentRequestDTO {
|
||||
private int requestId;
|
||||
private EnrolmentRequest enrolmentRequest;
|
||||
private String responseTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class EnrolmentRequest {
|
||||
@NotBlank(message = "IMEI cannot be blank")
|
||||
private String imei;
|
||||
@NotBlank(message = "IP Address cannot be blank")
|
||||
private String ipAddress;
|
||||
private String subTypeId;
|
||||
private String smsPIN;
|
||||
private int mfwVersion;
|
||||
private int rssi;
|
||||
private String network;
|
||||
private int comTypeId;
|
||||
private String cellId;
|
||||
private String lac;
|
||||
private int sysTick;
|
||||
private String meFwVersion;
|
||||
|
||||
@NotNull
|
||||
private String imei;
|
||||
|
||||
private String ipAddress;
|
||||
private int subTypeId;
|
||||
private String smsPIN;
|
||||
private int mfwVersion;
|
||||
private int rssi;
|
||||
private String network;
|
||||
private int comTypeId;
|
||||
private String cellId;
|
||||
private String lac;
|
||||
private int sysTick;
|
||||
private String meFwVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in new issue