Skip to content

Instantly share code, notes, and snippets.

@redjen8
Created November 18, 2021 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redjen8/ba5871b1df3dd9e595382a3e8af8402f to your computer and use it in GitHub Desktop.
Save redjen8/ba5871b1df3dd9e595382a3e8af8402f to your computer and use it in GitHub Desktop.
yanolja room reservation request api
@PostMapping("/reserve/make")
@ApiOperation(value="방 예약", notes="방 예약 정보를 기록한다.")
public ResponseEntity<Map<String, Object>> makeReservation(@RequestBody HashMap<String, String> paramMap) {
Map<String, Object> resultMap = new HashMap<>();
if(paramMap.isEmpty() || !paramMap.containsKey("memberIdx") || !paramMap.containsKey("companyIdx") || !paramMap.containsKey("roomIdx")
|| !paramMap.containsKey("reserveType") || !paramMap.containsKey("reserveStart") || !paramMap.containsKey("reserveEnd")) {
resultMap.put("resultCode", -1);
resultMap.put("resultMsg", "유효하지 않은 매개변수입니다.");
return new ResponseEntity<>(resultMap, HttpStatus.OK);
}
int memberIdx = Integer.parseInt(paramMap.get("memberIdx"));
int couponIdx;
if(!paramMap.containsKey("couponIdx")) {
couponIdx = 0;
}
else {
couponIdx = Integer.parseInt(paramMap.get("couponIdx"));
}
int companyIdx = Integer.parseInt(paramMap.get("companyIdx"));
int roomIdx = Integer.parseInt(paramMap.get("roomIdx"));
boolean reserveType = paramMap.get("reserveType").equals("1");
String reserveStart = paramMap.get("reserveStart");
String reserveEnd = paramMap.get("reserveEnd");
int result;
if (couponIdx == 0) {
result = reservationService.makeReservation(memberIdx, companyIdx, roomIdx, reserveType, reserveStart, reserveEnd);
}
else {
result = reservationService.makeReservationWithCoupon(memberIdx, couponIdx, companyIdx,roomIdx,reserveType,reserveStart,reserveEnd);
}
if(result == 1) {
resultMap.put("resultCode", 0);
resultMap.put("resultMsg", "정상적으로 예약되었습니다.");
}
else {
resultMap.put("resultCode", -1);
resultMap.put("resultMsg", "정상적으로 예약되었습니다.");
}
return new ResponseEntity<>(resultMap, HttpStatus.OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment