Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #43 from hardingadonis/dev
Browse files Browse the repository at this point in the history
Sale Dock - v0.0.2
  • Loading branch information
hardingadonis authored Jan 18, 2024
2 parents 9851817 + 6a0122f commit d28c8b8
Show file tree
Hide file tree
Showing 30 changed files with 771 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- name: 'Checkout repository'
uses: actions/checkout@v4

- name: 'Set up JDK 8'
- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '17'
distribution: 'temurin'
architecture: 'x64'

- name: 'Build project with Maven'
run: mvn verify
run: mvn verify
13 changes: 1 addition & 12 deletions database/database.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions database/setup.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE `customer` (
`id` int PRIMARY KEY AUTO_INCREMENT COMMENT 'ID dùng để quản lý, tự động tăng',
`code` varchar(255) UNIQUE COMMENT 'Mã khách hàng, sẽ hiện trên giao diện, ID thì không hiện',
`code` varchar(255) UNIQUE NOT NULL COMMENT 'Mã khách hàng, sẽ hiện trên giao diện, ID thì không hiện',
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
Expand All @@ -10,11 +10,11 @@ CREATE TABLE `customer` (

CREATE TABLE `product` (
`id` int PRIMARY KEY AUTO_INCREMENT COMMENT 'ID dùng để quản lý, tự động tăng',
`code` varchar(255) UNIQUE COMMENT 'Mã sản phẩm, sẽ hiện trên giao diện, ID thì không hiện',
`code` varchar(255) UNIQUE NOT NULL COMMENT 'Mã sản phẩm, sẽ hiện trên giao diện, ID thì không hiện',
`name` varchar(255) NOT NULL,
`description` TEXT,
`price` REAL NOT NULL,
`category_id` varchar(255) NOT NULL,
`category_id` int NOT NULL,
`image_url` LONGTEXT,
`created_at` TIMESTAMP DEFAULT null,
`updated_at` TIMESTAMP DEFAULT null
Expand All @@ -27,7 +27,7 @@ CREATE TABLE `category` (

CREATE TABLE `employee` (
`id` int PRIMARY KEY AUTO_INCREMENT COMMENT 'ID dùng để quản lý, tự động tăng',
`code` varchar(255) UNIQUE COMMENT 'Mã nhân viên, sẽ hiện trên giao diện, dùng để đăng nhập, vd QE170001',
`code` varchar(255) UNIQUE NOT NULL COMMENT 'Mã nhân viên, sẽ hiện trên giao diện, dùng để đăng nhập, vd QE170001',
`password` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT null,
Expand All @@ -36,10 +36,10 @@ CREATE TABLE `employee` (

CREATE TABLE `order` (
`id` int PRIMARY KEY AUTO_INCREMENT COMMENT 'ID dùng để quản lý, tự động tăng',
`code` varchar(255) UNIQUE,
`code` varchar(255) UNIQUE NOT NULL,
`employee_id` int NOT NULL,
`customer_id` int NOT NULL,
`status` ENUM ('pending', 'shipping', 'done', 'canceled') NOT NULL,
`status` ENUM ('pending', 'shipping', 'done', 'cancelled') NOT NULL,
`total` REAL NOT NULL,
`note` TEXT DEFAULT null,
`created_at` TIMESTAMP DEFAULT null,
Expand Down
2 changes: 1 addition & 1 deletion get_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

major_version=0
minor_version=0
path_version=1
path_version=2

echo "$major_version.$minor_version.$path_version"
57 changes: 44 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,73 @@

<groupId>io.hardingadonis</groupId>
<artifactId>saledock</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
<packaging>war</packaging>

<name>Sale Dock</name>
<name>Sale Dock - v${project.version}</name>

<properties>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<endorsed.dir>${project.basedir}/server/</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.0.0</jakartaee>
</properties>

<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<version>8.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.15.Final</version>
<version>6.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.16.0</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${maven.compiler.target}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -48,7 +79,7 @@
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>${project.basedir}/server/</outputDirectory>
<outputDirectory>${endorsed.dir}</outputDirectory>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package io.hardingadonis.saledock.controller;

public class Controller {

}
public class Controller {}
6 changes: 6 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/ICategoryDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.hardingadonis.saledock.dao;

import io.hardingadonis.saledock.model.*;

public interface ICategoryDAO extends IDAO<Category> {
}
6 changes: 6 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/ICustomerDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.hardingadonis.saledock.dao;

import io.hardingadonis.saledock.model.*;

public interface ICustomerDAO extends IDAO<Customer> {
}
14 changes: 14 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/IDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.hardingadonis.saledock.dao;

import java.util.*;

public interface IDAO<T> {

public void add(T obj);

public Optional<T> getByID(Integer ID);

public List<T> getAll();

void update(T obj);
}
6 changes: 6 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/IEmployeeDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.hardingadonis.saledock.dao;

import io.hardingadonis.saledock.model.*;

public interface IEmployeeDAO extends IDAO<Employee> {
}
7 changes: 7 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/IOrderDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.hardingadonis.saledock.dao;

import io.hardingadonis.saledock.model.*;

public interface IOrderDAO extends IDAO<Order> {

}
6 changes: 6 additions & 0 deletions src/main/java/io/hardingadonis/saledock/dao/IProductDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.hardingadonis.saledock.dao;

import io.hardingadonis.saledock.model.*;

public interface IProductDAO extends IDAO<Product> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.hardingadonis.saledock.dao.impl;

import io.hardingadonis.saledock.dao.*;
import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import java.util.*;
import org.hibernate.*;

public class CategoryDAOImpl implements ICategoryDAO {

private final SessionFactory sessionFactory;

public CategoryDAOImpl() {
this.sessionFactory = HibernateUtil.getSessionFactory();
}

@Override
public void add(Category obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.persist(obj);
session.getTransaction().commit();
}
}

@Override
public Optional<Category> getByID(Integer ID) {
try (Session session = sessionFactory.openSession()) {
return Optional.ofNullable(session.get(Category.class, ID));
}
}

@Override
public List<Category> getAll() {
try (Session session = sessionFactory.openSession()) {
return session.createQuery("FROM Category", Category.class).getResultList();
}
}

@Override
public void update(Category obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.merge(obj);
session.getTransaction().commit();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.hardingadonis.saledock.dao.impl;

import io.hardingadonis.saledock.dao.*;
import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import java.util.*;
import org.hibernate.*;

public class CustomerDAOImpl implements ICustomerDAO {

private final SessionFactory sessionFactory;

public CustomerDAOImpl() {
this.sessionFactory = HibernateUtil.getSessionFactory();
}

@Override
public void add(Customer obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.persist(obj);
session.getTransaction().commit();
}
}

@Override
public Optional<Customer> getByID(Integer ID) {
try (Session session = sessionFactory.openSession()) {
return Optional.ofNullable(session.get(Customer.class, ID));
}
}

@Override
public List<Customer> getAll() {
try (Session session = sessionFactory.openSession()) {
return session.createQuery("FROM Customer", Customer.class).getResultList();
}
}

@Override
public void update(Customer obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.merge(obj);
session.getTransaction().commit();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.hardingadonis.saledock.dao.impl;

import io.hardingadonis.saledock.dao.*;
import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import java.util.*;
import org.hibernate.*;

public class EmployeeDAOImpl implements IEmployeeDAO {

private final SessionFactory sessionFactory;

public EmployeeDAOImpl() {
this.sessionFactory = HibernateUtil.getSessionFactory();
}

@Override
public void add(Employee obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.persist(obj);
session.getTransaction().commit();
}
}

@Override
public Optional<Employee> getByID(Integer ID) {
try (Session session = sessionFactory.openSession()) {
return Optional.ofNullable(session.get(Employee.class, ID));
}
}

@Override
public List<Employee> getAll() {
try (Session session = sessionFactory.openSession()) {
return session.createQuery("FROM Employee", Employee.class).getResultList();
}
}

@Override
public void update(Employee obj) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.merge(obj);
session.getTransaction().commit();
}
}
}
Loading

0 comments on commit d28c8b8

Please sign in to comment.