add validation in request
This commit is contained in:
@@ -10,10 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.auth.AuthResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.AuthResponses;
|
||||
import com.billpaymentservice.bbps.dto.auth.LoginRequest;
|
||||
import com.billpaymentservice.bbps.dto.auth.OtpSendResponse;
|
||||
import com.billpaymentservice.bbps.dto.auth.RegisterRequest;
|
||||
import com.billpaymentservice.bbps.dto.auth.VerifyOtpRequest;
|
||||
import com.billpaymentservice.bbps.service.AuthService;
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
package com.billpaymentservice.bbps.dto.auth;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class LoginRequest {
|
||||
private String mobile;
|
||||
|
||||
public LoginRequest() {}
|
||||
@NotNull(message = "Mobile number cannot be null.")
|
||||
@Size(min = 10, max = 10, message = "Mobile number must be exactly 10 digits.")
|
||||
@Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must contain only digits.")
|
||||
private String mobile;
|
||||
|
||||
public LoginRequest(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public LoginRequest() {
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public LoginRequest(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,31 @@ package com.billpaymentservice.bbps.dto.auth;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.request.BaseClass;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class RegisterRequest extends BaseClass {
|
||||
|
||||
@NotNull(message = "Mobile number cannot be null.")
|
||||
@Size(min = 10, max = 10, message = "Mobile number must be exactly 10 digits.")
|
||||
@Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must contain only 10 digits.")
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "Name cannot be null.")
|
||||
@Size(min = 2, max = 100, message = "Name must be between 2 and 100 characters.")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "Email cannot be null.")
|
||||
@Email(message = "Email must be a valid email address.")
|
||||
private String email;
|
||||
|
||||
@NotNull(message = "Registration token cannot be null.")
|
||||
private String registrationToken;
|
||||
|
||||
}
|
||||
@@ -1,30 +1,42 @@
|
||||
package com.billpaymentservice.bbps.dto.auth;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class VerifyOtpRequest {
|
||||
private String mobile;
|
||||
private String otp;
|
||||
|
||||
public VerifyOtpRequest() {
|
||||
}
|
||||
@NotNull(message = "Mobile number cannot be null.")
|
||||
@Size(min = 10, max = 10, message = "Mobile number must be exactly 10 digits.")
|
||||
@Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must contain only digits.")
|
||||
private String mobile;
|
||||
|
||||
public VerifyOtpRequest(String mobile, String otp) {
|
||||
this.mobile = mobile;
|
||||
this.otp = otp;
|
||||
}
|
||||
@NotNull(message = "OTP cannot be null.")
|
||||
@Size(min = 6, max = 6, message = "OTP must be exactly 6 digits.")
|
||||
@Pattern(regexp = "^[0-9]{6}$", message = "OTP must contain only 6 digits.")
|
||||
private String otp;
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public VerifyOtpRequest() {
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public VerifyOtpRequest(String mobile, String otp) {
|
||||
this.mobile = mobile;
|
||||
this.otp = otp;
|
||||
}
|
||||
|
||||
public String getOtp() {
|
||||
return otp;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setOtp(String otp) {
|
||||
this.otp = otp;
|
||||
}
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getOtp() {
|
||||
return otp;
|
||||
}
|
||||
|
||||
public void setOtp(String otp) {
|
||||
this.otp = otp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -7,9 +9,16 @@ import lombok.Setter;
|
||||
@Setter
|
||||
public class ComplaintRequestDTO extends BaseClass {
|
||||
|
||||
private String ticketDescription; // Complaint description that the user enters
|
||||
private String ticketDisposition; // Complaint disposition
|
||||
private String ticketDispositionCode; // Type of complaint
|
||||
private String txnId; // Transaction ID (optional)
|
||||
@NotBlank(message = "Ticket description cannot be null.")
|
||||
private String ticketDescription;
|
||||
|
||||
@NotBlank(message = "Ticket disposition cannot be null.")
|
||||
private String ticketDisposition;
|
||||
|
||||
@NotBlank(message = "Ticket disposition code cannot be null.")
|
||||
private String ticketDispositionCode;
|
||||
|
||||
@NotBlank(message = "Transaction ID cannot be null.")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -9,9 +10,13 @@ public class TicketCheckStatusResponse {
|
||||
|
||||
private String refId;
|
||||
private TicketDetailsDTO ticketDetails;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String message;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String remarks;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String status;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String statusCode;
|
||||
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
Optional<TransactionMaster> dataById = transactionMasterRepository.findById(complainRequestDTO.getTxnId());
|
||||
if (dataById == null || dataById.isEmpty()) {
|
||||
LOGGER.warn("Txn Id is null");
|
||||
throw new CustomException("Txn Id is required", "FAILED", BBPSConstant.BADREQUEST, null);
|
||||
LOGGER.warn("Txn Data Not Found This Txn Id is null");
|
||||
throw new CustomException(BBPSConstant.USER_Txn_IS_NOT_FOUND, "FAILED", BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
TransactionMaster transData = dataById.get();
|
||||
|
||||
@@ -150,6 +150,7 @@ public class BBPSConstant {
|
||||
public static final String ALL_COMPLAINT_FIELDS_FETCH = "All complaint fields fetched successfully";
|
||||
public static final String SOMETHING_WENT_WRONG = "Something went wrong";
|
||||
public static final String USER_ID_IS_EMPTY = "User id is empty";
|
||||
public static final String USER_Txn_IS_NOT_FOUND = "Not Txn Found This Txn Id";
|
||||
|
||||
// Timing/delay constants (milliseconds)
|
||||
public static final long BILL_FETCH_DELAY_MS = 5000L; // used after initiate bill fetch
|
||||
|
||||
Reference in New Issue
Block a user