Skip to content

Commit 1be2c9d

Browse files
authored
Merge pull request #65 from tynab/develop
260618
2 parents 307bf29 + 0d066ba commit 1be2c9d

86 files changed

Lines changed: 910 additions & 626 deletions

File tree

Some content is hidden

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

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
# Tom tat: Image phuc vu chay CRM Spring Boot bang Maven Wrapper trong container.
12
FROM eclipse-temurin:17-jdk-focal
23

34
WORKDIR /app
45

6+
# Copy Maven Wrapper va pom truoc de cache dependency layer.
57
COPY .mvn/ .mvn
68
COPY mvnw pom.xml ./
79

810
RUN chmod +x mvnw
911

1012
RUN ./mvnw dependency:go-offline
1113

14+
# Copy source sau khi cache dependency de build/run nhanh hon khi code thay doi.
1215
COPY src ./src
1316

14-
CMD ["./mvnw", "spring-boot:run"]
17+
CMD ["./mvnw", "spring-boot:run"]

Jenkinsfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
pipeline {
2+
// Tom tat: Pipeline build image CRM, push Docker Hub, restart container va
3+
// gui thong bao Telegram theo tung stage.
24
agent any
35

46
environment {
5-
// Telegram configre
7+
// Cau hinh Telegram lay tu Jenkins credentials.
68
TOKEN = credentials('telegram_token')
79
CHAT_ID = credentials('telegram_chatid')
810

9-
// Telegram message
11+
// Noi dung thong bao duoc tao tu commit hien tai.
1012
GIT_MESSAGE = sh(returnStdout: true, script: "git log -n 1 --format=%s ${GIT_COMMIT}").trim()
1113
GIT_AUTHOR = sh(returnStdout: true, script: "git log -n 1 --format=%ae ${GIT_COMMIT}").trim()
1214
GIT_COMMIT_SHORT = sh(returnStdout: true, script: "git rev-parse --short ${GIT_COMMIT}").trim()
@@ -26,6 +28,7 @@ pipeline {
2628
stages {
2729
stage('Build') {
2830
steps {
31+
// Build Docker image tu source hien tai.
2932
sh "curl --location --request POST 'https://api.telegram.org/bot${TOKEN}/sendMessage' --form text='${TEXT_PRE}' --form chat_id='${CHAT_ID}'"
3033
sh "curl --location --request POST 'https://api.telegram.org/bot${TOKEN}/sendMessage' --form text='${TEXT_BUILD}' --form chat_id='${CHAT_ID}'"
3134
sh 'docker build -t yamiannephilim/crm:latest .'
@@ -34,6 +37,7 @@ pipeline {
3437

3538
stage('Push') {
3639
steps {
40+
// Push image len Docker Hub voi credential da cau hinh trong Jenkins.
3741
sh "curl --location --request POST 'https://api.telegram.org/bot${TOKEN}/sendMessage' --form text='${TEXT_PUSH}' --form chat_id='${CHAT_ID}'"
3842

3943
withDockerRegistry(credentialsId: 'docker_hub', url: 'https://index.docker.io/v1/') {
@@ -44,6 +48,7 @@ pipeline {
4448

4549
stage('Clean') {
4650
steps {
51+
// Dung va xoa container crm cu neu dang ton tai.
4752
sh "curl --location --request POST 'https://api.telegram.org/bot${TOKEN}/sendMessage' --form text='${TEXT_CLEAN}' --form chat_id='${CHAT_ID}'"
4853

4954
script {
@@ -58,6 +63,7 @@ pipeline {
5863

5964
stage('Run') {
6065
steps {
66+
// Tao network neu can va chay container moi tu image latest.
6167
sh "curl --location --request POST 'https://api.telegram.org/bot${TOKEN}/sendMessage' --form text='${TEXT_RUN}' --form chat_id='${CHAT_ID}'"
6268
sh 'docker container stop crm || echo "this container does not exist"'
6369
sh 'docker network create yan || echo "this network exist"'

Procfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
web: java -jar target/crm_project-0.0.1-SNAPSHOT.war
1+
# Tom tat: Lenh chay WAR khi deploy len nen tang kieu Heroku.
2+
web: java -jar target/crm_project-0.0.1-SNAPSHOT.war

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
- Xem thống kê công việc (cá nhân)
3737
- Quản lý tài khoản cá nhân
3838

39-
## LINK DEMO
40-
<div align='center'>
41-
42-
[Click vào đây để xem chi tiết](https://crm.yamiannephilim.com)
43-
44-
</div>
45-
4639
## HÌNH ẢNH DEMO
4740
<p align='center'>
4841
<img src='pic/0.jpg'></img>

database/crm.sql

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
-- dispose db
1+
-- Tom tat: Script khoi tao database CRM gom role, user, du an, trang thai
2+
-- cong viec va du lieu mau de demo ung dung Spring Boot.
3+
4+
-- Xoa database cu de script co the chay lai tu dau.
25

36
DROP DATABASE IF EXISTS crm;
47

5-
-- create db
8+
-- Tao database crm neu chua ton tai.
69

710
CREATE DATABASE IF NOT EXISTS crm;
811

9-
-- use db
12+
-- Chon database lam viec.
1013

1114
USE crm;
1215

13-
-- fix default
16+
-- Dam bao AUTO_INCREMENT tang tung don vi trong moi lan seed.
1417
SET @@auto_increment_increment=1;
1518

16-
-- create table loai_thanh_vien
19+
-- Bang vai tro nguoi dung: Admin, Leader, Member.
1720

1821
CREATE TABLE
1922
IF NOT EXISTS loai_thanh_vien (
@@ -23,7 +26,7 @@ CREATE TABLE
2326
PRIMARY KEY (id)
2427
);
2528

26-
-- create table nguoi_dung
29+
-- Bang tai khoan nguoi dung va khoa ngoai den vai tro.
2730

2831
CREATE TABLE
2932
IF NOT EXISTS nguoi_dung (
@@ -39,7 +42,7 @@ CREATE TABLE
3942
FOREIGN KEY (id_loai_thanh_vien) REFERENCES loai_thanh_vien(id)
4043
);
4144

42-
-- create table du_an
45+
-- Bang du an, moi du an co nguoi tao/originator.
4346

4447
CREATE TABLE
4548
IF NOT EXISTS du_an (
@@ -53,7 +56,7 @@ CREATE TABLE
5356
FOREIGN KEY (id_nguoi_tao) REFERENCES nguoi_dung(id)
5457
);
5558

56-
-- create table trang_thai_cong_viec
59+
-- Bang danh muc trang thai cong viec.
5760

5861
CREATE TABLE
5962
IF NOT EXISTS trang_thai_cong_viec (
@@ -62,7 +65,7 @@ CREATE TABLE
6265
PRIMARY KEY (id)
6366
);
6467

65-
-- create table cong_viec
68+
-- Bang cong viec, lien ket user thuc hien, du an va trang thai.
6669

6770
CREATE TABLE
6871
IF NOT EXISTS cong_viec (
@@ -80,13 +83,13 @@ CREATE TABLE
8083
FOREIGN KEY (id_trang_thai_cong_viec) REFERENCES trang_thai_cong_viec(id)
8184
);
8285

83-
-- add data to loai_thanh_vien
86+
-- Seed vai tro mac dinh.
8487

8588
INSERT INTO
8689
loai_thanh_vien (ten, mo_ta)
8790
VALUES ('Admin', 'Quản trị viên'), ('Leader', 'Quản lý dự án'), ('Member', 'Thành viên');
8891

89-
-- add data to nguoi_dung
92+
-- Seed user mau; comment sau hash la mat khau plaintext dung cho demo local.
9093

9194
INSERT INTO
9295
nguoi_dung (
@@ -163,7 +166,7 @@ VALUES (
163166
3
164167
);
165168

166-
-- add data to du_an
169+
-- Seed du an mau.
167170

168171
INSERT INTO
169172
du_an (
@@ -193,13 +196,13 @@ VALUES (
193196
4
194197
);
195198

196-
-- add data to trang_thai_cong_viec
199+
-- Seed trang thai task mac dinh.
197200

198201
INSERT INTO
199202
trang_thai_cong_viec (ten)
200203
VALUES ('Chưa bắt đầu'), ('Đang thực hiện'), ('Đã hoàn thành');
201204

202-
-- add data to cong_viec
205+
-- Seed cong viec mau.
203206

204207
INSERT INTO
205208
cong_viec (

pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Tom tat: Maven project cho CRM Spring Boot MVC dong goi WAR, dung Thymeleaf,
4+
Spring Security, Spring Data JPA, MySQL, JWT va imgscalr.
5+
-->
26
<project xmlns="http://maven.apache.org/POM/4.0.0"
37
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -14,7 +18,7 @@
1418
<version>0.0.1-SNAPSHOT</version>
1519
<packaging>war</packaging>
1620
<name>crm_project</name>
17-
<description>Demo project for Spring Boot</description>
21+
<description>Spring Boot CRM web application with Thymeleaf, JPA, Security and JWT</description>
1822
<properties>
1923
<java.version>11</java.version>
2024
</properties>
@@ -194,4 +198,4 @@
194198
</plugins>
195199
</build>
196200

197-
</project>
201+
</project>

src/main/java/com/yan/crm_project/CrmProjApplication.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import org.springframework.boot.autoconfigure.*;
55

66
@SpringBootApplication
7+
/**
8+
* Tom tat: Diem khoi dong Spring Boot cho ung dung CRM.
9+
*/
710
public class CrmProjApplication {
811
public static void main(String[] args) {
912
SpringApplication.run(CrmProjApplication.class, args);

src/main/java/com/yan/crm_project/ServletInitializer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import org.springframework.boot.builder.*;
44
import org.springframework.boot.web.servlet.support.*;
55

6+
/**
7+
* Tom tat: Cho phep dong goi ung dung thanh WAR va chay tren servlet container
8+
* ben ngoai.
9+
*/
610
public class ServletInitializer extends SpringBootServletInitializer {
711
@Override
812
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

src/main/java/com/yan/crm_project/common/Bean.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/com/yan/crm_project/config/ApplicationConfig.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66
import org.springframework.security.web.savedrequest.*;
77

88
@Configuration
9+
/**
10+
* Tom tat: Khai bao cac bean ha tang dung chung cho bao mat va request cache.
11+
*/
912
public class ApplicationConfig {
10-
// Passord encode BCrypt
13+
/**
14+
* Ma hoa mat khau nguoi dung bang BCrypt truoc khi luu vao database.
15+
*/
1116
@Bean
1217
public PasswordEncoder passwordEncoder() {
1318
return new BCryptPasswordEncoder();
1419
}
1520

16-
// Request cache
21+
/**
22+
* Khong tao session moi chi de luu request truoc dang nhap.
23+
*/
1724
@Bean
1825
public HttpSessionRequestCache getHttpSessionRequestCache() {
1926
var httpSessionRequestCache = new HttpSessionRequestCache();

0 commit comments

Comments
 (0)