Skip to content

Commit

Permalink
Ready for testing and deploying phase (#93)
Browse files Browse the repository at this point in the history
* Initial frontend

* Header and Footer UI.

* [BE] Create database (#3)

* Feature/sidebaradmin (#23)

* Homepages (#25)

* update page product

* Filter product (#27)

* update page product and navbar, dashboard

* add database and product detail page

* implement filter product with fake database

* Database change user role type (#29)

* Full User Page Layout (#30)

* update page product and navbar, dashboard

* add database and product detail page

* implement filter product with fake database

* payment page and cart page

* sort_product

* Feature/manage user (#28)

* Manage User bug handle upload image

* UI ManageUser vs inext8

* View Product with pagination

* Responsive dashboard

* Search Deouce

* Feature/manage user (#32)

* Manage User bug handle upload image

* UI ManageUser vs inext8

* View Product with pagination

* Responsive dashboard

* Search Deouce

* Config store redux

* clean and construct directory (#38)

* construct directory and update database (#39)

* connect to database via docker (#40)

* Code scanning configuration (#41)

* Update codeql.yml (#43)

* Login update (#48)

* responsive home page

* update login page and register page and Cart Using Redux Toolkit

* Feature/login cart fix (#49)

* Update cart

* API Product + Category (#54)

* base Product API with exception handle

* update documentations

* make API documentation with OpenAPI 3.0

* complete API product and category

* FEAT: RESPONSIVE CART PAGE AND PAYMENT PAGE

* Update Cart Page

* CALL API

* User & User Address API + Authentication/Authorization (#60)

* configurage for logging

* base setup for user and useraddress

* update documentation

* update API get products of category endpoint

* handle register/login user and response token

* update user api and exception handler

* User Address API and clean up the rest

* add authorize for Swagger and update json request

* authorization implementation

* handle authentication exception

* CORS handle

* default admin generation one time when startup

* update register and authenticate API

* FEAT: Call API in Cart Page

* update documentation

* Implement Order API

* update database

* update permissions

* update RolePermission documentation

* Feature/handle crud admin (#69)

* Create Store

* Login

* allow no authorize for get all products and categories (#70)

* FEAT: add login logic

* handle login register

* Implement Order Detail API

* update role & permission

* update request validation

* update attribute in order table

* update role & permission

* Modify rq header axios

* Update Header handle redux

* handle transaction orderdetail - product quantity

* clean up and update exception handler

* handle transaction cascade user-order-orderdetail (#74)

* Rating API (#75)

* handle transaction cascade user-order-orderdetail

* implement Rating API

* update role & permission

* clean code

* FEATURE: CALL API

* Crud User admin

* FEATURE: Add Update Account Page

* REFACTOR: Update code Add Address

* Handle crud user and Products (#77)

* Create Store

* Crud User admin

* Done crud Product

* Protect roles

* FEATURE: account handle

* update search

* Page product for category and logout redirect

* Email Verification (#83)

* config CORS

* base mail sender

* optimize method and enable HTTP/2

* update mail configuration and template

* update admin default name

* implement registration email sender

* handle async email sending

* handle email verification to enable user

* update documentation

* Reset Password + Change Password (#85)

* update register api not response token

* handle reset-password and change password API

* Modify and logic (#86)

* FEATURE: MANAGER ORDER

* Allow no email verification to login (#89)

* FEATURE: Update login and Register

* handle old new password (#91)

* FEATURE: Handle Login And ResetPassword

---------

Co-authored-by: Dinh Quang Huy <dinhquanghuy0809@gmail.com>
Co-authored-by: Dinh Quang Huy <71219472+quanghuy89@users.noreply.github.com>
Co-authored-by: trandangnguyenbao <trandangnguyenbao2810@gmail.com>
Co-authored-by: tdnbao281001 <61140987+trandangnguyenbao@users.noreply.github.com>
Co-authored-by: Nguyễn Trung Quốc <113247967+qnt078@users.noreply.github.com>
  • Loading branch information
6 people committed May 9, 2023
1 parent 2153788 commit 9f255eb
Show file tree
Hide file tree
Showing 901 changed files with 124,320 additions and 24 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master", "staging", "dev" ]
schedule:
- cron: '0 7,19 * * 0-6'

jobs:
analyze:
name: Analyze vulnerabilities
runs-on: ubuntu-latest, windows-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
27 changes: 5 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/
git-credential-manager/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# idea folder
.idea/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# VS Code
.vscode/

git-credential-manager/
33 changes: 33 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
8 changes: 8 additions & 0 deletions backend/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added backend/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions backend/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
30 changes: 29 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
This file is for pushing empty folder to remote repo!
# Back-end documentation

## Technologies

1. [MySQL](https://www.mysql.com/)
2. [Spring Boot 3](https://spring.io/projects/spring-boot)
3. Other Spring Ecosystems
- [Spring Data JPA](https://spring.io/projects/spring-data-jpa)
- [Spring Security](https://spring.io/projects/spring-security)
- [Spring Web](https://spring.io/projects/spring-web)
- [Spring Test](https://spring.io/guides/gs/testing-web/)

## Requirements

1. [Java 17+](https://adoptium.net/)
2. [Docker Desktop](https://www.docker.com/)

## Resources

1. [MySQL Scripts](assets/databases/mysql)
2. [Database Design](assets/images/database/database_info_v1.png)
3. [Spring Security Architecture](assets/images/security)
4. [Documentation](docs)

## Documentation

1. [Connect to database](docs/ConnectDatabase.md)
2. [APIs](docs/APIs.md)
3. [Role & Permission](docs/RolePermission.md)
Binary file added backend/assets/databases/mysql/dbs_model.mwb
Binary file not shown.
Binary file added backend/assets/databases/mysql/dbs_model.mwb.bak
Binary file not shown.
175 changes: 175 additions & 0 deletions backend/assets/databases/mysql/dbs_model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema myecommerce
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema myecommerce
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `myecommerce` ;
USE `myecommerce` ;

-- -----------------------------------------------------
-- Table `myecommerce`.`User`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`User` (
`UserID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`Email` VARCHAR(254) NOT NULL,
`Password` VARCHAR(255) NOT NULL,
`FullName` VARCHAR(255) NOT NULL,
`Gender` VARCHAR(255) NOT NULL,
`Phone` VARCHAR(255) NOT NULL,
`Image` VARCHAR(255) NOT NULL,
`Role` VARCHAR(255) NOT NULL,
`Locked` BIT(1) NOT NULL,
`Enabled` BIT(1) NOT NULL,
PRIMARY KEY (`UserID`),
UNIQUE INDEX `email_UNIQUE` (`Email` ASC) VISIBLE,
UNIQUE INDEX `phone_UNIQUE` (`Phone` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`UserAddress`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`UserAddress` (
`UserAddressID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`UserID` BIGINT UNSIGNED NOT NULL,
`Address` VARCHAR(255) NOT NULL,
PRIMARY KEY (`UserAddressID`),
INDEX `fk_UserAddress_User1_idx` (`UserID` ASC) VISIBLE,
CONSTRAINT `fk_UserAddress_User1`
FOREIGN KEY (`UserID`)
REFERENCES `myecommerce`.`User` (`UserID`)
ON DELETE CASCADE
ON UPDATE RESTRICT)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`Order`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`Order` (
`OrderID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`UserID` BIGINT UNSIGNED NOT NULL,
`AdditionalPrice` BIGINT UNSIGNED NOT NULL,
`PaymentType` VARCHAR(255) NOT NULL,
`Status` VARCHAR(255) NOT NULL,
`DateOrder` DATE NOT NULL,
`Address` VARCHAR(255) NOT NULL,
PRIMARY KEY (`OrderID`),
INDEX `fk_Order_User1_idx` (`UserID` ASC) VISIBLE,
CONSTRAINT `fk_Order_User1`
FOREIGN KEY (`UserID`)
REFERENCES `myecommerce`.`User` (`UserID`)
ON DELETE CASCADE
ON UPDATE RESTRICT)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`Category`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`Category` (
`CategoryID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Slug` VARCHAR(255) NOT NULL,
`Image` VARCHAR(255) NOT NULL,
PRIMARY KEY (`CategoryID`),
UNIQUE INDEX `Slug_UNIQUE` (`Slug` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`Product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`Product` (
`ProductID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`CategoryID` BIGINT UNSIGNED NULL,
`Name` VARCHAR(255) NOT NULL,
`Slug` VARCHAR(255) NOT NULL,
`Image` VARCHAR(255) NOT NULL,
`ImageReview1` VARCHAR(255) NOT NULL,
`ImageReview2` VARCHAR(255) NOT NULL,
`ImageReview3` VARCHAR(255) NOT NULL,
`UnitPrice` BIGINT UNSIGNED NOT NULL,
`Quantity` INT UNSIGNED NOT NULL,
`Description` LONGTEXT NOT NULL,
`YearRelease` SMALLINT(4) NOT NULL,
`Manufacturer` VARCHAR(255) NOT NULL,
`Monitor` VARCHAR(255) NOT NULL,
`CPU` VARCHAR(255) NOT NULL,
`RAM` VARCHAR(255) NOT NULL,
`VGA` VARCHAR(255) NOT NULL,
`HardDisk` VARCHAR(255) NOT NULL,
`Camera` VARCHAR(255) NOT NULL,
`Battery` VARCHAR(255) NOT NULL,
`Memory` VARCHAR(255) NOT NULL,
`Demand` VARCHAR(255) NOT NULL,
`Status` BIT(1) NOT NULL,
PRIMARY KEY (`ProductID`),
INDEX `fk_Product_Category1_idx` (`CategoryID` ASC) VISIBLE,
UNIQUE INDEX `Slug_UNIQUE` (`Slug` ASC) VISIBLE,
CONSTRAINT `fk_Product_Category1`
FOREIGN KEY (`CategoryID`)
REFERENCES `myecommerce`.`Category` (`CategoryID`)
ON DELETE SET NULL
ON UPDATE RESTRICT)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`OrderDetail`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`OrderDetail` (
`OrderID` BIGINT UNSIGNED NOT NULL,
`ProductID` BIGINT UNSIGNED NOT NULL,
`PurchasePrice` BIGINT UNSIGNED NOT NULL,
`Quantity` INT UNSIGNED NOT NULL,
PRIMARY KEY (`OrderID`, `ProductID`),
INDEX `fk_OrderDetail_Order1_idx` (`OrderID` ASC) VISIBLE,
INDEX `fk_OrderDetail_Product1_idx` (`ProductID` ASC) VISIBLE,
CONSTRAINT `fk_OrderDetail_Order1`
FOREIGN KEY (`OrderID`)
REFERENCES `myecommerce`.`Order` (`OrderID`)
ON DELETE CASCADE
ON UPDATE RESTRICT,
CONSTRAINT `fk_OrderDetail_Product1`
FOREIGN KEY (`ProductID`)
REFERENCES `myecommerce`.`Product` (`ProductID`)
ON DELETE RESTRICT
ON UPDATE RESTRICT)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `myecommerce`.`Rating`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myecommerce`.`Rating` (
`UserID` BIGINT UNSIGNED NOT NULL,
`OrderID` BIGINT UNSIGNED NOT NULL,
`ProductID` BIGINT UNSIGNED NOT NULL,
`RateAmount` TINYINT(1) UNSIGNED NOT NULL,
`Comment` LONGTEXT NOT NULL,
`DateRating` DATE NOT NULL,
PRIMARY KEY (`UserID`, `OrderID`, `ProductID`),
INDEX `fk_Rating_OrderDetail1_idx` (`OrderID` ASC, `ProductID` ASC) VISIBLE,
CONSTRAINT `fk_Rating_User1`
FOREIGN KEY (`UserID`)
REFERENCES `myecommerce`.`User` (`UserID`)
ON DELETE CASCADE
ON UPDATE RESTRICT,
CONSTRAINT `fk_Rating_OrderDetail1`
FOREIGN KEY (`OrderID` , `ProductID`)
REFERENCES `myecommerce`.`OrderDetail` (`OrderID` , `ProductID`)
ON DELETE CASCADE
ON UPDATE RESTRICT)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Binary file added backend/assets/images/api/json_body_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/assets/images/api/swaggerUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/assets/images/database/connection-run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/assets/images/database/docker-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/assets/images/database/docker-done.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/assets/images/security/authenticate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions backend/compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
db:
container_name: mysql
image: mysql:8.0.32
cap_add:
- SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- db:/var/lib/mysql
ports:
- "3333:3306"
restart: unless-stopped
volumes:
db:
Loading

0 comments on commit 9f255eb

Please sign in to comment.