diff --git a/src/META-INF/equip-database.sql b/src/META-INF/equip-database.sql index e69de29..07a7824 100644 --- a/src/META-INF/equip-database.sql +++ b/src/META-INF/equip-database.sql @@ -0,0 +1,75 @@ +create database equipments_management; + +create table equipment_categories +( + category_id int identity + primary key, + category_name nvarchar(100) not null + unique +) + go + +create table equipments +( + equipment_id int identity + primary key, + equipment_name nvarchar(100) not null + unique, + equipment_color nvarchar(100) not null, + equipment_created_date bigint not null, + equipment_quantity int not null, + equipment_category_id int + references equipment_categories +) + go + +create table roles +( + role_id int not null + primary key, + name varchar(100) not null + unique +) + go + +create table users +( + user_id varchar(100) not null + primary key, + password varchar(100) not null, + fullname nvarchar(100) not null, + email varchar(100) not null + unique, + phone varchar(100) not null, + address varchar(200) not null, + created_date bigint not null, + is_activated bit not null, + role_id int + references roles, + otp varchar(6) not null +) + go + +create table equipments_request +( + equipments_request_id int identity + primary key, + requester varchar(100) + references users, + assignee varchar(100) + references users, + request_status varchar(100) not null, + requested_date bigint not null, + equipment_id int + references equipments +) + go + +create table equipments_request_history +( + equipments_request_history_id int identity + primary key, + equipments_request_id int + references equipments_request +) + go diff --git a/src/bangmaple/Main.java b/src/bangmaple/Main.java index 4e50fa7..d5f41c4 100644 --- a/src/bangmaple/Main.java +++ b/src/bangmaple/Main.java @@ -8,6 +8,8 @@ import bangmaple.dao.UsersDAO; import bangmaple.dto.UsersDTO; import bangmaple.jdbc.dao.base.Store; +import bangmaple.jdbc.paging.PageRequest; +import bangmaple.jdbc.paging.Pageable; import bangmaple.jdbc.repository.JdbcRepository; import bangmaple.jdbc.utils.ConnectionManager; @@ -51,6 +53,10 @@ public static void main(String[] args) throws Exception { System.out.println(dao.count()); dao.deleteAll(); dao.deleteAllByIds(Arrays.asList("1", "2", "3", "4")); + System.out.println(dao.findAll(PageRequest.of(1, 5))); + System.out.println(dao.findAll(PageRequest.of(0, 4, Pageable.SORT_DESC))); + System.out.println(dao.findAll(PageRequest.of(0, 4, Pageable.SORT_DESC, "username", "fullname"))); + System.out.println(dao.findAll(Pageable.SORT_DESC)); } } diff --git a/src/bangmaple/dto/EquipmentsDTO.java b/src/bangmaple/dto/EquipmentsDTO.java index db38a89..3900227 100644 --- a/src/bangmaple/dto/EquipmentsDTO.java +++ b/src/bangmaple/dto/EquipmentsDTO.java @@ -13,7 +13,7 @@ * * @author bangmaple */ -@Table(name = "equipments", catalog = "LAB231_1") +@Table(name = "equipments", catalog = "equipments_management") public class EquipmentsDTO { @Id diff --git a/src/bangmaple/jdbc/paging/PageRequest.java b/src/bangmaple/jdbc/paging/PageRequest.java index b02bde0..48a5182 100644 --- a/src/bangmaple/jdbc/paging/PageRequest.java +++ b/src/bangmaple/jdbc/paging/PageRequest.java @@ -1,7 +1,6 @@ package bangmaple.jdbc.paging; import java.io.Serializable; -import java.util.Arrays; public class PageRequest extends AbstractPageRequest implements Serializable { diff --git a/src/bangmaple/jdbc/paging/Pageable.java b/src/bangmaple/jdbc/paging/Pageable.java index 7f3c9c4..ad9ff7c 100644 --- a/src/bangmaple/jdbc/paging/Pageable.java +++ b/src/bangmaple/jdbc/paging/Pageable.java @@ -1,7 +1,5 @@ package bangmaple.jdbc.paging; -import java.util.Optional; - public interface Pageable { boolean SORT_ASC = true;