Fakultas Ilmu Komputer UI

Commit 93fbb067 authored by MUHAMMAD AAQIL ABDULLAH's avatar MUHAMMAD AAQIL ABDULLAH
Browse files

Merge with staging

parent 5b0a5ab9
Pipeline #134374 canceled with stages
in 2 minutes
# Ryan's Bookstore
### Hello and welcome to our project called Ryan's Bookstore.
### 🖥Group Members🖥
1. 2006488013 - Fauzan Nazranda Rizqan
2. 2006489874 - Firlandi Althaf Rizqi Ansyari
3. 2006489501 - Muhammad Aaqil Abdullah
4. 2006519990 - Ryan Putra Budianto
5. 2006520001 - Winaldo Amadea Hestu
### 🔗OUR WEBSITE LINK🔗
[OUR WEBSITE](https://landi-and-friends-adpro.herokuapp.com/)
### ⚙Description⚙
Ryan's bookstore is a web project that we made which is an online book store application that allows the user to purchase a book remotely at home. Our project provides 10 features in overall that are utilized to achieve our main goal to help people purchase a specific book online in this pandemic era.
### 🕹Our Features🕹
- Homepage
- Cart
- Wishlist
- Books Recommendation
- Articles
- Consultation
- Large collection of book to browse
......@@ -10,4 +10,5 @@ public class LandiAndFriendsApplication {
SpringApplication.run(LandiAndFriendsApplication.class, args);
}
}
package id.ac.ui.cs.advprog.landiandfriends.exception;
public class AccountAlreadyExistsException extends RuntimeException {
private static final String MESSAGE = "Account with username %s or email %s already exists";
private final String username;
private final String email;
public AccountAlreadyExistsException(String username, String email){
super();
this.username = username;
this.email = email;
}
@Override
public String getMessage(){
return String.format(MESSAGE, username, email);
}
}
package id.ac.ui.cs.advprog.landiandfriends.exception;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class InvalidStockException extends RuntimeException {
private static final String MESSAGE = "Invalid stock '%s' for book %s";
private final String title;
private final String stock;
@Override
public String getMessage(){
return String.format(MESSAGE, stock, title);
}
}
package id.ac.ui.cs.advprog.landiandfriends.forms;
import lombok.Data;
import lombok.Generated;
@Generated
@Data
public class AddPaymentForm {
private String name;
private String cardName;
private String cardNumber;
private String expiryDate;
private String cvv;
}
package id.ac.ui.cs.advprog.landiandfriends.forms;
import lombok.Data;
import lombok.Generated;
@Generated
@Data
public class CreateAddressForm {
private String description;
private String city;
private String postalCode;
}
\ No newline at end of file
package id.ac.ui.cs.advprog.landiandfriends.forms;
import lombok.Data;
import lombok.Generated;
@Generated
@Data
public class CreateArticleForm {
private String title;
private String author;
private String content;
}
......@@ -4,6 +4,10 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import lombok.Generated;
@Generated
@Data
@NoArgsConstructor
@AllArgsConstructor
......@@ -13,6 +17,8 @@ public class CreateBookForm {
private String author;
private String description;
private String stock;
private List<String> genres;
private Float price;
}
......
package id.ac.ui.cs.advprog.landiandfriends.forms;
import lombok.Data;
import lombok.Generated;
@Generated
@Data
public class EditProfileForm {
private String username;
}
\ No newline at end of file
package id.ac.ui.cs.advprog.landiandfriends.forms;
import lombok.Data;
import lombok.Generated;
@Generated
@Data
public class RegisterForm {
private String email;
......
......@@ -5,28 +5,29 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import java.util.List;
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "user_model")
public class UserModel {
@Table(name = "address_model")
public class AddressModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long user_id;
@Column(name = "address_id")
private Long addressId;
@Column(nullable = false, unique = true, length = 45)
private String email;
@Column(name = "description")
private String description;
@Column(nullable = false, length = 64)
private String password;
@Column(name = "city")
private String city;
@Column(name = "username", nullable = false, length = 20)
private String username;
@Column(name = "postalCode")
private String postalCode;
}
@ManyToOne(cascade=CascadeType.REMOVE)
private User userModel;
}
package id.ac.ui.cs.advprog.landiandfriends.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "book_order")
public class BookOrder implements Order<Book>{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "book_order_Id")
private Long bookOrderId;
@ManyToOne
private Book book;
@ManyToOne
private Cart cart;
@Column(nullable = false, name = "amount")
private int amount = 1;
@Column(name = "total_price", nullable = false)
private float totalPrice;
@Override
public Book getItem() {
return book;
}
}
\ No newline at end of file
package id.ac.ui.cs.advprog.landiandfriends.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "cart_model")
public class Cart {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cart_Id")
private Long cartId;
@OneToMany(cascade=CascadeType.REMOVE)
@JoinTable(
name= "cart_book_order",
joinColumns = @JoinColumn(name = "cart_id"),
inverseJoinColumns = @JoinColumn(name = "book_order_id")
)
List<BookOrder> bookOrders = new ArrayList<>();
@OneToOne(cascade=CascadeType.REMOVE)
User user;
@Column(name = "total_price", nullable = false)
private float totalPrice;
@Column(name = "amount", nullable = false)
private int amount;
}
\ No newline at end of file
package id.ac.ui.cs.advprog.landiandfriends.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
......@@ -12,16 +14,17 @@ import java.util.List;
@Setter
@NoArgsConstructor
@Table(name = "genre_model")
public class GenreModel {
public class Genre {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "genre_Id")
private String genreId;
private Long genreId;
@Column(nullable = false, name = "name", length = 50)
@Column(nullable = false, name = "name", unique=true, length = 50)
private String name;
@JsonIgnore
@ManyToMany(mappedBy = "genres")
List<BookModel> books;
List<Book> books = new ArrayList<>();
}
package id.ac.ui.cs.advprog.landiandfriends.model;
public interface Order<T> {
Cart getCart();
int getAmount();
T getItem();
float getTotalPrice();
}
package id.ac.ui.cs.advprog.landiandfriends.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "payment_model")
public class PaymentModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, name = "id", length = 50)
private Integer paymentId;
@Column(name = "name", length = 50)
private String name;
@Column(name = "cardname", length = 50)
private String cardName;
@Column(name = "cardnumber", length = 50)
private String cardNumber;
@Column(name = "expiryDate", length = 5)
private String expiryDate;
@Column(name = "cvv", length = 3)
private String cvv;
@ManyToOne(cascade=CascadeType.REMOVE)
private User userModel;
}
package id.ac.ui.cs.advprog.landiandfriends.repository;
import id.ac.ui.cs.advprog.landiandfriends.model.AddressModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import javax.transaction.Transactional;
import java.util.List;
@Repository
public interface AddressRepository extends JpaRepository<AddressModel,String> {
@Query(value = "SELECT address_id from user_address where user_id = ?1", nativeQuery = true)
List<Long> getAddressId(Long userId);
@Query(value = "SELECT * from address_model where address_id = ?1", nativeQuery = true)
AddressModel getAddressFromId(Long addressId);
@Transactional
@Modifying
@Query(value = "insert into user_address (address_id,user_id) values (?1,?2);", nativeQuery = true)
void insertUserAddress(Long addressId, Long userId);
//update address
@Transactional
@Modifying
@Query(value = "update address_model set description = ?1, city = ?2, postal_code = ?3 where address_id = ?4", nativeQuery = true)
void updateAddress(String description, String city, String postalCode, Long addressId);
//delete address
@Transactional
@Modifying
@Query(value = "delete from user_address where address_id = ?1", nativeQuery = true)
void deleteUserAddress(Long addressId);
}
package id.ac.ui.cs.advprog.landiandfriends.repository;
import id.ac.ui.cs.advprog.landiandfriends.model.Articles;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ArticleRepository extends JpaRepository<Articles,Integer> {
}
package id.ac.ui.cs.advprog.landiandfriends.repository;
import id.ac.ui.cs.advprog.landiandfriends.model.BookModel;
import id.ac.ui.cs.advprog.landiandfriends.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface BookRepository extends JpaRepository<BookModel,String> {
public interface BookRepository extends JpaRepository<Book,Long> {
@Query("SELECT b FROM Book b WHERE b.bookId = ?1")
Book findByBookId(long bookId);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment