package com.billpaymentservice.bbps.controller; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; 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; import lombok.extern.slf4j.Slf4j; @RestController @RequestMapping("/auth") @CrossOrigin(origins = "*") @Slf4j public class AuthController { private final AuthService authService; public AuthController(AuthService authService) { this.authService = authService; } @PostMapping(value = "/sendOtp", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity sendOtp(@Validated @RequestBody LoginRequest request) { log.info("Received sendOtp request for mobile: {}", request.getMobile()); return ResponseEntity.ok(authService.sendOtp(request)); } @PostMapping(value = "/verifyOtp", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity verifyOtp(@Validated @RequestBody VerifyOtpRequest request) { return ResponseEntity.ok(authService.verifyOtp(request)); } @PostMapping(value = "/register", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity register(@Validated @RequestBody RegisterRequest request) { return ResponseEntity.ok(authService.registerUser(request)); } @PostMapping("/loginWithoutDecryption") public ResponseEntity login(@RequestBody LoginRequest loginRequest) { return ResponseEntity.ok(authService.authenticateUser(loginRequest)); } }