Skip to content

Commit 8d3b237

Browse files
authored
Merge pull request #1 from yyyCode/web-refactor
Web refactor
2 parents c665d9c + 004ca80 commit 8d3b237

230 files changed

Lines changed: 4952 additions & 2695 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.

.cursor/rules/rule.mdc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
alwaysApply: true
3+
---
4+
5+
前端规则:
6+
7+
任何前端代码的编写都要求和之前项目整体的前端的,字体大小风格,默认为不添加任何颜色
8+
9+
10+
后端规则:
11+
后端代码修改只修改要求的内容,不要做任何额外修改和处理
12+
13+
14+
项目设计:
15+
后端语言为java
16+
主框架为Springboot
17+
orm框架使用mybatis-plus

.gitattributes

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

.github/workflows/ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
push:
1414
branches:
1515
- master
16+
- web-refactor
1617

1718
jobs:
1819
build-and-deploy:
@@ -34,44 +35,51 @@ jobs:
3435
cache: "maven"
3536

3637
- name: Build backend (Maven)
37-
run: mvn -B -ntp package -DskipTests
38+
run: mvn -B -ntp package -DskipTests -pl OpenBlog-business -am
3839

3940
- name: Set up Node.js
4041
uses: actions/setup-node@v4
4142
with:
4243
node-version: "22"
4344
cache: "npm"
44-
cache-dependency-path: frontend/package-lock.json
45+
cache-dependency-path: vue/package-lock.json
4546

4647
- name: Install frontend dependencies and build
47-
working-directory: frontend
48+
working-directory: vue
4849
run: |
4950
npm ci
5051
npm run build
5152
5253
- name: Prepare release bundle for server
5354
run: |
5455
mkdir -p release
55-
cp -r frontend/dist release/dist
56-
cp frontend/Dockerfile frontend/docker.sh frontend/nginx.conf release/
56+
cp -r vue/dist release/dist
57+
cp vue/Dockerfile vue/docker.sh vue/nginx.conf release/
58+
59+
# 在 GitHub Runner 构建镜像并导出,避免国内服务器直连 Docker Hub 拉取 nginx:alpine 超时
60+
- name: Build Docker image on runner
61+
run: |
62+
docker build -t openblog-web release/
63+
docker save openblog-web | gzip > release/openblog-web.tar.gz
5764
5865
- name: Deploy files to server
5966
uses: easingthemes/ssh-deploy@v5.1.1
6067
with:
6168
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
6269
ARGS: "-rlgoDzvc --delete --exclude=dist/.user.ini"
63-
SOURCE: "release/dist release/Dockerfile release/docker.sh release/nginx.conf"
70+
SOURCE: "release/dist release/Dockerfile release/docker.sh release/nginx.conf release/openblog-web.tar.gz"
6471
REMOTE_HOST: ${{ secrets.SERVER_REMOTE_HOST }}
6572
REMOTE_USER: ${{ secrets.SERVER_REMOTE_USER }}
6673
TARGET: ${{ secrets.SERVER_TARGET }}
6774
SCRIPT_BEFORE: ls -la
6875

6976
- name: Run Docker commands on server
70-
uses: appleboy/ssh-action@v1
77+
uses: appleboy/ssh-action@v1.2.0
7178
with:
7279
host: ${{ secrets.SERVER_REMOTE_HOST }}
7380
username: ${{ secrets.SERVER_REMOTE_USER }}
7481
key: ${{ secrets.SERVER_SSH_KEY }}
82+
command_timeout: 30m
7583
script: |
7684
cd ${{ secrets.SERVER_TARGET }}
7785
sh docker.sh

.mvn/wrapper/maven-wrapper.properties

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

OpenBlog-business/.gitignore

Lines changed: 33 additions & 0 deletions
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/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip

OpenBlog-business/pom.xml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.yqz</groupId>
7+
<artifactId>OpenBlog</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>OpenBlog-business</artifactId>
12+
<name>OpenBlog-business</name>
13+
<description>OpenBlog business module</description>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.springframework.boot</groupId>
18+
<artifactId>spring-boot-starter-web</artifactId>
19+
</dependency>
20+
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-validation</artifactId>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-data-jpa</artifactId>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>com.mysql</groupId>
33+
<artifactId>mysql-connector-j</artifactId>
34+
<scope>runtime</scope>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-security</artifactId>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>com.baomidou</groupId>
44+
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
45+
<version>3.5.16</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.baomidou</groupId>
49+
<artifactId>mybatis-plus-jsqlparser</artifactId>
50+
<version>3.5.16</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-starter-data-redis</artifactId>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>io.jsonwebtoken</groupId>
60+
<artifactId>jjwt-api</artifactId>
61+
<version>0.12.5</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>io.jsonwebtoken</groupId>
65+
<artifactId>jjwt-impl</artifactId>
66+
<version>0.12.5</version>
67+
<scope>runtime</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>io.jsonwebtoken</groupId>
71+
<artifactId>jjwt-jackson</artifactId>
72+
<version>0.12.5</version>
73+
<scope>runtime</scope>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>com.github.ben-manes.caffeine</groupId>
78+
<artifactId>caffeine</artifactId>
79+
<version>3.1.8</version>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>net.coobird</groupId>
84+
<artifactId>thumbnailator</artifactId>
85+
<version>0.4.20</version>
86+
</dependency>
87+
88+
<dependency>
89+
<groupId>org.projectlombok</groupId>
90+
<artifactId>lombok</artifactId>
91+
<optional>true</optional>
92+
</dependency>
93+
94+
<dependency>
95+
<groupId>org.springframework.boot</groupId>
96+
<artifactId>spring-boot-starter-test</artifactId>
97+
<scope>test</scope>
98+
</dependency>
99+
</dependencies>
100+
101+
<build>
102+
<plugins>
103+
<plugin>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-maven-plugin</artifactId>
106+
<executions>
107+
<execution>
108+
<goals>
109+
<goal>repackage</goal>
110+
</goals>
111+
</execution>
112+
</executions>
113+
<configuration>
114+
<mainClass>com.yqz.openblog.OpenBlogApplication</mainClass>
115+
</configuration>
116+
</plugin>
117+
</plugins>
118+
</build>
119+
120+
</project>

src/main/java/com/yqz/openblog/OpenBlogApplication.java renamed to OpenBlog-business/src/main/java/com/yqz/openblog/OpenBlogApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import org.springframework.boot.SpringApplication;
88
import org.springframework.boot.autoconfigure.SpringBootApplication;
99
import org.springframework.boot.context.properties.EnableConfigurationProperties;
10+
import org.springframework.scheduling.annotation.EnableScheduling;
1011

1112
@SpringBootApplication
13+
@EnableScheduling
1214
@EnableConfigurationProperties({
1315
SiteProperties.class,
1416
CorsProperties.class,

src/main/java/com/yqz/openblog/article/controller/ArticleController.java renamed to OpenBlog-business/src/main/java/com/yqz/openblog/article/controller/ArticleController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import jakarta.validation.Valid;
1515

16-
16+
import org.springframework.security.access.prepost.PreAuthorize;
1717
import org.springframework.web.bind.annotation.*;
1818
import jakarta.servlet.http.HttpServletRequest;
1919

@@ -45,40 +45,46 @@ public ApiResponse<ArticleDetailResponse> detailPublished(@PathVariable("article
4545
}
4646

4747
@PostMapping("/articles")
48+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
4849
public ApiResponse<ArticleListItemResponse> createDraft(@RequestBody @Valid ArticleCreateRequest req) {
4950
Long uid = currentUser.userId();
5051
return ApiResponse.ok(articleService.createDraft(uid, req));
5152
}
5253

5354
@PutMapping("/articles/{articleId}")
55+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
5456
public ApiResponse<ArticleListItemResponse> updateArticle(@PathVariable("articleId") Long articleId,
5557
@RequestBody @Valid ArticleUpdateRequest req) {
5658
Long uid = currentUser.userId();
5759
return ApiResponse.ok(articleService.updateArticle(uid, articleId, req));
5860
}
5961

6062
@PostMapping("/articles/{articleId}/publish")
63+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
6164
public ApiResponse<ArticleListItemResponse> submitForReview(@PathVariable("articleId") Long articleId,
6265
@RequestBody(required = false) ArticlePublishRequest req) {
6366
Long uid = currentUser.userId();
6467
return ApiResponse.ok(articleService.publish(uid, articleId, req == null ? null : req.getPublishedAt()));
6568
}
6669

6770
@PostMapping("/articles/{articleId}/unpublish")
71+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
6872
public ApiResponse<Void> unpublish(@PathVariable("articleId") Long articleId) {
6973
Long uid = currentUser.userId();
7074
articleService.unpublishOrDelete(uid, articleId);
7175
return ApiResponse.ok();
7276
}
7377

7478
@DeleteMapping("/articles/{articleId}")
79+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
7580
public ApiResponse<Void> deleteArticle(@PathVariable("articleId") Long articleId) {
7681
Long uid = currentUser.userId();
7782
articleService.unpublishOrDelete(uid, articleId);
7883
return ApiResponse.ok();
7984
}
8085

8186
@GetMapping("/users/me/articles")
87+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
8288
public ApiResponse<PageResult<ArticleListItemResponse>> listMine(
8389
@RequestParam(defaultValue = "0") int page,
8490
@RequestParam(defaultValue = "20") int size) {
@@ -87,6 +93,7 @@ public ApiResponse<PageResult<ArticleListItemResponse>> listMine(
8793
}
8894

8995
@GetMapping("/users/me/articles/{articleId}")
96+
@PreAuthorize("hasAnyRole('ADMIN','AUTHOR')")
9097
public ApiResponse<ArticleDetailResponse> detailMine(@PathVariable("articleId") Long articleId,
9198
HttpServletRequest request) {
9299
Long uid = currentUser.userId();

src/main/java/com/yqz/openblog/article/dto/ArticleCreateRequest.java renamed to OpenBlog-business/src/main/java/com/yqz/openblog/article/dto/ArticleCreateRequest.java

File renamed without changes.

0 commit comments

Comments
 (0)