Skip to content

Commit c991d98

Browse files
committed
Add documents for shopapp-backend
1 parent 95b6a7d commit c991d98

File tree

9,296 files changed

+2306329
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

9,296 files changed

+2306329
-0
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.ignoreLimitWarning": true
3+
}

Viết ứng dụng bán hàng với Java SpringbootAPI và Angular/shopapp-backend/shopapp-backend-10/shopapp-backend/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Viết ứng dụng bán hàng với Java SpringbootAPI và Angular/shopapp-backend/shopapp-backend-10/shopapp-backend/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Viết ứng dụng bán hàng với Java SpringbootAPI và Angular/shopapp-backend/shopapp-backend-10/shopapp-backend/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Viết ứng dụng bán hàng với Java SpringbootAPI và Angular/shopapp-backend/shopapp-backend-10/shopapp-backend/.idea/workspace.xml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
CREATE DATABASE shopapp;
2+
USE shopapp;
3+
--Khách hàng khi muốn mua hàng => phải đăng ký tài khoản => bảng users
4+
CREATE TABLE users(
5+
id INT PRIMARY KEY AUTO_INCREMENT,
6+
fullname VARCHAR(100) DEFAULT '',
7+
phone_number VARCHAR(10) NOT NULL,
8+
address VARCHAR(200) DEFAULT '',
9+
password VARCHAR(100) NOT NULL DEFAULT '',
10+
created_at DATETIME,
11+
updated_at DATETIME,
12+
is_active TINYINT(1) DEFAULT 1,
13+
date_of_birth DATE,
14+
facebook_account_id INT DEFAULT 0,
15+
google_account_id INT DEFAULT 0
16+
);
17+
ALTER TABLE users ADD COLUMN role_id INT;
18+
19+
CREATE TABLE roles(
20+
id INT PRIMARY KEY,
21+
name VARCHAR(20) NOT NULL
22+
);
23+
ALTER TABLE users ADD FOREIGN KEY (role_id) REFERENCES roles (id);
24+
25+
CREATE TABLE tokens(
26+
id int PRIMARY KEY AUTO_INCREMENT,
27+
token varchar(255) UNIQUE NOT NULL,
28+
token_type varchar(50) NOT NULL,
29+
expiration_date DATETIME,
30+
revoked tinyint(1) NOT NULL,
31+
expired tinyint(1) NOT NULL,
32+
user_id int,
33+
FOREIGN KEY (user_id) REFERENCES users(id)
34+
);
35+
36+
--hỗ trợ đăng nhập từ Facebook và Google
37+
CREATE TABLE social_accounts(
38+
id INT PRIMARY KEY AUTO_INCREMENT,
39+
provider VARCHAR(20) NOT NULL COMMENT 'Tên nhà social network',
40+
provider_id VARCHAR(50) NOT NULL,
41+
email VARCHAR(150) NOT NULL COMMENT 'Email tài khoản',
42+
name VARCHAR(100) NOT NULL COMMENT 'Tên người dùng',
43+
user_id int,
44+
FOREIGN KEY (user_id) REFERENCES users(id)
45+
);
46+
47+
--Bảng danh mục sản phẩm(Category)
48+
CREATE TABLE categories(
49+
id INT PRIMARY KEY AUTO_INCREMENT,
50+
name varchar(100) NOT NULL DEFAULT '' COMMENT 'Tên danh mục, vd: đồ điện tử'
51+
);
52+
53+
--Bảng chứa sản phẩm(Product): "laptop macbook air 15 inch 2023", iphone 15 pro,...
54+
CREATE TABLE products (
55+
id INT PRIMARY KEY AUTO_INCREMENT,
56+
name VARCHAR(350) COMMENT 'Tên sản phẩm',
57+
price FLOAT NOT NULL CHECK (price >= 0),
58+
thumbnail VARCHAR(300) DEFAULT '',
59+
description LONGTEXT DEFAULT '',
60+
created_at DATETIME,
61+
updated_at DATETIME,
62+
category_id INT,
63+
FOREIGN KEY (category_id) REFERENCES categories (id)
64+
);
65+
66+
CREATE TABLE product_images(
67+
id INT PRIMARY KEY AUTO_INCREMENT,
68+
product_id INT,
69+
FOREIGN KEY (product_id) REFERENCES products (id),
70+
CONSTRAINT fk_product_images_product_id
71+
FOREIGN KEY (product_id)
72+
REFERENCES products (id) ON DELETE CASCADE,
73+
image_url VARCHAR(300)
74+
);
75+
76+
--Đặt hàng - orders
77+
CREATE TABLE orders(
78+
id INT PRIMARY KEY AUTO_INCREMENT,
79+
user_id int,
80+
FOREIGN KEY (user_id) REFERENCES users(id),
81+
fullname VARCHAR(100) DEFAULT '',
82+
email VARCHAR(100) DEFAULT '',
83+
phone_number VARCHAR(20) NOT NULL,
84+
address VARCHAR(200) NOT NULL,
85+
note VARCHAR(100) DEFAULT '',
86+
order_date DATETIME DEFAULT CURRENT_TIMESTAMP,
87+
status VARCHAR(20),
88+
total_money FLOAT CHECK(total_money >= 0)
89+
);
90+
91+
ALTER TABLE orders ADD COLUMN `shipping_method` VARCHAR(100);
92+
ALTER TABLE orders ADD COLUMN `shipping_address` VARCHAR(200);
93+
ALTER TABLE orders ADD COLUMN `shipping_date` DATE;
94+
ALTER TABLE orders ADD COLUMN `tracking_number` VARCHAR(100);
95+
ALTER TABLE orders ADD COLUMN `payment_method` VARCHAR(100);
96+
--xóa 1 đơn hàng => xóa mềm => thêm trường active
97+
ALTER TABLE orders ADD COLUMN active TINYINT(1);
98+
--Trạng thái đơn hàng chỉ đc phép nhận "một số giá trị cụ thể"
99+
ALTER TABLE orders
100+
MODIFY COLUMN status ENUM('pending', 'processing', 'shipped', 'delivered', 'cancelled')
101+
COMMENT 'Trạng thái đơn hàng';
102+
103+
CREATE TABLE order_details(
104+
id INT PRIMARY KEY AUTO_INCREMENT,
105+
order_id INT,
106+
FOREIGN KEY (order_id) REFERENCES orders (id),
107+
product_id INT,
108+
FOREIGN KEY (product_id) REFERENCES products (id),
109+
price FLOAT CHECK(price >= 0),
110+
number_of_products INT CHECK(number_of_products > 0),
111+
total_money FLOAT CHECK(total_money >= 0),
112+
color VARCHAR(20) DEFAULT ''
113+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
tôi có 2 thực thể products và product_images, có quan hệ 1-n, trong product_images có trường product_id. Hãy viết lệnh sql trong mysql cho phép cập nhật trường thumbnail của bảng products là giá trị trường image_url của 1 trong các bản ghi của bảng product_images với products.id == product_images
2+
3+
4+
Thêm nút search vào phía bên phải thẻ input, khi bấm nút search sẽ tìm kiếm và trả về danh sách sản phẩm có paging
5+
6+
<div class="search-box">
7+
<input type="text" class="form-control search-input" placeholder="Tìm sản phẩm">
8+
<select class="form-control product-category" [(ngModel)]="selectedCategory">
9+
<option selected disabled>Danh mục sản phẩm</option>
10+
<option *ngFor="let category of categories" [value]="category.id">{{ category.name }}</option>
11+
</select>
12+
</div>
13+
14+
getProducts(keyword: string, page: number, limit: number) {
15+
this.productService.getProducts(keyword, page, limit).subscribe({
16+
next: (response: any) => {
17+
debugger
18+
response.products.forEach((product: Product) => {
19+
product.url = `${environment.apiBaseUrl}/products/images/${product.thumbnail}`;
20+
});
21+
this.products = response.products;
22+
this.totalPages = response.totalPages;
23+
this.visiblePages = this.generateVisiblePageArray(this.currentPage, this.totalPages);
24+
},
25+
complete: () => {
26+
debugger;
27+
},
28+
error: (error: any) => {
29+
debugger;
30+
console.error('Error fetching products:', error);
31+
}
32+
});
33+
}
34+
35+
36+
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

0 commit comments

Comments
 (0)