|
|
@ -1,11 +1,10 @@ |
|
|
package com.gcc.coworkspace.controller; |
|
|
package com.gcc.coworkspace.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.gcc.coworkspace.component.UserSession; |
|
|
import com.gcc.coworkspace.component.UserSession; |
|
|
import com.gcc.coworkspace.configuration.AppConfig; |
|
|
import com.gcc.coworkspace.configuration.AppConfig; |
|
|
import com.gcc.coworkspace.configuration.QrGenerator; |
|
|
import com.gcc.coworkspace.configuration.QrGenerator; |
|
|
import com.gcc.coworkspace.constants.AppConstants; |
|
|
import com.gcc.coworkspace.constants.AppConstants; |
|
|
|
|
|
import com.gcc.coworkspace.exception.NoSlotAvailable; |
|
|
import com.gcc.coworkspace.service.BookingService; |
|
|
import com.gcc.coworkspace.service.BookingService; |
|
|
import com.gcc.coworkspace.service.NormalSMS; |
|
|
import com.gcc.coworkspace.service.NormalSMS; |
|
|
import com.gcc.coworkspace.service.PaymentService; |
|
|
import com.gcc.coworkspace.service.PaymentService; |
|
|
@ -50,66 +49,117 @@ public class BookingController { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private PaymentService paymentService; |
|
|
private PaymentService paymentService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private NormalSMS normalSMS; |
|
|
private NormalSMS normalSMS; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* @PostMapping("/saveInTemp") |
|
|
|
|
|
* public Map<String, Object> booking(@RequestParam("catId") int catId, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("buildId") int buildId, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("subId") int subId, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("noOfPeople") int noOfPeople, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("fromDate") LocalDate fromDate, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("toDate") LocalDate toDate, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("userName") String userName, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("userMobile") long userMobile, |
|
|
|
|
|
* // @RequestParam("amount") double amount, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("slots") List<Integer> slots) { |
|
|
|
|
|
* |
|
|
|
|
|
* System.out.println(catId); |
|
|
|
|
|
* System.out.println(slots); |
|
|
|
|
|
* return bookingService.saveTempBooking(userName, userMobile, slots, fromDate, |
|
|
|
|
|
* toDate, noOfPeople, catId, buildId, |
|
|
|
|
|
* subId); |
|
|
|
|
|
* |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@PostMapping("/saveInTemp") |
|
|
@PostMapping("/saveInTemp") |
|
|
public Map<String, Object> booking(@RequestParam("catId") int catId, |
|
|
|
|
|
@RequestParam("buildId") int buildId, |
|
|
|
|
|
@RequestParam("subId") int subId, |
|
|
|
|
|
@RequestParam("noOfPeople") int noOfPeople, |
|
|
|
|
|
@RequestParam("fromDate") LocalDate fromDate, |
|
|
|
|
|
@RequestParam("toDate") LocalDate toDate, |
|
|
|
|
|
@RequestParam("userName") String userName, |
|
|
|
|
|
@RequestParam("userMobile") long userMobile, |
|
|
|
|
|
// @RequestParam("amount") double amount, |
|
|
|
|
|
@RequestParam("slots") List<Integer> slots){ |
|
|
|
|
|
|
|
|
|
|
|
System.out.println(catId); |
|
|
|
|
|
System.out.println(slots); |
|
|
|
|
|
return bookingService.saveTempBooking(userName,userMobile, slots, fromDate, toDate,noOfPeople,catId,buildId,subId) ; |
|
|
|
|
|
|
|
|
public ResponseEntity<Map<String, Object>> booking( |
|
|
|
|
|
@RequestParam("catId") int catId, |
|
|
|
|
|
@RequestParam("buildId") int buildId, |
|
|
|
|
|
@RequestParam("subId") int subId, |
|
|
|
|
|
@RequestParam("noOfPeople") int noOfPeople, |
|
|
|
|
|
@RequestParam("fromDate") LocalDate fromDate, |
|
|
|
|
|
@RequestParam("toDate") LocalDate toDate, |
|
|
|
|
|
@RequestParam("userName") String userName, |
|
|
|
|
|
@RequestParam("userMobile") long userMobile, |
|
|
|
|
|
@RequestParam("slots") List<Integer> slots) { |
|
|
|
|
|
System.out.println("buildId" + buildId); |
|
|
|
|
|
System.out.println("catId" + catId); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
|
|
|
// @PostMapping("/saveBooking") |
|
|
|
|
|
// public int saveBooking(@RequestParam("tempBookId") int tempBookId){ |
|
|
|
|
|
// |
|
|
|
|
|
// return bookingService.saveBooking(tempBookId); |
|
|
|
|
|
// } |
|
|
|
|
|
/* |
|
|
|
|
|
@GetMapping("/checkAvail") |
|
|
|
|
|
public Boolean checkAvailability(int bid,int cid,LocalDate bDate,int scid,int noOfPerson,int slotId){ |
|
|
|
|
|
System.out.println("check Availability"); |
|
|
|
|
|
return bookingService.checkAvailabilityByBdate(bid,cid,bDate,scid,noOfPerson,slotId); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Map<String, Object> result = bookingService.saveTempBooking( |
|
|
|
|
|
userName, userMobile, slots, |
|
|
|
|
|
fromDate, toDate, noOfPeople, |
|
|
|
|
|
catId, buildId, subId); |
|
|
|
|
|
|
|
|
|
|
|
response.put("status", "SUCCESS"); |
|
|
|
|
|
response.putAll(result); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (NoSlotAvailable e) { |
|
|
|
|
|
|
|
|
|
|
|
response.put("status", "ERROR"); |
|
|
|
|
|
response.put("message", e.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity |
|
|
|
|
|
.status(HttpStatus.BAD_REQUEST) |
|
|
|
|
|
.body(response); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @PostMapping("/saveBooking") |
|
|
|
|
|
// public int saveBooking(@RequestParam("tempBookId") int tempBookId){ |
|
|
|
|
|
// |
|
|
|
|
|
// return bookingService.saveBooking(tempBookId); |
|
|
|
|
|
// } |
|
|
|
|
|
/* |
|
|
|
|
|
* @GetMapping("/checkAvail") |
|
|
|
|
|
* public Boolean checkAvailability(int bid,int cid,LocalDate bDate,int scid,int |
|
|
|
|
|
* noOfPerson,int slotId){ |
|
|
|
|
|
* System.out.println("check Availability"); |
|
|
|
|
|
* return |
|
|
|
|
|
* bookingService.checkAvailabilityByBdate(bid,cid,bDate,scid,noOfPerson,slotId) |
|
|
|
|
|
* ; |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@GetMapping("/checkAvail") |
|
|
@GetMapping("/checkAvail") |
|
|
public Boolean checkAvailability(int bid,int cid,LocalDate bDate,int scid,int noOfPerson,int slotId){ |
|
|
|
|
|
|
|
|
public Boolean checkAvailability(int bid, int cid, LocalDate bDate, int scid, int noOfPerson, int slotId) { |
|
|
System.out.println("check Availability"); |
|
|
System.out.println("check Availability"); |
|
|
return bookingService.checkAvailabilityByBdate(bid,cid,bDate,scid,noOfPerson,slotId); |
|
|
|
|
|
|
|
|
return bookingService.checkAvailabilityByBdate(bid, cid, bDate, scid, noOfPerson, slotId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("/hasTodayAttendance") |
|
|
@GetMapping("/hasTodayAttendance") |
|
|
public ResponseEntity<Map<String,Object>> hasTodayAttendance( |
|
|
|
|
|
|
|
|
public ResponseEntity<Map<String, Object>> hasTodayAttendance( |
|
|
@RequestParam("buildingid") int buildingid) { |
|
|
@RequestParam("buildingid") int buildingid) { |
|
|
|
|
|
|
|
|
boolean exists = bookingService.hasTodayAttendance(buildingid); |
|
|
boolean exists = bookingService.hasTodayAttendance(buildingid); |
|
|
Map<String,Object> response = new HashMap<>(); |
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
response.put("exists", exists); |
|
|
response.put("exists", exists); |
|
|
return ResponseEntity.ok(response); |
|
|
return ResponseEntity.ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping(value="/create_order") |
|
|
|
|
|
public String create_order(HttpServletRequest request,@RequestParam("id") int tempid) throws RazorpayException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/create_order") |
|
|
|
|
|
public String create_order(HttpServletRequest request, @RequestParam("id") int tempid) throws RazorpayException { |
|
|
// Get data from the service |
|
|
// Get data from the service |
|
|
Map<String, Object> tempBookingInfo = bookingService.getTempBookingByTempId(tempid); |
|
|
Map<String, Object> tempBookingInfo = bookingService.getTempBookingByTempId(tempid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the list is not empty |
|
|
// Check if the list is not empty |
|
|
if (tempBookingInfo!=null && !tempBookingInfo.isEmpty()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tempBookingInfo != null && !tempBookingInfo.isEmpty()) { |
|
|
|
|
|
|
|
|
String tempbookid = tempBookingInfo.get("tempbookid").toString(); |
|
|
String tempbookid = tempBookingInfo.get("tempbookid").toString(); |
|
|
String amount = tempBookingInfo.get("amount").toString(); |
|
|
String amount = tempBookingInfo.get("amount").toString(); |
|
|
@ -121,54 +171,52 @@ public class BookingController { |
|
|
System.out.println("Invalid number format for amount: " + amount); |
|
|
System.out.println("Invalid number format for amount: " + amount); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//To enable testing mode in appConstants if required for testing & development |
|
|
|
|
|
var client = new RazorpayClient(AppConstants.key_id,AppConstants.key_secret); |
|
|
|
|
|
|
|
|
// To enable testing mode in appConstants if required for testing & development |
|
|
|
|
|
var client = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|
|
JSONObject options = new JSONObject(); |
|
|
JSONObject options = new JSONObject(); |
|
|
options.put("amount", amountDouble * 100); |
|
|
options.put("amount", amountDouble * 100); |
|
|
options.put("currency", "INR"); |
|
|
options.put("currency", "INR"); |
|
|
Order od = client.orders.create(options); |
|
|
Order od = client.orders.create(options); |
|
|
System.out.println(od); |
|
|
System.out.println(od); |
|
|
paymentService.saveorderLog(od.get("id").toString(),od.toString(),tempbookid); |
|
|
|
|
|
|
|
|
paymentService.saveorderLog(od.get("id").toString(), od.toString(), tempbookid); |
|
|
return od.toString(); |
|
|
return od.toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
System.out.println("No data found for tempid: " + tempid); |
|
|
System.out.println("No data found for tempid: " + tempid); |
|
|
return "No data found for tempid: " + tempid; |
|
|
return "No data found for tempid: " + tempid; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// return "error"; |
|
|
|
|
|
|
|
|
// return "error"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("/Confirm") |
|
|
@PostMapping("/Confirm") |
|
|
public String updateOrder(@RequestBody Map<String,Object> data){ |
|
|
|
|
|
String tempid=data.get("id").toString();; |
|
|
|
|
|
String pay_id= data.get("payment_id").toString(); |
|
|
|
|
|
String order_id=data.get("order_id").toString(); |
|
|
|
|
|
String status=data.get("status").toString(); |
|
|
|
|
|
String amount =(Double.parseDouble(data.get("amount").toString())/100)+""; |
|
|
|
|
|
|
|
|
|
|
|
int pid = paymentService.savePayment(amount,pay_id,order_id,status,0+"",0+""); |
|
|
|
|
|
|
|
|
public String updateOrder(@RequestBody Map<String, Object> data) { |
|
|
|
|
|
String tempid = data.get("id").toString(); |
|
|
|
|
|
; |
|
|
|
|
|
String pay_id = data.get("payment_id").toString(); |
|
|
|
|
|
String order_id = data.get("order_id").toString(); |
|
|
|
|
|
String status = data.get("status").toString(); |
|
|
|
|
|
String amount = (Double.parseDouble(data.get("amount").toString()) / 100) + ""; |
|
|
|
|
|
|
|
|
|
|
|
int pid = paymentService.savePayment(amount, pay_id, order_id, status, 0 + "", 0 + ""); |
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
int bookingId = bookingser.saveBooking(Integer.parseInt(tempid),pid); |
|
|
|
|
|
// |
|
|
|
|
|
// Print or use the values as required |
|
|
|
|
|
System.out.println("Temp ID: " + tempid); |
|
|
|
|
|
System.out.println("Booking ID:- "+bookingId); |
|
|
|
|
|
return bookingId+""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int bookingId = bookingser.saveBooking(Integer.parseInt(tempid), pid); |
|
|
|
|
|
// |
|
|
|
|
|
// Print or use the values as required |
|
|
|
|
|
System.out.println("Temp ID: " + tempid); |
|
|
|
|
|
System.out.println("Booking ID:- " + bookingId); |
|
|
|
|
|
return bookingId + ""; |
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
System.out.println("error: "+e.getMessage()); |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.println("error: " + e.getMessage()); |
|
|
System.out.println("No booking data found for tempid: " + tempid); |
|
|
System.out.println("No booking data found for tempid: " + tempid); |
|
|
|
|
|
|
|
|
return "error"; |
|
|
return "error"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//mobile app development |
|
|
|
|
|
|
|
|
// mobile app development |
|
|
@GetMapping("/bookings") |
|
|
@GetMapping("/bookings") |
|
|
public ResponseEntity<List<Map<String, Object>>> getBookingsByMobileNo(@RequestParam long mobileNo) { |
|
|
public ResponseEntity<List<Map<String, Object>>> getBookingsByMobileNo(@RequestParam long mobileNo) { |
|
|
List<Map<String, Object>> bookings = bookingService.getBookingByMobileNo(mobileNo); |
|
|
List<Map<String, Object>> bookings = bookingService.getBookingByMobileNo(mobileNo); |
|
|
@ -177,6 +225,7 @@ public class BookingController { |
|
|
} |
|
|
} |
|
|
return ResponseEntity.ok(bookings); // Return 200 with the bookings data |
|
|
return ResponseEntity.ok(bookings); // Return 200 with the bookings data |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("/generate-qrcode") |
|
|
@GetMapping("/generate-qrcode") |
|
|
public ResponseEntity<?> generateQRCode(@RequestParam(required = true) String booking_id) { |
|
|
public ResponseEntity<?> generateQRCode(@RequestParam(required = true) String booking_id) { |
|
|
if (booking_id == null) { |
|
|
if (booking_id == null) { |
|
|
@ -184,7 +233,7 @@ public class BookingController { |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
// URL for the booking details API |
|
|
// URL for the booking details API |
|
|
String url = appConfig.getFull_URL()+"/bookingQRCode?booking_id=" + booking_id; |
|
|
|
|
|
|
|
|
String url = appConfig.getFull_URL() + "/bookingQRCode?booking_id=" + booking_id; |
|
|
|
|
|
|
|
|
// Generate QR code as base64 string |
|
|
// Generate QR code as base64 string |
|
|
String base64QRCode = QrGenerator.generateQRCode(url); |
|
|
String base64QRCode = QrGenerator.generateQRCode(url); |
|
|
@ -214,15 +263,14 @@ public class BookingController { |
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
System.out.print("\n otp---:" + otp); |
|
|
System.out.print("\n otp---:" + otp); |
|
|
|
|
|
|
|
|
String bodyMessage = normalSMS.sendOTPNsms(mobileNo,otp+""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String bodyMessage = normalSMS.sendOTPNsms(mobileNo, otp + ""); |
|
|
|
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
HttpSession session = request.getSession(); |
|
|
session.setAttribute("otp", otp); |
|
|
session.setAttribute("otp", otp); |
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
return bodyMessage; |
|
|
return bodyMessage; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/verifyOTP") |
|
|
@GetMapping(value = "/verifyOTP") |
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
public Map<String, Object> verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|
|
public Map<String, Object> verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|
|
@ -270,103 +318,103 @@ public class BookingController { |
|
|
return response; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
/* |
|
|
/* |
|
|
@GetMapping(value = "/verifyOTP") |
|
|
|
|
|
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
|
|
|
* @GetMapping(value = "/verifyOTP") |
|
|
|
|
|
* public String verifyOtp(HttpServletRequest request, @RequestParam String otp) |
|
|
|
|
|
* { |
|
|
|
|
|
* HttpSession session = request.getSession(); |
|
|
|
|
|
* |
|
|
|
|
|
* try { |
|
|
|
|
|
* Integer session_otp = (Integer) session.getAttribute("otp"); |
|
|
|
|
|
* System.out.println("session_otp---:" + session_otp); |
|
|
|
|
|
* Integer entered_otp = Integer.parseInt(otp); |
|
|
|
|
|
* |
|
|
|
|
|
* if (session_otp != null && session_otp.equals(entered_otp)) { |
|
|
|
|
|
* System.out.println("Entered OTP Correct"); |
|
|
|
|
|
* session.setAttribute("verifiedotp", "success"); |
|
|
|
|
|
* userSession.setMobileno(Long.parseLong(session.getAttribute("mobileNo"). |
|
|
|
|
|
* toString())); |
|
|
|
|
|
* return "Success"; |
|
|
|
|
|
* } else { |
|
|
|
|
|
* System.out.println("Incorrect OTP. Please enter correct OTPs."); |
|
|
|
|
|
* session.setAttribute("verifiedotp", "error"); |
|
|
|
|
|
* return "Error"; |
|
|
|
|
|
* } |
|
|
|
|
|
* } catch (NumberFormatException e) { |
|
|
|
|
|
* System.out.println("Invalid OTP format: " + otp); |
|
|
|
|
|
* return "Error"; |
|
|
|
|
|
* } catch (Exception e) { |
|
|
|
|
|
* System.out.println("Error verifying OTP: " + e.getMessage()); |
|
|
|
|
|
* return "Error"; |
|
|
|
|
|
* } |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
|
|
|
|
|
System.out.println("session_otp---:" + session_otp); |
|
|
|
|
|
Integer entered_otp = Integer.parseInt(otp); |
|
|
|
|
|
|
|
|
|
|
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
|
|
|
|
|
System.out.println("Entered OTP Correct"); |
|
|
|
|
|
session.setAttribute("verifiedotp", "success"); |
|
|
|
|
|
userSession.setMobileno(Long.parseLong(session.getAttribute("mobileNo").toString())); |
|
|
|
|
|
return "Success"; |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
|
|
|
|
|
session.setAttribute("verifiedotp", "error"); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
System.out.println("Invalid OTP format: " + otp); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.println("Error verifying OTP: " + e.getMessage()); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
// @PostMapping("/validatelogin") |
|
|
// @PostMapping("/validatelogin") |
|
|
// public ResponseEntity<?> checkLogin(@RequestParam String usernametxt, @RequestParam String passwordtxt, HttpSession session) { |
|
|
|
|
|
|
|
|
|
|
|
// try { |
|
|
|
|
|
// String userName = bookingser.validateLogin(usernametxt, passwordtxt); |
|
|
|
|
|
|
|
|
|
|
|
// if (userName != null) { |
|
|
|
|
|
// // Set user info in the session |
|
|
|
|
|
// session.setAttribute("mobileno", usernametxt); |
|
|
|
|
|
// session.setAttribute("user_name",userName ); |
|
|
|
|
|
|
|
|
|
|
|
// return ResponseEntity.ok(userName); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|
|
|
|
|
// } |
|
|
|
|
|
// } catch (Exception e) { |
|
|
|
|
|
// e.printStackTrace(); |
|
|
|
|
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal server error occurred"); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
// public ResponseEntity<?> checkLogin(@RequestParam String usernametxt, |
|
|
|
|
|
// @RequestParam String passwordtxt, HttpSession session) { |
|
|
|
|
|
|
|
|
|
|
|
// try { |
|
|
|
|
|
// String userName = bookingser.validateLogin(usernametxt, passwordtxt); |
|
|
|
|
|
|
|
|
// added by yogi |
|
|
|
|
|
@PostMapping("/validatelogin") |
|
|
|
|
|
public ResponseEntity<?> checkLogin( |
|
|
|
|
|
@RequestParam String usernametxt, |
|
|
|
|
|
@RequestParam String passwordtxt, |
|
|
|
|
|
HttpSession session) { |
|
|
|
|
|
|
|
|
// if (userName != null) { |
|
|
|
|
|
// // Set user info in the session |
|
|
|
|
|
// session.setAttribute("mobileno", usernametxt); |
|
|
|
|
|
// session.setAttribute("user_name",userName ); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Map<String, Object> userData = bookingser.validateLogin(usernametxt, passwordtxt); |
|
|
|
|
|
|
|
|
// return ResponseEntity.ok(userName); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|
|
|
|
|
// } |
|
|
|
|
|
// } catch (Exception e) { |
|
|
|
|
|
// e.printStackTrace(); |
|
|
|
|
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal |
|
|
|
|
|
// server error occurred"); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
if (userData != null) { |
|
|
|
|
|
|
|
|
// added by yogi |
|
|
|
|
|
@PostMapping("/validatelogin") |
|
|
|
|
|
public ResponseEntity<?> checkLogin( |
|
|
|
|
|
@RequestParam String usernametxt, |
|
|
|
|
|
@RequestParam String passwordtxt, |
|
|
|
|
|
HttpSession session) { |
|
|
|
|
|
|
|
|
String userName = (String) userData.get("user_name"); |
|
|
|
|
|
//Integer bid = (Integer) userData.get("bid"); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Map<String, Object> userData = bookingser.validateLogin(usernametxt, passwordtxt); |
|
|
|
|
|
|
|
|
// FIX: Convert BID safely |
|
|
|
|
|
Integer bid = Integer.valueOf(userData.get("bid").toString()); |
|
|
|
|
|
|
|
|
if (userData != null) { |
|
|
|
|
|
|
|
|
// Store in session |
|
|
|
|
|
// Store in session |
|
|
|
|
|
session.setAttribute("user_name", userName); |
|
|
|
|
|
session.setAttribute("bid", bid); |
|
|
|
|
|
// Return clean JSON |
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("user_name", userName); |
|
|
|
|
|
response.put("bid", bid); |
|
|
|
|
|
|
|
|
String userName = (String) userData.get("user_name"); |
|
|
|
|
|
// Integer bid = (Integer) userData.get("bid"); |
|
|
|
|
|
|
|
|
|
|
|
// FIX: Convert BID safely |
|
|
|
|
|
Integer bid = Integer.valueOf(userData.get("bid").toString()); |
|
|
|
|
|
|
|
|
System.out.println("Logged in user=" + userName + ", BID=" + bid); |
|
|
|
|
|
|
|
|
// Store in session |
|
|
|
|
|
// Store in session |
|
|
|
|
|
session.setAttribute("user_name", userName); |
|
|
|
|
|
session.setAttribute("bid", bid); |
|
|
|
|
|
// Return clean JSON |
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("user_name", userName); |
|
|
|
|
|
response.put("bid", bid); |
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
} else { |
|
|
|
|
|
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
System.out.println("Logged in user=" + userName + ", BID=" + bid); |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|
|
|
|
|
.body("Internal server error occurred"); |
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
} else { |
|
|
|
|
|
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|
|
|
|
|
.body("Internal server error occurred"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//ak |
|
|
|
|
|
|
|
|
// ak |
|
|
|
|
|
|
|
|
@GetMapping("/bookinghistorydetails") |
|
|
@GetMapping("/bookinghistorydetails") |
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
@ -374,7 +422,7 @@ public class BookingController { |
|
|
long mobileNo = Long.parseLong(mobileno); |
|
|
long mobileNo = Long.parseLong(mobileno); |
|
|
return bookingService.getBookingDetailsByMobileNo(mobileNo); |
|
|
return bookingService.getBookingDetailsByMobileNo(mobileNo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/bookingDetails") |
|
|
@GetMapping("/bookingDetails") |
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
public List<Map<String, Object>> getBookingDetailsByMobileNo(@RequestParam String mobileno) { |
|
|
public List<Map<String, Object>> getBookingDetailsByMobileNo(@RequestParam String mobileno) { |
|
|
@ -383,94 +431,106 @@ public class BookingController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("/getAvailabilityBySlot") |
|
|
@GetMapping("/getAvailabilityBySlot") |
|
|
public List<Map<String, Object>> getAvailabilityBySlot(@RequestParam int scid, @RequestParam String selectedDate) { |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getAvailabilityBySlot(@RequestParam int scid, @RequestParam String selectedDate) { |
|
|
|
|
|
|
|
|
return bookingService.getCalendarBasedOnSubCatId(scid, selectedDate); |
|
|
return bookingService.getCalendarBasedOnSubCatId(scid, selectedDate); |
|
|
// Replace with the actual view name |
|
|
// Replace with the actual view name |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* @GetMapping("/getbookingdetailDashBoard") |
|
|
|
|
|
public List<Map<String, Object>> getbookingdetailDashBoard(@RequestParam String fromDate, @RequestParam String toDate, @RequestParam String status) { |
|
|
|
|
|
return bookingService.getbookingdetailDashBoard(fromDate,toDate, status); |
|
|
|
|
|
}*/ |
|
|
|
|
|
//ak |
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* @GetMapping("/getbookingdetailDashBoard") |
|
|
|
|
|
* public List<Map<String, Object>> getbookingdetailDashBoard(@RequestParam |
|
|
|
|
|
* String fromDate, @RequestParam String toDate, @RequestParam String status) { |
|
|
|
|
|
* return bookingService.getbookingdetailDashBoard(fromDate,toDate, status); |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
// ak |
|
|
@GetMapping("/getbookingdetailDashBoard") |
|
|
@GetMapping("/getbookingdetailDashBoard") |
|
|
public List<Map<String, Object>> getbookingdetailDashBoard( |
|
|
|
|
|
@RequestParam String fromDate, |
|
|
|
|
|
@RequestParam String toDate, |
|
|
|
|
|
@RequestParam String status, |
|
|
|
|
|
@RequestParam int bid) { |
|
|
|
|
|
System.out.println("fromdate: " + fromDate); |
|
|
|
|
|
System.out.println("bid: " + bid); |
|
|
|
|
|
System.out.println("status: " + status); |
|
|
|
|
|
System.out.println("toDate: " + toDate); |
|
|
|
|
|
|
|
|
|
|
|
return bookingService.getbookingdetailDashBoard(fromDate, toDate, status, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getbookingdetailDashBoard( |
|
|
|
|
|
@RequestParam String fromDate, |
|
|
|
|
|
@RequestParam String toDate, |
|
|
|
|
|
@RequestParam String status, |
|
|
|
|
|
@RequestParam int bid) { |
|
|
|
|
|
System.out.println("fromdate: " + fromDate); |
|
|
|
|
|
System.out.println("bid: " + bid); |
|
|
|
|
|
System.out.println("status: " + status); |
|
|
|
|
|
System.out.println("toDate: " + toDate); |
|
|
|
|
|
|
|
|
|
|
|
return bookingService.getbookingdetailDashBoard(fromDate, toDate, status, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* @GetMapping("/amountCollected") |
|
|
|
|
|
* public List<Map<String, Object>> getAmountCollected(@RequestParam("fromDate") |
|
|
|
|
|
* String fromDate, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("toDate") String toDate) { |
|
|
|
|
|
* // Convert the string dates to LocalDate |
|
|
|
|
|
* LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|
|
|
|
|
* LocalDate parsedToDate = LocalDate.parse(toDate); |
|
|
|
|
|
* return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate); |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
@GetMapping("/amountCollected") |
|
|
|
|
|
public List<Map<String, Object>> getAmountCollected( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
/* @GetMapping("/amountCollected") |
|
|
|
|
|
public List<Map<String, Object>> getAmountCollected(@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate) { |
|
|
|
|
|
// Convert the string dates to LocalDate |
|
|
|
|
|
LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|
|
LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|
|
LocalDate parsedToDate = LocalDate.parse(toDate); |
|
|
LocalDate parsedToDate = LocalDate.parse(toDate); |
|
|
return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate); |
|
|
|
|
|
}*/ |
|
|
|
|
|
@GetMapping("/amountCollected") |
|
|
|
|
|
public List<Map<String, Object>> getAmountCollected( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
|
|
|
LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|
|
|
|
|
LocalDate parsedToDate = LocalDate.parse(toDate); |
|
|
|
|
|
|
|
|
|
|
|
return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*@GetMapping("/bookingCountByCategory") |
|
|
|
|
|
public List<Map<String, Object>> getBookingCountsByCategory(@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate,) { |
|
|
|
|
|
// Call the service method to get the booking counts for the specified date range |
|
|
|
|
|
return bookingService.getBookingCountsByCategory(fromDate, toDate); |
|
|
|
|
|
}*/ |
|
|
|
|
|
//ak |
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* @GetMapping("/bookingCountByCategory") |
|
|
|
|
|
* public List<Map<String, Object>> |
|
|
|
|
|
* getBookingCountsByCategory(@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
* |
|
|
|
|
|
* @RequestParam("toDate") String toDate,) { |
|
|
|
|
|
* // Call the service method to get the booking counts for the specified date |
|
|
|
|
|
* range |
|
|
|
|
|
* return bookingService.getBookingCountsByCategory(fromDate, toDate); |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
// ak |
|
|
@GetMapping("/bookingCountByCategory") |
|
|
@GetMapping("/bookingCountByCategory") |
|
|
public List<Map<String, Object>> getBookingCountsByCategory( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getBookingCountsByCategory( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
return bookingService.getBookingCountsByCategory(fromDate, toDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return bookingService.getBookingCountsByCategory(fromDate, toDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* @GetMapping("/totalBookingCounts") |
|
|
|
|
|
public List<Map<String, Object>> getBookingCounts(@RequestParam("fromDate") String fromDate,@RequestParam("toDate")String toDate) { |
|
|
|
|
|
// Call service method to get booking counts |
|
|
|
|
|
return bookingService.getBookingCountsByDate(fromDate,toDate); |
|
|
|
|
|
}*/ |
|
|
|
|
|
//ak |
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* @GetMapping("/totalBookingCounts") |
|
|
|
|
|
* public List<Map<String, Object>> getBookingCounts(@RequestParam("fromDate") |
|
|
|
|
|
* String fromDate,@RequestParam("toDate")String toDate) { |
|
|
|
|
|
* // Call service method to get booking counts |
|
|
|
|
|
* return bookingService.getBookingCountsByDate(fromDate,toDate); |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
// ak |
|
|
@GetMapping("/totalBookingCounts") |
|
|
@GetMapping("/totalBookingCounts") |
|
|
public List<Map<String, Object>> getBookingCounts( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getBookingCounts( |
|
|
|
|
|
@RequestParam("fromDate") String fromDate, |
|
|
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
|
|
@RequestParam("bid") int bid) { |
|
|
|
|
|
|
|
|
return bookingService.getBookingCountsByDate(fromDate, toDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return bookingService.getBookingCountsByDate(fromDate, toDate, bid); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/bookinghistory") |
|
|
@GetMapping("/bookinghistory") |
|
|
@ResponseBody |
|
|
|
|
|
public List<Map<String, Object>> getBookingHistory() { |
|
|
|
|
|
if (userSession != null && userSession.getMobileno() != 0) { |
|
|
|
|
|
return bookingService.getBookingByMobileNo(userSession.getMobileno()); |
|
|
|
|
|
} |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
public List<Map<String, Object>> getBookingHistory() { |
|
|
|
|
|
if (userSession != null && userSession.getMobileno() != 0) { |
|
|
|
|
|
return bookingService.getBookingByMobileNo(userSession.getMobileno()); |
|
|
|
|
|
} |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("/getComplaintsByMobile") |
|
|
@GetMapping("/getComplaintsByMobile") |
|
|
public ResponseEntity<?> getComplaintAndUserDetailsByMobile(@RequestParam("mobileNo") String mobileNo) { |
|
|
public ResponseEntity<?> getComplaintAndUserDetailsByMobile(@RequestParam("mobileNo") String mobileNo) { |
|
|
Map<String, Object> result = bookingService.getComplaintAndUserDetailsByMobile(mobileNo); |
|
|
Map<String, Object> result = bookingService.getComplaintAndUserDetailsByMobile(mobileNo); |
|
|
|