From dc607c497850fafca5f9c72a0d28ea7c9f92d35a Mon Sep 17 00:00:00 2001 From: Jansen-Stanlie Date: Mon, 26 Jul 2021 21:12:47 +0700 Subject: [PATCH] Backend Hotel-Project --- .idea/.gitignore | 3 + .idea/compiler.xml | 18 ++ .idea/encodings.xml | 7 + .idea/jarRepositories.xml | 20 ++ .idea/misc.xml | 14 + .idea/uiDesigner.xml | 124 ++++++++ HotelThirdParty.iml | 2 + pom.xml | 171 ++++++++++ src/main/java/com/App.java | 17 + .../java/com/controller/HotelController.java | 68 ++++ src/main/java/com/model/Booking.java | 183 +++++++++++ src/main/java/com/model/Hotel.java | 146 +++++++++ src/main/java/com/repository/hotelrepo.java | 296 ++++++++++++++++++ .../java/com/service/CustomErrorType.java | 16 + .../java/com/service/MyBatisUtilHotel.java | 26 ++ .../com/service/MyBatisUtilPemesanan.java | 26 ++ src/main/resources/SqlMapConfig.xml | 19 ++ src/main/resources/SqlMapConfigPemesanan.xml | 19 ++ src/main/resources/application.properties | 18 ++ src/main/resources/mybatis/Hotel.xml | 60 ++++ src/main/resources/mybatis/Pemesanan.xml | 33 ++ src/test/java/com/AppTest.java | 20 ++ target/classes/SqlMapConfig.xml | 19 ++ target/classes/SqlMapConfigPemesanan.xml | 19 ++ target/classes/application.properties | 18 ++ target/classes/com/App.class | Bin 0 -> 923 bytes .../com/controller/HotelController.class | Bin 0 -> 4685 bytes target/classes/com/model/Booking.class | Bin 0 -> 4984 bytes target/classes/com/model/Hotel.class | Bin 0 -> 3948 bytes target/classes/com/repository/hotelrepo.class | Bin 0 -> 10841 bytes .../classes/com/service/CustomErrorType.class | Bin 0 -> 527 bytes .../com/service/MyBatisUtilHotel.class | Bin 0 -> 1169 bytes .../com/service/MyBatisUtilPemesanan.class | Bin 0 -> 1190 bytes target/classes/mybatis/Hotel.xml | 60 ++++ target/classes/mybatis/Pemesanan.xml | 33 ++ target/test-classes/com/AppTest.class | Bin 0 -> 453 bytes 36 files changed, 1455 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 HotelThirdParty.iml create mode 100644 pom.xml create mode 100644 src/main/java/com/App.java create mode 100644 src/main/java/com/controller/HotelController.java create mode 100644 src/main/java/com/model/Booking.java create mode 100644 src/main/java/com/model/Hotel.java create mode 100644 src/main/java/com/repository/hotelrepo.java create mode 100644 src/main/java/com/service/CustomErrorType.java create mode 100644 src/main/java/com/service/MyBatisUtilHotel.java create mode 100644 src/main/java/com/service/MyBatisUtilPemesanan.java create mode 100644 src/main/resources/SqlMapConfig.xml create mode 100644 src/main/resources/SqlMapConfigPemesanan.xml create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/mybatis/Hotel.xml create mode 100644 src/main/resources/mybatis/Pemesanan.xml create mode 100644 src/test/java/com/AppTest.java create mode 100644 target/classes/SqlMapConfig.xml create mode 100644 target/classes/SqlMapConfigPemesanan.xml create mode 100644 target/classes/application.properties create mode 100644 target/classes/com/App.class create mode 100644 target/classes/com/controller/HotelController.class create mode 100644 target/classes/com/model/Booking.class create mode 100644 target/classes/com/model/Hotel.class create mode 100644 target/classes/com/repository/hotelrepo.class create mode 100644 target/classes/com/service/CustomErrorType.class create mode 100644 target/classes/com/service/MyBatisUtilHotel.class create mode 100644 target/classes/com/service/MyBatisUtilPemesanan.class create mode 100644 target/classes/mybatis/Hotel.xml create mode 100644 target/classes/mybatis/Pemesanan.xml create mode 100644 target/test-classes/com/AppTest.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e97d23d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d24ea8e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HotelThirdParty.iml b/HotelThirdParty.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/HotelThirdParty.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f5a8a89 --- /dev/null +++ b/pom.xml @@ -0,0 +1,171 @@ + + + + 4.0.0 + + com + jar + HotelThirdParty + 1.0-SNAPSHOT + + HotelThirdParty + + http://www.example.com + + org.springframework.boot + spring-boot-starter-parent + 2.3.12.RELEASE + + + 11 + true + true + + + + + org.mybatis + mybatis + 3.3.0 + + + junit + junit + 4.11 + test + + + mysql + mysql-connector-java + 8.0.19 + + + org.json + json + 20190722 + + + org.apache.maven + maven-compat + 3.0 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + + + + + + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + + + + + + + + + + com.h2database + h2 + 1.4.200 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-jdbc + + + com.alibaba + druid + 1.1.8 + + + com.google.code.gson + gson + 2.8.7 + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + diff --git a/src/main/java/com/App.java b/src/main/java/com/App.java new file mode 100644 index 0000000..fb1eab6 --- /dev/null +++ b/src/main/java/com/App.java @@ -0,0 +1,17 @@ +package com; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication(scanBasePackages={"com"}) +public class App +{ private static final Logger log = LoggerFactory.getLogger(App.class); + public static void main( String[] args ) + { + SpringApplication.run(App.class); + } +} + diff --git a/src/main/java/com/controller/HotelController.java b/src/main/java/com/controller/HotelController.java new file mode 100644 index 0000000..3a6d5c0 --- /dev/null +++ b/src/main/java/com/controller/HotelController.java @@ -0,0 +1,68 @@ +package com.controller; + +import com.model.Booking; +import com.model.Hotel; +import com.repository.hotelrepo; +import com.service.CustomErrorType; +import org.json.simple.JSONObject; +import org.json.simple.parser.ParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("/hotel") +public class HotelController { + @Autowired + hotelrepo hotelrepo; + public static final Logger logger = LoggerFactory.getLogger(HotelController.class); + + + @RequestMapping(value = "/All", method = RequestMethod.GET, produces="application/json") + public ResponseEntity> listAllHotel() { + List hotels = hotelrepo.findAll(); + if (hotels.isEmpty()) { + logger.error("No data in database"); + return new ResponseEntity<>(hotels , HttpStatus.NOT_FOUND); + } + return new ResponseEntity<>(hotels, HttpStatus.OK); + } + + @RequestMapping(value = "/{location}", method = RequestMethod.GET, produces="application/json") + public ResponseEntity GetHotelbyLocation(@PathVariable("location") String location) { + logger.info("Fetching Hotel list by location in {}",location); + List hotels = hotelrepo.findByLocation(location); + + return new ResponseEntity<>(hotels,HttpStatus.OK); + } + @RequestMapping(value = "Ratings/{ratings}", method = RequestMethod.GET, produces="application/json") + public ResponseEntity GetHotelbyratings(@PathVariable("ratings") float rating) { + String ratings = Float.toString(rating) + " Star"; + logger.info("Fetching Hotel list by Ratings {}",ratings); + List hotels = hotelrepo.findByRatings(ratings); + + return new ResponseEntity<>(hotels,HttpStatus.OK); + } + + @RequestMapping(value = "/room", method = RequestMethod.GET, produces="application/json") + public ResponseEntity> GetHotelbyroom(@RequestParam("room") String room, @RequestParam("location") String location){ + logger.info("Fetching Hotel list by room {}",room); + List hotels = hotelrepo.findByRoom(room,location); + return new ResponseEntity<>(hotels,HttpStatus.OK); + } + + @RequestMapping(value = "/Booking", method = RequestMethod.POST) + public ResponseEntity insertStudent(@RequestBody JSONObject jobj) throws IOException, ParseException, java.text.ParseException { + JSONObject book = hotelrepo.bookDetail(jobj); + System.out.println(jobj.toString()); + return (new ResponseEntity<>(book, HttpStatus.CREATED)); + } + + +} diff --git a/src/main/java/com/model/Booking.java b/src/main/java/com/model/Booking.java new file mode 100644 index 0000000..3c10595 --- /dev/null +++ b/src/main/java/com/model/Booking.java @@ -0,0 +1,183 @@ +package com.model; + +import java.util.Date; + +public class Booking { + private int id; + private String name; + private String username; + private String hotel_name; + private String Booking_id; + private String Room_type; + private String location; + private long harga_kamar; + private int kamar_kosong; + private int Quantity; + private String payment_status = "Pending"; + private long Total_payment; + private Date booking_date; + private Date checkout_date; + private int kamarBaru; + private int Days; + private Date today; + public Booking(String fullname, String hotel_name) { + this.name = fullname; + this.hotel_name = hotel_name; + + } + + public Booking() { + + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHotel_name() { + return hotel_name; + } + + public void setHotel_name(String hotel_name) { + this.hotel_name = hotel_name; + } + + public String getBooking_id() { + return Booking_id; + } + + public void setBooking_id(String booking_id) { + Booking_id = booking_id; + } + + public String getRoom_type() { + return Room_type; + } + + public void setRoom_type(String room_type) { + Room_type = room_type; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public long getHarga_kamar() { + return harga_kamar; + } + + public void setHarga_kamar(long harga_kamar) { + this.harga_kamar = harga_kamar; + } + + public int getKamar_kosong() { + return kamar_kosong; + } + + public void setKamar_kosong(int kamar_kosong) { + this.kamar_kosong = kamar_kosong; + } + + public int getQuantity() { + return Quantity; + } + + public void setQuantity(int quantity) { + Quantity = quantity; + } + + public String getPayment_status() { + return payment_status; + } + + public void setPayment_status(String payment_status) { + this.payment_status = payment_status; + } + + + public long getTotal_payment() { + return Total_payment; + } + + public void setTotal_payment(long total_payment) { + Total_payment = total_payment; + } + + public Date getBooking_date() { + return booking_date; + } + + public void setBooking_date(Date booking_date) { + this.booking_date = booking_date; + } + + public int getKamarBaru() { + return kamarBaru; + } + + public void setKamarBaru(int kamarBaru) { + this.kamarBaru = kamarBaru; + } + + public int getDays() { + return Days; + } + + public void setDays(int days) { + Days = days; + } + + public Date getCheckout_date() { + return checkout_date; + } + + public void setCheckout_date(Date checkout_date) { + this.checkout_date = checkout_date; + } + + public Date getToday() { + return today; + } + + public void setToday(Date today) { + this.today = today; + } + + @Override + public String toString() { + return "Booking{" + + "name='" + name + '\'' + + ", username='" + username + '\'' + + ", hotel_name='" + hotel_name + '\'' + + ", Booking_id='" + Booking_id + '\'' + + ", Room_type='" + Room_type + '\'' + + ", location='" + location + '\'' + + ", harga_kamar=" + harga_kamar + + ", kamar_kosong=" + kamar_kosong + + ", Quantity=" + Quantity + + ", payment_status='" + payment_status + '\'' + + ", Total_payment=" + Total_payment + + ", booking_date=" + booking_date + + ", checkout_date=" + checkout_date + + ", kamarBaru=" + kamarBaru + + ", Days=" + Days + + ", today=" + today + + '}'; + } +} diff --git a/src/main/java/com/model/Hotel.java b/src/main/java/com/model/Hotel.java new file mode 100644 index 0000000..14b10f7 --- /dev/null +++ b/src/main/java/com/model/Hotel.java @@ -0,0 +1,146 @@ +package com.model; + +import java.util.Date; + +public class Hotel { + private String hotel_id; + private String hotel_name; + private int suite_room; + private int deluxe_room; + private int standard_room; + private int suite_price; + private int deluxe_price; + private int standard_price; + private Date price_update; + private Date room_update; + private String location; + private String status; + private String rating; + + + + public String getHotel_id() { + return hotel_id; + } + + public void setHotel_id(String hotel_id) { + this.hotel_id = hotel_id; + } + + public String getHotel_name() { + return hotel_name; + } + + public void setHotel_name(String hotel_name) { + this.hotel_name = hotel_name; + } + + public int getSuite_room() { + return suite_room; + } + + public void setSuite_room(int suite_room) { + this.suite_room = suite_room; + } + + public int getDeluxe_room() { + return deluxe_room; + } + + public void setDeluxe_room(int deluxe_room) { + this.deluxe_room = deluxe_room; + } + + public int getStandard_room() { + return standard_room; + } + + public void setStandard_room(int standard_room) { + this.standard_room = standard_room; + } + + public int getSuite_price() { + return suite_price; + } + + public void setSuite_price(int suite_price) { + this.suite_price = suite_price; + } + + public int getDeluxe_price() { + return deluxe_price; + } + + public void setDeluxe_price(int deluxe_price) { + this.deluxe_price = deluxe_price; + } + + public int getStandard_price() { + return standard_price; + } + + public void setStandard_price(int standard_price) { + this.standard_price = standard_price; + } + + public Date getPrice_update() { + return price_update; + } + + public void setPrice_update(Date price_update) { + ; + this.price_update = price_update; + } + + public Date getRoom_update() { + return room_update; + } + + public void setRoom_update(Date room_update) { + this.room_update = room_update; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getRating() { + return rating; + } + + public void setRating(String rating) { + this.rating = rating; + } + + @Override + public String toString() { + return "Hotel{" + + "hotel_id='" + hotel_id + '\'' + + ", hotel_name='" + hotel_name + '\'' + + ", suite_room=" + suite_room + + ", deluxe_room=" + deluxe_room + + ", standard_room=" + standard_room + + ", suite_price=" + suite_price + + ", deluxe_price=" + deluxe_price + + ", standard_price=" + standard_price + + ", price_update=" + price_update + + ", room_update=" + room_update + + ", location='" + location + '\'' + + ", status='" + status + '\'' + + ", rating='" + rating + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/repository/hotelrepo.java b/src/main/java/com/repository/hotelrepo.java new file mode 100644 index 0000000..426236a --- /dev/null +++ b/src/main/java/com/repository/hotelrepo.java @@ -0,0 +1,296 @@ +package com.repository; + +import com.model.Booking; +import com.model.Hotel; +import com.service.MyBatisUtilHotel; +import com.service.MyBatisUtilPemesanan; +import org.apache.ibatis.session.SqlSession; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.springframework.stereotype.Repository; + + +import java.awt.print.Book; +import java.text.SimpleDateFormat; +import java.util.*; + +@Repository +public class hotelrepo{ + private String booking_status; + private String message; + private Date datepesan; + private Date datecheckout; + + public List findAll(){ + List hotel = new ArrayList<>(); + try { + SqlSession session = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + hotel= session.selectList("Hotel.selectAll"); + }catch (Exception e){ + e.printStackTrace(); + } + return hotel; + } + public List findByLocation(String location){ + List hotel = new ArrayList<>(); + try { + SqlSession session = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + hotel= session.selectList("Hotel.getByLocation",location); + session.commit(); + session.close(); + }catch (Exception e){ + e.printStackTrace(); + } + return hotel; + } + public List findByRatings(String ratings){ + List hotel = new ArrayList<>(); + try { + SqlSession session = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + hotel= session.selectList("Hotel.getByRatings",ratings); + session.commit(); + session.close(); + }catch (Exception e){ + e.printStackTrace(); + } + return hotel; + } + public List findByRoom(String room,String location){ + List hotel = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("room",room); + map.put("location",location); + try { + SqlSession session = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + hotel= session.selectList("Hotel.getByRoomType",map); + session.commit(); + session.close(); + }catch (Exception e){ + e.printStackTrace(); + } + return hotel; + } + public Booking bookingHotel(JSONObject jobj) throws ParseException, java.text.ParseException { + JSONParser parser = new JSONParser(); + Object obj = parser.parse(jobj.toString()); + JSONObject temp = (JSONObject) obj; + JSONObject temp1 = (JSONObject) obj; + Booking booking = new Booking(); + + for(Iterator iterator = temp1.keySet().iterator(); iterator.hasNext();) { + String key = (String) iterator.next(); + booking.setUsername(String.valueOf(temp.get("username"))); + if (temp1.get(key) instanceof JSONObject) { + JSONObject temp2 = (JSONObject) temp1.get(key); + booking = new Booking(String.valueOf(temp2.get("name")), String.valueOf(temp2.get("hotel name"))); + JSONObject temp3 = (JSONObject) temp2.get("Room"); + booking.setRoom_type(String.valueOf(temp3.get("Type"))); + booking.setQuantity(Integer.parseInt(String.valueOf(temp3.get("Quantity")))); + booking.setDays(Integer.parseInt(String.valueOf(temp3.get("Nights")))); + Date date1=new SimpleDateFormat("yyyy-MM-dd").parse(String.valueOf(temp3.get("CheckIn Date"))); + booking.setBooking_date(date1); + } + } + return booking; + } + public JSONObject bookDetail(JSONObject jobj) throws ParseException, java.text.ParseException { + JSONObject obj = new JSONObject(); + datepesan = new Date(); + + Calendar cal = Calendar.getInstance(); + Calendar cal1 = Calendar.getInstance(); + + SqlSession session = MyBatisUtilPemesanan.getSqlSessionFactory().openSession(); + SqlSession session3 = MyBatisUtilPemesanan.getSqlSessionFactory().openSession(); + SqlSession session2 = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + Booking bookdetail = bookingHotel(jobj); + String roomName = bookdetail.getRoom_type(); + String hotelName = bookdetail.getHotel_name(); + String booking_id = getAlphaNumericString(8); + String Username = bookdetail.getUsername(); + datecheckout = bookdetail.getBooking_date(); + + + Booking databasecheck = SelectData(roomName,hotelName); + Booking checkPaymentStat = checkBook(Username); + if (databasecheck.getKamar_kosong() == 0) { + booking_status = "Failed"; + message ="Room Full,please book another hotel or another available room"; + obj.put("Message",message); + obj.put("Booking Status",booking_status); + }else{ + if(checkPaymentStat == null){ + if(databasecheck.getKamar_kosong() < bookdetail.getQuantity()) { + booking_status = "Failed"; + message = "Room Requested more than Available room,please book another hotel or another available room"; + obj.put("Message", message); + obj.put("Booking Status", booking_status); + }else if(bookdetail.getQuantity() == 0){ + booking_status = "Failed"; + message = "Requested room cannot be empty"; + obj.put("Message", message); + obj.put("Booking Status", booking_status); + }else if(bookdetail.getDays() > 31){ + booking_status = "Failed"; + message = "Booking nights cannot more than 31 Days"; + obj.put("Message", message); + obj.put("Booking Status", booking_status); + }else{ + booking_status = "Success"; + message ="Please Complete your payment using your booking id"; + bookdetail.setBooking_id(booking_id); + bookdetail.setToday(datepesan); + Date pesan = new Date(); + pesan = bookdetail.getBooking_date(); + cal1.setTime(pesan); + cal1.add(Calendar.HOUR_OF_DAY,14); + bookdetail.setBooking_date(cal1.getTime()); + cal.setTime(datecheckout); + cal.add(Calendar.DAY_OF_MONTH,bookdetail.getDays()); + cal.add(Calendar.HOUR_OF_DAY,12); + datecheckout = cal.getTime(); + bookdetail.setCheckout_date(datecheckout); + bookdetail.setKamarBaru(jumlahKamarNew(bookdetail.getQuantity(),databasecheck.getKamar_kosong())); + bookdetail.setTotal_payment(databasecheck.getHarga_kamar()*bookdetail.getQuantity()* bookdetail.getDays()); + obj.put("Booking Status", booking_status); + JSONObject obj2 = new JSONObject(); + obj2.put("name",bookdetail.getName()); + obj2.put("Hotel Name",bookdetail.getHotel_name()); + JSONObject obj3 = new JSONObject(); + obj3.put("Room type",bookdetail.getRoom_type()); + obj3.put("Quantity",bookdetail.getQuantity()); + obj2.put("Booking id",bookdetail.getBooking_id()); + obj2.put("Checkin Date",bookdetail.getBooking_date().toString()); + obj2.put("Booking Date",bookdetail.getToday().toString()); + obj2.put("Checkout Date",bookdetail.getCheckout_date().toString()); + obj2.put("Room Price",databasecheck.getHarga_kamar()); + obj2.put("Total Payment",bookdetail.getTotal_payment()); + obj2.put("number of nights",bookdetail.getDays()); + obj2.put("Room", obj3); + obj.put("Booking Details", obj2); + obj.put("Message",message); + session.insert("Pemesanan.insert", bookdetail); + session2.update("Hotel.insertUpdateRoom",bookdetail); + session2.commit(); + session2.close(); + session.commit(); + session.close(); + } + }else if(checkPaymentStat.getPayment_status().equalsIgnoreCase("pending") && checkPaymentStat != null){ + booking_status = "failed"; + message = "Can not make a new Booking," + +"Payment Still "+checkPaymentStat.getPayment_status()+" Please Complete Payment for " + bookdetail.getUsername() + + " with booking id "+ checkPaymentStat.getBooking_id(); + obj.put("Message",message); + obj.put("Booking Status", booking_status); + + }else{ + if(databasecheck.getKamar_kosong() < bookdetail.getQuantity()){ + booking_status = "Failed"; + message ="Room Requested more than Available room,please book another hotel or another available room"; + obj.put("Message",message); + obj.put("Booking Status",booking_status); + }else if(bookdetail.getQuantity() == 0){ + booking_status = "Failed"; + message = "Requested room cannot be empty"; + obj.put("Message", message); + obj.put("Booking Status", booking_status); + }else if(bookdetail.getDays() > 31){ + booking_status = "Failed"; + message = "Booking nights cannot more than 31 Days"; + obj.put("Message", message); + obj.put("Booking Status", booking_status); + }else{ + booking_status = "Success"; + message ="Please Complete your payment using your booking id"; + bookdetail.setBooking_id(booking_id); + bookdetail.setToday(datepesan); + Date pesan = new Date(); + pesan = bookdetail.getBooking_date(); + cal1.setTime(pesan); + cal1.add(Calendar.HOUR_OF_DAY,14); + bookdetail.setBooking_date(cal1.getTime()); + cal.setTime(datecheckout); + cal.add(Calendar.DAY_OF_MONTH,bookdetail.getDays()); + cal.add(Calendar.HOUR_OF_DAY,12); + datecheckout = cal.getTime(); + bookdetail.setCheckout_date(datecheckout); + session.delete("Pemesanan.delete", bookdetail); + session.commit(); + session.close(); + bookdetail.setKamarBaru(jumlahKamarNew(bookdetail.getQuantity(),databasecheck.getKamar_kosong())); + bookdetail.setTotal_payment(databasecheck.getHarga_kamar()*bookdetail.getQuantity()* bookdetail.getDays()); + obj.put("Booking Status", booking_status); + JSONObject obj2 = new JSONObject(); + obj2.put("name",bookdetail.getName()); + obj2.put("Hotel Name",bookdetail.getHotel_name()); + JSONObject obj3 = new JSONObject(); + obj3.put("Room type",bookdetail.getRoom_type()); + obj3.put("Quantity",bookdetail.getQuantity()); + obj2.put("Booking id",bookdetail.getBooking_id()); + obj2.put("Checkin Date",bookdetail.getBooking_date().toString()); + obj2.put("Booking Date",bookdetail.getToday().toString()); + obj2.put("Checkout Date",bookdetail.getCheckout_date().toString()); + obj2.put("Room Price",databasecheck.getHarga_kamar()); + obj2.put("Total Payment",bookdetail.getTotal_payment()); + obj2.put("number of nights",bookdetail.getDays()); + obj2.put("Room", obj3); + obj.put("Booking Details", obj2); + obj.put("Message",message); + + session2.update("Hotel.insertUpdateRoom",bookdetail); + session3.insert("Pemesanan.replace",bookdetail); + session3.commit(); + session3.close(); + session2.commit(); + session2.close(); + + } + } + + } + + return obj; + } + public String getAlphaNumericString(int n) { + // chose a Character random from this String + String AlphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "0123456789" + + "abcdefghijklmnopqrstuvxyz"; + // create StringBuffer size of AlphaNumericString + StringBuilder sb = new StringBuilder(n); + for (int i = 0; i < n; i++) { + // generate a random number between + // 0 to AlphaNumericString variable length + int index + = (int)(AlphaNumericString.length() + * Math.random()); + + // add Character one by one in end of sb + sb.append(AlphaNumericString + .charAt(index)); + } + return sb.toString(); + } + public Booking SelectData(String tipe_kamar,String hotel){ + Booking checkbook = new Booking(); + Map map = new HashMap<>(); + map.put("room",tipe_kamar); + map.put("hotel",hotel); + SqlSession session = MyBatisUtilHotel.getSqlSessionFactory().openSession(); + checkbook = session.selectOne("Hotel.datakamar",map); + session.commit(); + session.close(); + return checkbook; + } + public Booking checkBook(String username){ + Booking checkBook = new Booking(); + SqlSession session = MyBatisUtilPemesanan.getSqlSessionFactory().openSession(); + checkBook = session.selectOne("Pemesanan.check",username); + return checkBook; + } + public int jumlahKamarNew(int kamar_pesanan, int kamar_database){ + return kamar_database - kamar_pesanan; + } +} diff --git a/src/main/java/com/service/CustomErrorType.java b/src/main/java/com/service/CustomErrorType.java new file mode 100644 index 0000000..f54b61c --- /dev/null +++ b/src/main/java/com/service/CustomErrorType.java @@ -0,0 +1,16 @@ +package com.service; + + +public class CustomErrorType { + + private String errorMessage; + + public CustomErrorType(String errorMessage){ + this.errorMessage = errorMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + +} diff --git a/src/main/java/com/service/MyBatisUtilHotel.java b/src/main/java/com/service/MyBatisUtilHotel.java new file mode 100644 index 0000000..91186e4 --- /dev/null +++ b/src/main/java/com/service/MyBatisUtilHotel.java @@ -0,0 +1,26 @@ +package com.service; + +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; + +import java.io.IOException; +import java.io.Reader; + +public class MyBatisUtilHotel { + + private static SqlSessionFactory factory; + + static{ + Reader reader; + try{ + reader=Resources.getResourceAsReader("SqlMapConfig.xml"); + }catch(IOException exception){ + throw new RuntimeException(exception.getMessage()); + } + factory=new SqlSessionFactoryBuilder().build(reader); + } + public static SqlSessionFactory getSqlSessionFactory(){ + return factory; + } +} diff --git a/src/main/java/com/service/MyBatisUtilPemesanan.java b/src/main/java/com/service/MyBatisUtilPemesanan.java new file mode 100644 index 0000000..43b51a2 --- /dev/null +++ b/src/main/java/com/service/MyBatisUtilPemesanan.java @@ -0,0 +1,26 @@ +package com.service; + +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; + +import java.io.IOException; +import java.io.Reader; + +public class MyBatisUtilPemesanan { + + private static SqlSessionFactory factory; + + static{ + Reader reader; + try{ + reader=Resources.getResourceAsReader("SqlMapConfigPemesanan.xml"); + }catch(IOException exception){ + throw new RuntimeException(exception.getMessage()); + } + factory=new SqlSessionFactoryBuilder().build(reader); + } + public static SqlSessionFactory getSqlSessionFactory(){ + return factory; + } +} diff --git a/src/main/resources/SqlMapConfig.xml b/src/main/resources/SqlMapConfig.xml new file mode 100644 index 0000000..970d6b8 --- /dev/null +++ b/src/main/resources/SqlMapConfig.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/SqlMapConfigPemesanan.xml b/src/main/resources/SqlMapConfigPemesanan.xml new file mode 100644 index 0000000..8757736 --- /dev/null +++ b/src/main/resources/SqlMapConfigPemesanan.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..4ce4f8a --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,18 @@ +logging.level.org.springframework=info +#logging.level.org.springframework.jdbc=DEBUG +logging.level.com=INFO +logging.level.com.zaxxer=DEBUG +logging.level.root=ERROR +spring.datasource.hikari.connectionTimeout=20000 +spring.datasource.hikari.maximumPoolSize=5 +logging.pattern.console=%-5level %logger{36} - %msg%n + +# MySQL +spring.datasource.url=jdbc:mysql://localhost:3306/tugas29?serverTimezone=Asia/Shanghai +spring.datasource.username=root +spring.datasource.password=Jansen24 + +# Oracle +#spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl +#spring.datasource.username=system +#spring.datasource.password=Password123 \ No newline at end of file diff --git a/src/main/resources/mybatis/Hotel.xml b/src/main/resources/mybatis/Hotel.xml new file mode 100644 index 0000000..8e022a0 --- /dev/null +++ b/src/main/resources/mybatis/Hotel.xml @@ -0,0 +1,60 @@ + + + + + UPDATE room_availability INNER JOIN list_hotel ON list_hotel.hotel_id = room_availability.hotel_id + INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET ${Room_type}_room = #{kamarBaru},room_date = #{today} + WHERE list_hotel.nama_hotel = #{hotel_name}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/Pemesanan.xml b/src/main/resources/mybatis/Pemesanan.xml new file mode 100644 index 0000000..de9948f --- /dev/null +++ b/src/main/resources/mybatis/Pemesanan.xml @@ -0,0 +1,33 @@ + + + + + INSERT INTO pemesanan (nama_pemesan,username,booking_id,hotel_name,room_type,quantity,jumlah_malam,total_payment,status,tanggal_pemesanan,tanggal_checkin,tanggal_checkout) + VALUES (#{name},#{username},#{Booking_id},#{hotel_name},#{Room_type},#{Quantity},#{Days},#{Total_payment},#{payment_status},#{today},#{booking_date},#{checkout_date}); + + select last_insert_id() as id + + + + DELETE FROM pemesanan WHERE username = #{username}; + + + INSERT INTO pemesanan (nama_pemesan,username,booking_id,hotel_name,room_type,quantity,jumlah_malam,total_payment,status,tanggal_pemesanan,tanggal_checkin,tanggal_checkout) + VALUES (#{name},#{username},#{Booking_id},#{hotel_name},#{Room_type},#{Quantity},#{Days},#{Total_payment},#{payment_status},#{today},#{booking_date},#{checkout_date}); + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/com/AppTest.java b/src/test/java/com/AppTest.java new file mode 100644 index 0000000..23a8a11 --- /dev/null +++ b/src/test/java/com/AppTest.java @@ -0,0 +1,20 @@ +package com; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/target/classes/SqlMapConfig.xml b/target/classes/SqlMapConfig.xml new file mode 100644 index 0000000..970d6b8 --- /dev/null +++ b/target/classes/SqlMapConfig.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/SqlMapConfigPemesanan.xml b/target/classes/SqlMapConfigPemesanan.xml new file mode 100644 index 0000000..8757736 --- /dev/null +++ b/target/classes/SqlMapConfigPemesanan.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000..4ce4f8a --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,18 @@ +logging.level.org.springframework=info +#logging.level.org.springframework.jdbc=DEBUG +logging.level.com=INFO +logging.level.com.zaxxer=DEBUG +logging.level.root=ERROR +spring.datasource.hikari.connectionTimeout=20000 +spring.datasource.hikari.maximumPoolSize=5 +logging.pattern.console=%-5level %logger{36} - %msg%n + +# MySQL +spring.datasource.url=jdbc:mysql://localhost:3306/tugas29?serverTimezone=Asia/Shanghai +spring.datasource.username=root +spring.datasource.password=Jansen24 + +# Oracle +#spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl +#spring.datasource.username=system +#spring.datasource.password=Password123 \ No newline at end of file diff --git a/target/classes/com/App.class b/target/classes/com/App.class new file mode 100644 index 0000000000000000000000000000000000000000..827055baed92ac5703405bc30240ecc562f966f8 GIT binary patch literal 923 zcmZuvT~8B16g|@qw%u01q9FK*ineIn7hVj61W0(QO2ps;Pt#>srfheb*;zk+mhnMi zqCdbNWjwoWq+%a-@67!;_nbTT*YEE?0c_y84-a=e-1BhX#{;bTc!)=Jl)4Q0?oSPmS$fR3$Vw`l^BrM+^ zX&&bNPjl3d#-0Z~V_YCJXF`*l>L{}+I4n|j86a@1!vcVM=F?CnyE0V=GCY@&B4(Lt zoAA*P@W#TKcU7&2Crvy>+e4>`bv$dLhWbBwZ+d+dI)U}#S*B4Ok(waH<~HMad+mwo z?!_`qH>V7=GgUk_JN3y0dt>eSdrq{VI}cO(($#g@m!UKEGao!sZnQxHYyVRj_nllc zta2GWE~~&wJ_w%5JadTrH+c(a1#NZx8^jkLO1Q@VOyTq~%X4#-fH}
yU;n3Wg5 zq|J*Pty1|1$``1-zl87^1Oa>&Ucxl6fE)DR4nf`hGtXlcH(P=^xO)si&vky)(NEu;jpL_M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UObJV*@P)Lx1{5V4O%r@8iF ze1s}|lzURGXyqhlr?`@a_8)ZX{D3^ow-g2x{v3A)sqmTSp@n!HLmX`k;|ZKqD^GI& zDU47HX^)%Ks)1upA~1+&R|6!vzE$j=l=}DIMOA<9@Z@fFz8fvHX&YCh-nocJthan0 z#W~7pqt+5Zs)it1Imwmtq-)Z65V87Wb<`iPqy7a_7}ARu`9BkqgNCPZDF*Zg0X6c( zzmW%6c{s|oPuE~skU^@; zAk8a2g<1jX;+p(rT08Ee^KCTABBZIzii*%d@+)#JMWnKxwQ{z=age7XIg9@TFx%hc literal 0 HcmV?d00001 diff --git a/target/classes/com/model/Booking.class b/target/classes/com/model/Booking.class new file mode 100644 index 0000000000000000000000000000000000000000..e04f2cc5bc140bb76d206fe1813a1e779a32ce2b GIT binary patch literal 4984 zcmaKu`*#yX6vywTX|qj}Hcfd7NC2g!1fs}Gpha5bQ3{k-5me%~32kVaE$IfRh@hyT zsGz8zsGy?wfOGU5Th7sQ`~&=V_}%08&Lo@7biyz9&fL8_^O>3N+}(fw`|BSfT1^jv z6sI>#I#*B2=}k80*<4`r7Mr)(Tx9bOn|Il~$L127%WU3f^8uSHY(8Z3QGh-UQVS1# zmHjm~pP2NiN!LyK%%smv`og3e9KLDNm+ZeX>6S@foAixI-*Vu#Nq0>8&ZO^6`hf#? z1N38nelp0HNf~79G{~Q`M$-mGdrw%WtVGtz4J8gZ`AlwTqd{h2Je`-%gTuCy&L)eU zF54bKN|Fbu-*4NaNoQgVqnKHH&~h?%&Y*^2D?elyL!gTe=G$I2#)VZ1s}oG@iMm?k1&3r;4R*op{H!-K== z!4bRQBxOpyn5@gn7qG;w)&vHvb?lUd+3GfBav7)7pw_nOi=G}?){hao?G)y1>doZR zdkUii>HI-!AS<>F3(odi`3(1qLBBJc!F(;fgZ5}*6mMn|#SP;Gn>16i79J{qq4tOq4j^B)!ieqg9A_9$ zD*AZtJz;+C?FUPz!N(s$vPS_SAhFzQWF)U(un~|As=FHLVji3-?p=~qh-DE)|GqaNmq!?7`IQ+Vl$G}SOj^BL?cL3LSd&; z#Y|n=N2$_i>1e%D=0#MdwG(d0m)Z z37N<`C~u63r=_N2%kp4Q@PJ*&52m+e_#%Xg#4EXsgs6*lL3@4aTnc3(L>uUt5GB~G zV)HDU=h&=fvxd!DS{I`Av@%4`v)RbqP1F&h&D?!~O(%D^P=`UY)ne6E$YfJ#6q?2& z$63B&9jzg{M?bUq1&Hxjsh)MTA~PN<*R*1wwC$M`2g31~D`oCufKq)c4N%r5(C*Q% zkYGGE;!&mu|AyNdkChY${%AZ_S@L+iNIX^{Amm}N0Z-)t?r{Z-MBP|DpBCXe8pl_<}CMG6m53J+Zh z4`~VybqWtj3lE_R53LFhkqQsl3J>K958c8qAp>`#8ys8F8-%ZcpV|J9jP|H+l4{zQ zPm;eqK1sEIh}T|(okg{ zy$@l+OOUXX>%2(elJtM*r&r4;!D zs%5HInR>KLFYB4=Ri-^)+FON*E0KG4YXs9P^eRGpbrQG|rF$2AfPnYj?bk9Lqa?EA zy{i$IysmxWBn4HbelQ)b!o*e4Wm+qkUL(t8D%XOB`wG)hEz^Lgg_X5n-Xt}sOvk{K ztir?<+GScVm{MA%kjgZmWlHOrLMqd7Fb!2 zU4@CiT<$(?5KI}Zp2Di0#K z_k3F#Ri^V`x=@9Qzv%8hZ4yjlT0J$Xdb+4(I;q!Flge}nOqZ)L@n40@v{^9awM-F} z>57(VT+b9ynXZEAS`{Y8%j5{Ag7)m1)w8>TwR*)tZP5OW=W^f$E}c}O#&GpA@4{-ykI zk=7}i9i1Zsb#7p;4Ai=TCuAVt2Ik3t=?3P@K)oASAOpcEdNR6Dwi~7>7F{IUA#N|0 z?HV{qvP1^L{L)jh-8e;0N0-WWGq-`v_)R=On`}q8y-c>F$cdc8vZknAJ%PKP6L{qQ MExwM;@zL4;0RihX!vFvP literal 0 HcmV?d00001 diff --git a/target/classes/com/model/Hotel.class b/target/classes/com/model/Hotel.class new file mode 100644 index 0000000000000000000000000000000000000000..0c6754786e478d6f29ae7c73caa5d65603875d75 GIT binary patch literal 3948 zcmaKu>sK2^6u|F>JT}SZLHa-iEw$JL2*eh&D$r`dw%D{FRBE*qmSiQ1n}^G$qAk|? z{$u>0=U94R6e3O933HVk4wb6DAYtyVNP^j+e_w|aUw{|M)j%~Jf z<`hWr`Ig=^aIn`k9b?mOx0?zm%L=6HhSlBoJefU5Z`F0X?nb0}c*iztxL9*z-C@=b z_U4)1>~`w9gW-8j({)U%vVfx5)`o7IGE!)%tZxv!rpyBrQLQ#Y7;Cm83U{RDu`2-cz zLJ^CnJj%P2dTW8Aeq>Q@vobI4iBZ9-SYR=HA-gzqxvI zbrXtBKT=ve+ULRP<^P-RJB_oY#xi0WD+%=oC{&avFW{(xT0tF~cnZpIEbI-GaqfgS(bio1 zEttcR0`stdvVZaK5cySDJS1Iw5ia2`q{SCeM^MKnCZ9m0cXWz*harZfbo@yk1^jqI zqdY0_HqONq91znxQl6Db|vYcr^WIBUPVd({g6NrjTlgLyKVWRr+nM#c5s+1`vGF7BZ*W^qwk!c2*WB4tX7Oe<2RRXI~qWLih2TOmyJ_W4ZHjOl$? zLznnIrNp=3wv=fdPZIkM-=~zwbQhWKg)q@O>@!su(+5(fw8*q2W!jK4rA4MXG8rLE z^iA-Y&M~Ij(l=8RnHo~259M#BCNf#b)C^&w?~~7To-y5#GG#=jj+E&mIa5Yta*(MT z!bIOnpJ|3MeJo|licI@brn_>ctjP2bnGQmj=)3JR%`ztZ8-y;Z@qe&f=>z`kPsrVQ z3i-m|ArvO?dyFbyJcMI~XeJ5F#%^bk%KhPWLg`#EmM$$p;O39?_{wo3Lex07U# za65GfFBV?ncAD%{+}2QWf>G|s_>R-uk@Xz;0|Y&Um&Keu4&?Ni`wu{YPw?kPVDmpp C!h1dd literal 0 HcmV?d00001 diff --git a/target/classes/com/repository/hotelrepo.class b/target/classes/com/repository/hotelrepo.class new file mode 100644 index 0000000000000000000000000000000000000000..fd9e078ae8caccb5750bb517959b3706cf210ae6 G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tqTj!WkrX+cbzm}R)wCDdHA;h{o^bh#@dE>L6y%qSmKI*olmm6@l` a3#=z}4?QFUL literal 0 HcmV?d00001 diff --git a/target/classes/com/service/MyBatisUtilHotel.class b/target/classes/com/service/MyBatisUtilHotel.class new file mode 100644 index 0000000000000000000000000000000000000000..ee7e8eb073190c228fc7c16f5851981bd461f11f GIT binary patch literal 1169 zcmb7DT~8B16g^Yg-F96*io5o{ zZ7I)Mj}h|axU=-b^l_5B-dCxPk#9 zQSwlH0;E47^^q|L#x=& zfRRMM`5}JHO}Qtn9c9`T8QOsvs35RC*DQZ<%E@&( zF`pO6F4(ReJ`-pw6gLFYOWu|e=qTB)dR?zol>b&%93ovM&yvoD^zBG)fa!3@4g|(Z zmRDmIf8Vy0xq7%5WqlXg&Kp%zfpn$IL_Jj%o+BV&7K)c-oLjJ*2Is7=jBWRyPE YoM6Mm4Ww2yWPZcYaEsazVkwON1uaD=h5!Hn literal 0 HcmV?d00001 diff --git a/target/classes/mybatis/Hotel.xml b/target/classes/mybatis/Hotel.xml new file mode 100644 index 0000000..8e022a0 --- /dev/null +++ b/target/classes/mybatis/Hotel.xml @@ -0,0 +1,60 @@ + + + + + UPDATE room_availability INNER JOIN list_hotel ON list_hotel.hotel_id = room_availability.hotel_id + INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET ${Room_type}_room = #{kamarBaru},room_date = #{today} + WHERE list_hotel.nama_hotel = #{hotel_name}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/mybatis/Pemesanan.xml b/target/classes/mybatis/Pemesanan.xml new file mode 100644 index 0000000..de9948f --- /dev/null +++ b/target/classes/mybatis/Pemesanan.xml @@ -0,0 +1,33 @@ + + + + + INSERT INTO pemesanan (nama_pemesan,username,booking_id,hotel_name,room_type,quantity,jumlah_malam,total_payment,status,tanggal_pemesanan,tanggal_checkin,tanggal_checkout) + VALUES (#{name},#{username},#{Booking_id},#{hotel_name},#{Room_type},#{Quantity},#{Days},#{Total_payment},#{payment_status},#{today},#{booking_date},#{checkout_date}); + + select last_insert_id() as id + + + + DELETE FROM pemesanan WHERE username = #{username}; + + + INSERT INTO pemesanan (nama_pemesan,username,booking_id,hotel_name,room_type,quantity,jumlah_malam,total_payment,status,tanggal_pemesanan,tanggal_checkin,tanggal_checkout) + VALUES (#{name},#{username},#{Booking_id},#{hotel_name},#{Room_type},#{Quantity},#{Days},#{Total_payment},#{payment_status},#{today},#{booking_date},#{checkout_date}); + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/test-classes/com/AppTest.class b/target/test-classes/com/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..b5260f32919af3f99d70658943a22ef512cc5d0c GIT binary patch literal 453 zcmZvZzfQw25XL{JX#;6WOI!YQWNR7702>G?LSl+Qf+|RCZfdozQoD*BcrGRo0}sGM zAueg9GT`Ct?>^t}PWJcD=NEtr41BoQ_t8bqL*K&zL*q&+X|EY-!%@QE-sq`dXvb2C zyJ9&J`It{K%5-C$@+{%GEcGVo+PO3gtvJ=oFj}p~!q`iOzM1PHn?}mKiu_61`8Y2K zF?cAHl}nLGBZ(0yr7gEoD?)T)ozKEWL9>J#ivOsKJQcUHY#(gsXAAzq1Ju#*a2VhS z#|+Is-HBA*2s5r`;r(PGQcI~VJ2FP(l=69XSP$k7pGOH!P@~r=mjhOIpy-hbX=k+8 zPv61bDtm`wX#+lXDF*8cq?)8?T5_GL_?%Q#?0&%67W-s_zQINBA3%$|62Di$+7umh FegWhJSV;f? literal 0 HcmV?d00001