diff --git a/src/main/java/reserve/controller/BookingController.java b/src/main/java/reserve/controller/BookingController.java new file mode 100644 index 0000000..10621dd --- /dev/null +++ b/src/main/java/reserve/controller/BookingController.java @@ -0,0 +1,185 @@ +package reserve.controller; + + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import reserve.model.Booking; +import reserve.model.Product; +import reserve.model.User; +import reserve.repository.BookingRepository; +import reserve.repository.ProductRepository; +import reserve.repository.UserRepository; + +@CrossOrigin(origins = "*") +@RestController +public class BookingController { + @Autowired + BookingRepository bookingRepository; + + @Autowired + UserRepository userRepository; + + @Autowired + ProductRepository productRepository; + + @PostMapping("/book") + public ResponseEntity createBooking(@RequestBody Booking body) { + try { + User user = userRepository.findById(body.getUser().getUserID()).orElse(null); + Product product = productRepository.findById(body.getProduct().getProductid()).orElse(null); + + if (user != null && product != null) { + body.setUser(user); + body.setProduct(product); + + int total = body.getQuantity() * product.getPrice(); + body.setTotal(total); + + Booking newBooking = bookingRepository.save(body); + + return new ResponseEntity<>(newBooking, HttpStatus.CREATED); + } else { + return new ResponseEntity<>("User or Product not found.", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + @GetMapping("/book") + public ResponseEntity getBooking() { + try { + + List booking = bookingRepository.findAll(); + return new ResponseEntity<>(booking, HttpStatus.OK); + + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Integer server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @GetMapping("/book/stale/{userID}") + public ResponseEntity getBookingStale(@PathVariable Long userID) { + try { + List bookings = bookingRepository.findByUserUserIDAndStatus(userID, "1"); + return new ResponseEntity<>(bookings, HttpStatus.OK); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + @GetMapping("/book/paid/{userID}") + public ResponseEntity getBooking(@PathVariable Long userID) { + try { + List bookings = bookingRepository.findByUserUserIDAndStatus(userID, "0"); + return new ResponseEntity<>(bookings, HttpStatus.OK); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + @GetMapping("/book/{reviewID}") + public ResponseEntity getBooking(@PathVariable List reviewID) { + try { + List bookings = bookingRepository.findByReviewIDIn(reviewID); + return new ResponseEntity<>(bookings, HttpStatus.OK); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping("/book/{userID}") + public ResponseEntity updateBookingStatus( + @PathVariable Long userID, + @RequestBody List request) { + try { + List bookings = bookingRepository.findByUserUserID(userID); + + for (Booking update : request) { + for (Booking booking : bookings) { + if (booking.getReviewID().equals(update.getReviewID())) { + Timestamp currentTimestamp = new Timestamp(System.currentTimeMillis()); + booking.setDate_book(currentTimestamp); + booking.setStatus("0"); + } + } + } + + bookingRepository.saveAll(bookings); + + return new ResponseEntity<>("Status updated to '0' successfully", HttpStatus.OK); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping("/book/day/{reviewID}") + public ResponseEntity updateBookingDate( + @PathVariable Long reviewID, + @RequestBody Booking request) { + try { + Optional bookingOptional = bookingRepository.findById(reviewID); + + if (bookingOptional.isPresent()) { + Booking booking = bookingOptional.get(); + + booking.setDate_reciept(request.getDate_reciept()); + + bookingRepository.save(booking); + + return new ResponseEntity<>("date_receipt updated successfully", HttpStatus.OK); + } else { + return new ResponseEntity<>("Booking not found", HttpStatus.NOT_FOUND); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + @DeleteMapping("/book/{reviewID}") + public ResponseEntity deleteBookById(@PathVariable("reviewID") Long reviewID) { + + try { + + Optional bookingFind = bookingRepository.findById(reviewID); + + if (bookingFind.isPresent()) { + + + bookingRepository.delete(bookingFind.get()); + + return new ResponseEntity<>("Delete Product Success.", HttpStatus.OK); + + } else { + return new ResponseEntity<>("Product Not Found.", HttpStatus.BAD_REQUEST); + } + + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + +} \ No newline at end of file diff --git a/src/main/java/reserve/controller/ProductController.java b/src/main/java/reserve/controller/ProductController.java index a6bf878..a10c780 100644 --- a/src/main/java/reserve/controller/ProductController.java +++ b/src/main/java/reserve/controller/ProductController.java @@ -3,35 +3,40 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Optional; -import java.util.UUID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; + import com.fasterxml.jackson.databind.ObjectMapper; import reserve.model.Product; import reserve.model.User; import reserve.repository.ProductRepository; - +@CrossOrigin(origins = "*") @RestController public class ProductController { @Autowired ProductRepository productRepository; - - + + @PostMapping(value = "/Productphoto", consumes = { "multipart/form-data" }) public ResponseEntity createPhoto(@RequestParam("body") String Productjson, @RequestParam("photo") MultipartFile photo) throws IOException { @@ -53,9 +58,8 @@ public ResponseEntity createPhoto(@RequestParam("body") String Productjs return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); } } - @GetMapping("/Product") - public ResponseEntity getBoardGames() { + public ResponseEntity getProduct() { try { List ProductList = productRepository.findAllProduct(); @@ -64,7 +68,8 @@ public ResponseEntity getBoardGames() { for (Product row : ProductList) { Long productid = row.getProductid(); String productname = row.getProductname(); - String price = row.getPrice(); + Integer price = row.getPrice(); + Integer piece = row.getPiece(); byte[] photoData = row.getPhotoData(); String detail = row.getDetail(); @@ -72,7 +77,7 @@ public ResponseEntity getBoardGames() { - Product newProduct = new Product(productid, productname, price, photoData, detail, user); + Product newProduct = new Product(productid, productname, price, piece, photoData, detail, user); Product.add(newProduct); } @@ -85,7 +90,7 @@ public ResponseEntity getBoardGames() { } @GetMapping("/Product/{productid}") - public ResponseEntity getBoardGameById(@PathVariable("productid") Long productid) { + public ResponseEntity getProductById(@PathVariable("productid") Long productid) { try { @@ -124,7 +129,7 @@ public ResponseEntity deleteProductById(@PathVariable("productid") Long return new ResponseEntity<>("Delete Product Success.", HttpStatus.OK); } else { - return new ResponseEntity<>("Board Product Found.", HttpStatus.BAD_REQUEST); + return new ResponseEntity<>("Product Not Found.", HttpStatus.BAD_REQUEST); } } catch (Exception e) { @@ -134,7 +139,7 @@ public ResponseEntity deleteProductById(@PathVariable("productid") Long } - @PutMapping(value = "/Product/{productid}", consumes = { "multipart/form-data" }) + @PutMapping(value = "/Product/all/{productid}", consumes = { "multipart/form-data" }) public ResponseEntity updateProduct(@PathVariable("productid") Long productid, @RequestParam("body") String Productjson, @RequestParam("photo") MultipartFile photo) throws IOException { @@ -170,9 +175,59 @@ public ResponseEntity updateProduct(@PathVariable("productid") Long prod } } - - - + @PutMapping(value = "/Product/Piece/{productid}", consumes = { "application/json" }) + public ResponseEntity updatePiece( + @PathVariable("productid") Long productid, + @RequestBody Map requestBody + ) { + try { + Optional productFind = productRepository.findById(productid); + + if (productFind.isPresent()) { + Product productUpdate = productFind.get(); + int change = requestBody.get("change"); + int newPiece = productUpdate.getPiece() - change; + + if (newPiece >= 0) { + productUpdate.setPiece(newPiece); + productRepository.save(productUpdate); + return new ResponseEntity<>(productUpdate, HttpStatus.OK); + } else { + return new ResponseEntity<>("Invalid quantity change.", HttpStatus.BAD_REQUEST); + } + } else { + return new ResponseEntity<>("Product Not Found.", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + @PutMapping("/Product/{productid}") + public ResponseEntity updateProduct(@PathVariable("productid") Long productid, @RequestBody Product body) { + try { + Optional ProductFound = productRepository.findById(productid); + + if (ProductFound.isPresent()) { + Product productToUpdate = ProductFound.get(); + + productToUpdate.setProductname(body.getProductname()); + productToUpdate.setPrice(body.getPrice()); + productToUpdate.setPiece(body.getPiece()); + productToUpdate.setDetail(body.getDetail()); + + + productRepository.save(productToUpdate); + + return new ResponseEntity<>(productToUpdate, HttpStatus.OK); + } else { + return new ResponseEntity<>("Product Not Found.", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + } } diff --git a/src/main/java/reserve/controller/StudentController.java b/src/main/java/reserve/controller/StudentController.java new file mode 100644 index 0000000..d27b29b --- /dev/null +++ b/src/main/java/reserve/controller/StudentController.java @@ -0,0 +1,95 @@ +package reserve.controller; + +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import reserve.model.Student; +import reserve.model.User; +import reserve.repository.StudentRepository; + +@RestController +@CrossOrigin(origins = "*") +public class StudentController { + @Autowired + StudentRepository studentRepository; + + @GetMapping("/students") + public ResponseEntity getUsers() { + + try { + List Student = studentRepository.findAll(); + return new ResponseEntity<>(Student , HttpStatus.OK); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + @PutMapping("/students/{id}") + public ResponseEntity upadatStudent(@PathVariable Long id ,@RequestBody Student body){ + try { + Optional student = studentRepository.findById(id); + + if (student.isPresent()) { + Student studentEdit = student.get(); + studentEdit.setName(body.getName()); + studentEdit.setEmail(body.getEmail()); + + studentRepository.save(studentEdit); + return new ResponseEntity<>(studentEdit,HttpStatus.OK); + + }else { + return new ResponseEntity<>("Stundet not found", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + + + } + + @PostMapping("/students") + public ResponseEntity createUser(@RequestBody Student body) { + + try { + + Student newStudent = studentRepository.save(body); + return new ResponseEntity<>(newStudent , HttpStatus.CREATED); + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + @DeleteMapping("/students/{id}") + public ResponseEntity deleteEmployee(@PathVariable Long id) { + + try { + Optional student = studentRepository.findById(id); + if (student.isPresent()) { + + studentRepository.delete(student.get()); + + return new ResponseEntity<>("Delete Success",HttpStatus.OK); + }else { + return new ResponseEntity<>("Student not found", HttpStatus.BAD_REQUEST); + } + + } catch (Exception e) { + return new ResponseEntity<>("Internal server error", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/src/main/java/reserve/controller/UserController.java b/src/main/java/reserve/controller/UserController.java index c47e4ed..b1c740a 100644 --- a/src/main/java/reserve/controller/UserController.java +++ b/src/main/java/reserve/controller/UserController.java @@ -6,16 +6,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import reserve.model.Product; import reserve.model.User; import reserve.repository.UserRepository; @RestController +@CrossOrigin(origins = "*") public class UserController { @Autowired @@ -32,6 +37,26 @@ public ResponseEntity getUsers() { return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); } + } + + @GetMapping("/user/{userID}") + public ResponseEntity getUsersById(@PathVariable("userID") Long userID) { + + try { + Optional userFind = userRepository.findById(userID); + + if (userFind.isPresent()) { + User user = userFind.get(); + + return new ResponseEntity<>( user, HttpStatus.OK); + }else { + return new ResponseEntity<>("User Not Found.", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + } @PostMapping("/user") public ResponseEntity createUser(@RequestBody User body) { @@ -46,6 +71,38 @@ public ResponseEntity createUser(@RequestBody User body) { } } + @PutMapping("/user/{userID}") + public ResponseEntity updateUserData(@PathVariable("userID") Long userID, @RequestBody User body) { + try { + Optional userFound = userRepository.findById(userID); + + if (userFound.isPresent()) { + User userToUpdate = userFound.get(); + + userToUpdate.setFirstname(body.getFirstname()); + userToUpdate.setLastname(body.getLastname()); + userToUpdate.setUsername(body.getUsername()); + userToUpdate.setTel(body.getTel()); + userToUpdate.setAddress(body.getAddress()); + userToUpdate.setProvince(body.getProvince()); + + if (body.getPassword() != null) { + userToUpdate.setPassword(body.getPassword()); + } + + userRepository.save(userToUpdate); + + return new ResponseEntity<>(userToUpdate, HttpStatus.OK); + } else { + return new ResponseEntity<>("User Not Found.", HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + return new ResponseEntity<>("Internal server error.", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @GetMapping("/checkUsername") public ResponseEntity checkUsername(@RequestParam("username") String username) { @@ -73,13 +130,14 @@ public ResponseEntity registerUser(@RequestBody User body) { if (userRepository.findByUsername(body.getUsername()).isPresent()) { return new ResponseEntity<>("Username is already taken.", HttpStatus.BAD_REQUEST); } - - // Create a new user User newUser = new User(); newUser.setUsername(body.getUsername()); newUser.setPassword(body.getPassword()); - newUser.setName(body.getName()); + newUser.setFirstname(body.getFirstname()); + newUser.setLastname(body.getLastname()); newUser.setTel(body.getTel()); + newUser.setAddress(body.getAddress()); + newUser.setProvince(body.getProvince()); newUser.setUserType(body.getUserType()); User saveUser = userRepository.save(newUser); diff --git a/src/main/java/reserve/model/Booking.java b/src/main/java/reserve/model/Booking.java index 753e3ec..6fac0bc 100644 --- a/src/main/java/reserve/model/Booking.java +++ b/src/main/java/reserve/model/Booking.java @@ -1,5 +1,7 @@ package reserve.model; +import java.sql.Timestamp; + import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -15,8 +17,11 @@ public class Booking { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long reviewID; - private String date_book; - private String date_reciept; + private Timestamp date_book; + private Timestamp date_reciept; + private Integer quantity; + private Integer total; + private String status; @ManyToOne @JoinColumn(name = "productid") @@ -26,11 +31,19 @@ public class Booking { @JoinColumn(name = "userID") private User user; - public Booking(Long reviewID, String date_book, String date_reciept, Product product, User user) { + public Booking() { + super(); + } + + public Booking(Long reviewID, Timestamp date_book, Timestamp date_reciept, Integer quantity, Integer total, + String status, Product product, User user) { super(); this.reviewID = reviewID; this.date_book = date_book; this.date_reciept = date_reciept; + this.quantity = quantity; + this.total = total; + this.status = status; this.product = product; this.user = user; } @@ -43,22 +56,46 @@ public void setReviewID(Long reviewID) { this.reviewID = reviewID; } - public String getDate_book() { + public Timestamp getDate_book() { return date_book; } - public void setDate_book(String date_book) { + public void setDate_book(Timestamp date_book) { this.date_book = date_book; } - public String getDate_reciept() { + public Timestamp getDate_reciept() { return date_reciept; } - public void setDate_reciept(String date_reciept) { + public void setDate_reciept(Timestamp date_reciept) { this.date_reciept = date_reciept; } + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + public Product getProduct() { return product; } diff --git a/src/main/java/reserve/model/Product.java b/src/main/java/reserve/model/Product.java index 4e7d86d..ffa4042 100644 --- a/src/main/java/reserve/model/Product.java +++ b/src/main/java/reserve/model/Product.java @@ -18,7 +18,8 @@ public class Product { @GeneratedValue(strategy = GenerationType.AUTO) private Long productid; private String productname; - private String price; + private Integer price; + private Integer piece; @Lob @Column(length = 3048576) @@ -29,26 +30,28 @@ public class Product { @JoinColumn(name = "userID") private User user; - - public Product() { - - } - - public Product(Long productid, String productname, String price, byte[] photoData, String detail, User user) { - super(); - this.productid = productid; - this.productname = productname; - this.price = price; - this.photoData = photoData; - this.detail = detail; - this.user = user; - } + public Product() { + super(); + } + + public Product(Long productid, String productname, Integer price, Integer piece, byte[] photoData, String detail, + User user) { + super(); + this.productid = productid; + this.productname = productname; + this.price = price; + this.piece = piece; + this.photoData = photoData; + this.detail = detail; + this.user = user; + } + public Long getProductid() { return productid; } - public void setProductid(Long poductid) { - this.productid = poductid; + public void setProductid(Long productid) { + this.productid = productid; } public String getProductname() { @@ -59,14 +62,22 @@ public void setProductname(String productname) { this.productname = productname; } - public String getPrice() { + public Integer getPrice() { return price; } - public void setPrice(String price) { + public void setPrice(Integer price) { this.price = price; } + public Integer getPiece() { + return piece; + } + + public void setPiece(Integer piece) { + this.piece = piece; + } + public byte[] getPhotoData() { return photoData; } @@ -90,8 +101,6 @@ public User getUser() { public void setUser(User user) { this.user = user; } - - - + } diff --git a/src/main/java/reserve/model/Student.java b/src/main/java/reserve/model/Student.java new file mode 100644 index 0000000..8752011 --- /dev/null +++ b/src/main/java/reserve/model/Student.java @@ -0,0 +1,56 @@ +package reserve.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "Student") +public class Student { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String studentid; + private String name; + private String email; + public Student(Long id, String studentid, String name, String email) { + super(); + this.id = id; + this.studentid = studentid; + this.name = name; + this.email = email; + } + public Student() { + super(); + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getStudentid() { + return studentid; + } + public void setStudentid(String studentid) { + this.studentid = studentid; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + + +} diff --git a/src/main/java/reserve/model/User.java b/src/main/java/reserve/model/User.java index 9f21e1c..7a58c8a 100644 --- a/src/main/java/reserve/model/User.java +++ b/src/main/java/reserve/model/User.java @@ -18,10 +18,13 @@ public class User { @Column(unique = true) private String username; - - private String name; + + private String firstname; + private String lastname; private String password; private String tel; + private String address; + private String province; private String userType; @@ -30,63 +33,131 @@ public User() { super(); } - public User(Long userID, String username, String password, String userType) { + + + public User(Long userID, String username, String firstname, String lastname, String password, String tel, + String address, String province, String userType) { super(); this.userID = userID; this.username = username; + this.firstname = firstname; + this.lastname = lastname; this.password = password; + this.tel = tel; + this.address = address; + this.province = province; this.userType = userType; } + + public Long getUserID() { return userID; } + + public void setUserID(Long userID) { this.userID = userID; } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; + + + public String getUsername() { + return username; } - public String getTel() { - return tel; + + + public void setUsername(String username) { + this.username = username; } - public void setTel(String tel) { - this.tel = tel; + + + public String getFirstname() { + return firstname; } - public String body() { - return username; + + + public void setFirstname(String firstname) { + this.firstname = firstname; } - - public String getUsername() { - return username; + + + + public String getLastname() { + return lastname; } - public void setUsername(String username) { - this.username = username; + + + public void setLastname(String lastname) { + this.lastname = lastname; } + + public String getPassword() { return password; } + + public void setPassword(String password) { this.password = password; } + + + public String getTel() { + return tel; + } + + + + public void setTel(String tel) { + this.tel = tel; + } + + + + public String getAddress() { + return address; + } + + + + public void setAddress(String address) { + this.address = address; + } + + + + public String getProvince() { + return province; + } + + + + public void setProvince(String province) { + this.province = province; + } + + + public String getUserType() { return userType; } + + public void setUserType(String userType) { this.userType = userType; } + + } + diff --git a/src/main/java/reserve/repository/BookingRepository.java b/src/main/java/reserve/repository/BookingRepository.java index 312d6a9..7205ed5 100644 --- a/src/main/java/reserve/repository/BookingRepository.java +++ b/src/main/java/reserve/repository/BookingRepository.java @@ -1,9 +1,18 @@ package reserve.repository; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import reserve.model.Booking; public interface BookingRepository extends JpaRepository{ + + List findByUserUserID(Long userID); + + List findByUserUserIDAndStatus(Long userID, String string); + List findByReviewIDIn(List reviewIDs); } diff --git a/src/main/java/reserve/repository/StudentRepository.java b/src/main/java/reserve/repository/StudentRepository.java new file mode 100644 index 0000000..203e3d1 --- /dev/null +++ b/src/main/java/reserve/repository/StudentRepository.java @@ -0,0 +1,9 @@ +package reserve.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import reserve.model.Student; + +public interface StudentRepository extends JpaRepository{ + +} \ No newline at end of file