Compare commits
36 Commits
master-old
...
feat-multl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d462cc876 | ||
|
|
ec96a787ef | ||
|
|
91de56cb32 | ||
|
|
e2a3fb6a6c | ||
|
|
49ff1865bb | ||
|
|
b920034ad6 | ||
|
|
76f3d16e09 | ||
|
|
9dafc6d5a7 | ||
|
|
ec693da079 | ||
|
|
58498ef225 | ||
|
|
c56a3eaf83 | ||
|
|
e0abfb7d70 | ||
|
|
96cb2dcee4 | ||
|
|
e39763ad0c | ||
|
|
a3edc00a03 | ||
|
|
c0687b4776 | ||
|
|
b3b3a7a908 | ||
|
|
56efdc44d7 | ||
|
|
e4684e6150 | ||
|
|
65d65221e8 | ||
|
|
47df223655 | ||
|
|
fa95f2f69e | ||
|
|
5598804ddc | ||
|
|
ed7d18d491 | ||
|
|
2fbe030da9 | ||
|
|
5f3cbece7b | ||
|
|
4942daf900 | ||
|
|
9f070169b4 | ||
|
|
4fa114eb1e | ||
|
|
431ce8ac28 | ||
|
|
49000e9ee6 | ||
|
|
19068ff14d | ||
|
|
3d0253a35a | ||
|
|
0283bd11dc | ||
|
|
60347c7629 | ||
|
|
8de0cbded8 |
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@@ -1,12 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "maven" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
30
.github/workflows/build.yml
vendored
30
.github/workflows/build.yml
vendored
@@ -1,23 +1,21 @@
|
|||||||
|
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
||||||
|
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
|
||||||
|
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches:
|
||||||
paths-ignore:
|
- master
|
||||||
- "doc/**"
|
|
||||||
- "**/README.md"
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
paths-ignore:
|
|
||||||
- "doc/**"
|
|
||||||
- "**/README.md"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: "!contains(github.event.head_commit.message, '[skip ci]')" # 如果 commit 信息包含以下关键字则跳过该任务
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
KEY: ${{ secrets.WEB_HOOK_ACCESS_KEY }}
|
KEY: ${{ secrets.WEB_HOOK_ACCESS_KEY }}
|
||||||
|
QINIU_ACCESSKEY: ${{ secrets.QINIU_ACCESSKEY }}
|
||||||
|
QINIU_SECRETKEY: ${{ secrets.QINIU_SECRETKEY }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -26,13 +24,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 1.8
|
||||||
|
|
||||||
- name: Cache local Maven repository
|
- name: Deploy
|
||||||
uses: actions/cache@v2
|
run: mvn -B test --file pom.xml && curl http://bt.celess.cn:2271/hook?access_key=$KEY
|
||||||
with:
|
|
||||||
path: ~/.m2/repository
|
|
||||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-maven-
|
|
||||||
|
|
||||||
- name: Unit Test
|
|
||||||
run: mvn package -B -pl blog-deploy -am
|
|
||||||
|
|||||||
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# 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.
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 14 * * 2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# Override automatic language detection by changing the below list
|
||||||
|
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||||
|
language: ['java']
|
||||||
|
# Learn more...
|
||||||
|
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# We must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event, then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
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.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, 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@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
22
.github/workflows/sync.yml
vendored
22
.github/workflows/sync.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
name: Sync Repository Action
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
schedule:
|
|
||||||
# 每周一0:00
|
|
||||||
- cron: '0 0 * * 1'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Sync to Gitee
|
|
||||||
uses: x-dr/sync-repo-to-gitee@master
|
|
||||||
env:
|
|
||||||
# 在 Settings->Secrets 配置 GITEE_KEY
|
|
||||||
SSH_KEY: ${{ secrets.GITEE_KEY }}
|
|
||||||
with:
|
|
||||||
# GitHub存储库的SSH URL.
|
|
||||||
github-repo: git@github.com:xiaohai2271/blog-backEnd.git
|
|
||||||
# Gitee存储库的SSH URL.
|
|
||||||
gitee-repo: git@gitee.com:xiaohai2271/blog-backEnd.git
|
|
||||||
29
.github/workflows/test.yml
vendored
Normal file
29
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
||||||
|
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
|
||||||
|
|
||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
QINIU_ACCESSKEY: ${{ secrets.QINIU_ACCESSKEY }}
|
||||||
|
QINIU_SECRETKEY: ${{ secrets.QINIU_SECRETKEY }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: mvn -B test --file pom.xml
|
||||||
|
|
||||||
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,5 +4,5 @@
|
|||||||
target/
|
target/
|
||||||
|
|
||||||
# 本地项目的私有文件
|
# 本地项目的私有文件
|
||||||
blog-deploy/src/main/resources/application-dev.properties
|
src/main/resources/application-dev.properties
|
||||||
src/main/resources/application-prod.properties
|
src/main/resources/application-prod.properties
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-article</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--MarkDown 2 html -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.youbenzi</groupId>
|
|
||||||
<artifactId>MDTool</artifactId>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.minidev</groupId>
|
|
||||||
<artifactId>json-smart</artifactId>
|
|
||||||
<version>2.4.7</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package cn.celess.article;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {ArticleApplication.class, CommonApplication.class, UserApplication.class})
|
|
||||||
public class ArticleApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(ArticleApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _ _
|
|
||||||
| | | | (_) | _ \ | | /\ | | (_) | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ / \ _ __ | |_ _ ___ | | ___
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| / /\ \ | '__| | __| | | / __| | | / _ \
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | / ____ \ | | | |_ | | | (__ | | | __/
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | /_/ \_\ |_| \__| |_| \___| |_| \___|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.article;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseRedisTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = {ArticleApplication.class})
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class ArticleBaseTest extends BaseRedisTest {
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package cn.celess.article.serviceimpl;
|
|
||||||
|
|
||||||
import cn.celess.article.ArticleBaseTest;
|
|
||||||
import cn.celess.common.entity.vo.ArticleModel;
|
|
||||||
import cn.celess.common.entity.vo.PageData;
|
|
||||||
import cn.celess.common.mapper.ArticleMapper;
|
|
||||||
import cn.celess.common.service.ArticleService;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class ArticleServiceTest extends ArticleBaseTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
ArticleService articleService;
|
|
||||||
@Resource
|
|
||||||
ArticleMapper articleMapper;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void adminArticles() {
|
|
||||||
// 测deleted参数传值
|
|
||||||
PageData<ArticleModel> pageData = articleService.adminArticles(10, 1, true);
|
|
||||||
assertTrue(pageData.getList().stream().allMatch(ArticleModel::isDeleted));
|
|
||||||
pageData = articleService.adminArticles(10, 1, false);
|
|
||||||
assertFalse(pageData.getList().stream().allMatch(ArticleModel::isDeleted));
|
|
||||||
pageData = articleService.adminArticles(10, 1, null);
|
|
||||||
assertTrue(pageData.getList().stream().anyMatch(ArticleModel::isDeleted));
|
|
||||||
assertTrue(pageData.getList().stream().anyMatch(articleModel -> !articleModel.isDeleted()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void retrievePageForOpen() {
|
|
||||||
PageData<ArticleModel> articleModelPageData = articleService.retrievePageForOpen(10, 1);
|
|
||||||
assertEquals(10, articleModelPageData.getPageSize());
|
|
||||||
assertEquals(1, articleModelPageData.getPageNum());
|
|
||||||
assertEquals(10, articleModelPageData.getList().size());
|
|
||||||
articleModelPageData.getList().forEach(Assert::assertNotNull);
|
|
||||||
|
|
||||||
// 测试open字段
|
|
||||||
articleModelPageData.getList().forEach(articleModel -> {
|
|
||||||
// 当前文章
|
|
||||||
assertTrue(articleMapper.findArticleById(articleModel.getId()).getOpen());
|
|
||||||
if (articleModel.getPreArticle() != null) {
|
|
||||||
assertTrue(articleMapper.findArticleById(articleModel.getPreArticle().getId()).getOpen());
|
|
||||||
}
|
|
||||||
if (articleModel.getNextArticle() != null) {
|
|
||||||
assertTrue(articleMapper.findArticleById(articleModel.getNextArticle().getId()).getOpen());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-categorytag</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package cn.celess.categorytag;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {CategoryTagApplication.class, CommonApplication.class, UserApplication.class})
|
|
||||||
public class CategoryTagApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(CategoryTagApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _______
|
|
||||||
| | | | (_) | _ \ | | |__ __|
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ | | __ _ __ _
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _` | / _` |
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | | | (_| | | (_| |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | |_| \__,_| \__, |
|
|
||||||
__/ | __/ |
|
|
||||||
|___/ |___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.categorytag;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = {CategoryTagApplication.class})
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class CategoryTagBaseTest extends BaseTest {
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-comment</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package cn.celess.comment;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {CommentApplication.class, CommonApplication.class, UserApplication.class})
|
|
||||||
public class CommentApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(CommentApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _____ _
|
|
||||||
| | | | (_) | _ \ | | / ____| | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ | | ___ _ __ ___ _ __ ___ ___ _ __ | |_
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _ \ | '_ ` _ \ | '_ ` _ \ / _ \ | '_ \ | __|
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | |____ | (_) | | | | | | | | | | | | | | __/ | | | | | |_
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | \_____| \___/ |_| |_| |_| |_| |_| |_| \___| |_| |_| \__|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.comment;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = {CommentApplication.class})
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class CommentBaseTest extends BaseTest {
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-resource</artifactId>
|
|
||||||
<version>${blog-resource.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.kstyrc</groupId>
|
|
||||||
<artifactId>embedded-redis</artifactId>
|
|
||||||
<version>0.6</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid</artifactId>
|
|
||||||
<version>1.2.8</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun</groupId>
|
|
||||||
<artifactId>jconsole</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun</groupId>
|
|
||||||
<artifactId>tools</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mybatis -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mybatis.spring.boot</groupId>
|
|
||||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
|
||||||
<version>2.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- pageHelper -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.pagehelper</groupId>
|
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
|
||||||
<version>1.4.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!--Email-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- TODO: remove this -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.qiniu</groupId>
|
|
||||||
<artifactId>qiniu-java-sdk</artifactId>
|
|
||||||
<version>[7.2.0, 7.2.99]</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- redis -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sourceforge.htmlunit</groupId>
|
|
||||||
<artifactId>htmlunit</artifactId>
|
|
||||||
<version>2.45.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- protostuff序列化依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.dyuproject.protostuff</groupId>
|
|
||||||
<artifactId>protostuff-core</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.dyuproject.protostuff</groupId>
|
|
||||||
<artifactId>protostuff-runtime</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package cn.celess.common;
|
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.FilterType;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
|
|
||||||
@SpringBootApplication(
|
|
||||||
scanBasePackageClasses = {
|
|
||||||
CommonApplication.class
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = "cn.celess.common.test.BaseRedisTest")})
|
|
||||||
@MapperScan("cn.celess.common.mapper")
|
|
||||||
public class CommonApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(CommonApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package cn.celess.common.config;
|
|
||||||
|
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
|
||||||
import org.springframework.boot.logging.DeferredLog;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class CommonEnvPostProcessor implements EnvironmentPostProcessor, ApplicationListener<ApplicationEvent>, Ordered {
|
|
||||||
public static final DeferredLog log = new DeferredLog();
|
|
||||||
|
|
||||||
private static final String CONFIG_PATH = "/HBlog/config/blog.properties";
|
|
||||||
private static final String SOURCE_NAME = "localize";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) {
|
|
||||||
|
|
||||||
EnvironmentUtil.setEnvironment(configurableEnvironment);
|
|
||||||
|
|
||||||
log.info("加载本地配置文件--");
|
|
||||||
//获取环境变量
|
|
||||||
String homeEnv = EnvironmentUtil.getEnv("BLOG_HOME", EnvironmentUtil.getEnv("USERPROFILE"));
|
|
||||||
String configPath = (homeEnv + CONFIG_PATH).replaceAll("[\\|/]+", Matcher.quoteReplacement(File.separator));
|
|
||||||
try (InputStream input = new FileInputStream(configPath)) {
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.load(input);
|
|
||||||
PropertiesPropertySource propertySource = new PropertiesPropertySource(SOURCE_NAME, properties);
|
|
||||||
configurableEnvironment.getPropertySources().addLast(propertySource);
|
|
||||||
log.info("成功加载本地配置文件:)");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("加载本地[" + configPath + "]的配置文件失败:(");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onApplicationEvent(ApplicationEvent event) {
|
|
||||||
log.replayTo(CommonEnvPostProcessor.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package cn.celess.common.entity.vo;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2019/04/21 22:43
|
|
||||||
*/
|
|
||||||
public class QiniuResponse implements Serializable {
|
|
||||||
public String key;
|
|
||||||
public String hash;
|
|
||||||
public String bucket;
|
|
||||||
public long fsize;
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package cn.celess.common.service;
|
|
||||||
|
|
||||||
import cn.celess.common.entity.vo.QiniuResponse;
|
|
||||||
import com.qiniu.storage.model.FileInfo;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2019/04/25 18:15
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public interface QiniuService {
|
|
||||||
/**
|
|
||||||
* 上传文件
|
|
||||||
*
|
|
||||||
* @param is InputStream流
|
|
||||||
* @param fileName 文件名
|
|
||||||
* @return 响应数据
|
|
||||||
*/
|
|
||||||
QiniuResponse uploadFile(InputStream is, String fileName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件列表
|
|
||||||
*
|
|
||||||
* @return 文件列表
|
|
||||||
*/
|
|
||||||
FileInfo[] getFileList();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package cn.celess.common.test;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import redis.embedded.RedisServer;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2020/08/14 16:20
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@Slf4j
|
|
||||||
public class BaseRedisTest extends BaseTest {
|
|
||||||
private static RedisServer redisServer;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public static void startRedis() {
|
|
||||||
try {
|
|
||||||
if (redisServer == null) {
|
|
||||||
redisServer = new RedisServer(6380);
|
|
||||||
redisServer.start();
|
|
||||||
log.info("start Redis success");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("start Redis failed");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreDestroy()
|
|
||||||
public static void stopRedis() {
|
|
||||||
if (redisServer.isActive()) {
|
|
||||||
redisServer.stop();
|
|
||||||
log.info("stop Redis success");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package cn.celess.common.util;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class EnvironmentUtil {
|
|
||||||
|
|
||||||
private static Environment environment;
|
|
||||||
|
|
||||||
public static String getEnv(String name) {
|
|
||||||
String value = System.getenv(name);
|
|
||||||
if (StringUtils.isBlank(value)) {
|
|
||||||
log.error("没有找到环境变量:" + name);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getEnv(String name, String defaultValue) {
|
|
||||||
String env = getEnv(name);
|
|
||||||
if (env == null) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getProperties(String key) {
|
|
||||||
String value = environment.getProperty(key);
|
|
||||||
if (StringUtils.isBlank(value)) {
|
|
||||||
log.error("没有找到配置项: {}", key);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getProperties(String key, String defaultValue) {
|
|
||||||
return environment.getProperty(key, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setEnvironment(Environment environment) {
|
|
||||||
EnvironmentUtil.environment = environment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package cn.celess.common.util;
|
|
||||||
|
|
||||||
import org.springframework.util.DigestUtils;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2019/03/28 17:21
|
|
||||||
*/
|
|
||||||
public class StringUtil {
|
|
||||||
/**
|
|
||||||
* 从html中提取纯文本
|
|
||||||
*
|
|
||||||
* @param html html string
|
|
||||||
* @return 纯文本
|
|
||||||
*/
|
|
||||||
public static String getString(String html) {
|
|
||||||
//剔出<html>的标签
|
|
||||||
String txtcontent = html.replaceAll("</?[^>]+>", "");
|
|
||||||
//去除字符串中的空格,回车,换行符,制表符
|
|
||||||
txtcontent = txtcontent.replaceAll("<a>\\s*|\t|\r|\n</a>", "");
|
|
||||||
return txtcontent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成MD5
|
|
||||||
*
|
|
||||||
* @param str 源数据
|
|
||||||
* @return md5 内容
|
|
||||||
*/
|
|
||||||
public static String getMD5(String str) {
|
|
||||||
return DigestUtils.md5DigestAsHex(str.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCompleteUrlAndMethod(HttpServletRequest request) {
|
|
||||||
// like this : GET:/articles?page=1&count=5
|
|
||||||
return request.getMethod() + ":" + request.getRequestURI() +
|
|
||||||
(request.getQueryString() == null ? "" : "?" + request.getQueryString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.env.EnvironmentPostProcessor=cn.celess.common.config.CommonEnvPostProcessor
|
|
||||||
org.springframework.context.ApplicationListener=cn.celess.common.config.CommonEnvPostProcessor
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _____
|
|
||||||
| | | | (_) | _ \ | | / ____|
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ | | ___ _ __ ___ _ __ ___ ___ _ __
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _ \ | '_ ` _ \ | '_ ` _ \ / _ \ | '_ \
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | |____ | (_) | | | | | | | | | | | | | | (_) | | | | |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | \_____| \___/ |_| |_| |_| |_| |_| |_| \___/ |_| |_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.common;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = CommonApplication.class)
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class CommonBaseTest extends BaseTest {
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package cn.celess.common.util;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonBaseTest;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class StringUtilTest extends CommonBaseTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMD5() {
|
|
||||||
assertEquals("25f9e794323b453885f5181f1b624d0b", StringUtil.getMD5("123456789"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-deploy</artifactId>
|
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<!-- Swagger -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
|
||||||
<version>1.9.6</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-article</artifactId>
|
|
||||||
<version>${blog-article.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-categorytag</artifactId>
|
|
||||||
<version>${blog-categorytag.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-comment</artifactId>
|
|
||||||
<version>${blog-comment.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-extension</artifactId>
|
|
||||||
<version>${blog-extension.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-partnersite</artifactId>
|
|
||||||
<version>${blog-partnersite.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-siteinfo</artifactId>
|
|
||||||
<version>${blog-siteinfo.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-visitor</artifactId>
|
|
||||||
<version>${blog-visitor.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>2.5.6</version>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>cn.celess.BlogApplication</mainClass>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package cn.celess;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.FilterType;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@EnableAsync
|
|
||||||
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = "cn.celess.common.test.BaseRedisTest")})
|
|
||||||
public class BlogApplication {
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(BlogApplication.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(BlogApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
logger.info("启动完成!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package cn.celess.configuration;
|
|
||||||
|
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2019/03/28 14:26
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class DruidConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DruidDataSource druidDataSource() {
|
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
|
||||||
dataSource.setDriverClassName(EnvironmentUtil.getProperties("spring.datasource.driver-class-name"));
|
|
||||||
// 数据库基本信息
|
|
||||||
dataSource.setUrl(EnvironmentUtil.getProperties("spring.datasource.url"));
|
|
||||||
dataSource.setUsername(EnvironmentUtil.getProperties("spring.datasource.username"));
|
|
||||||
dataSource.setPassword(EnvironmentUtil.getProperties("spring.datasource.password"));
|
|
||||||
|
|
||||||
// 数据库连接池配置
|
|
||||||
dataSource.setInitialSize(10);
|
|
||||||
dataSource.setMinIdle(10);
|
|
||||||
dataSource.setMaxActive(100);
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _
|
|
||||||
| | | | (_) | _ \ | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _
|
|
||||||
| __ | | | | _ < | | / _ \ / _` |
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, |
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = {BlogApplication.class})
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class DeployBaseTest extends BaseTest {
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-extension</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 七牛云SDK -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.qiniu</groupId>
|
|
||||||
<artifactId>qiniu-java-sdk</artifactId>
|
|
||||||
<version>[7.2.0, 7.2.99]</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--Email-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package cn.celess.extension;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {ExtensionApplication.class, CommonApplication.class})
|
|
||||||
public class ExtensionApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(ExtensionApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package cn.celess.extension.serviceimpl;
|
|
||||||
|
|
||||||
import cn.celess.common.entity.vo.QiniuResponse;
|
|
||||||
import cn.celess.common.service.QiniuService;
|
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
|
||||||
import com.qiniu.common.QiniuException;
|
|
||||||
import com.qiniu.common.Zone;
|
|
||||||
import com.qiniu.http.Response;
|
|
||||||
import com.qiniu.storage.BucketManager;
|
|
||||||
import com.qiniu.storage.Configuration;
|
|
||||||
import com.qiniu.storage.UploadManager;
|
|
||||||
import com.qiniu.storage.model.FileInfo;
|
|
||||||
import com.qiniu.util.Auth;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : xiaohai
|
|
||||||
* @date : 2019/04/25 18:15
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class QiniuServiceImpl implements QiniuService {
|
|
||||||
private static final Configuration cfg = new Configuration(Zone.zone2());
|
|
||||||
private static UploadManager uploadManager;
|
|
||||||
private static BucketManager bucketManager;
|
|
||||||
private static Auth auth;
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
String accessKey = EnvironmentUtil.getProperties("qiniu.accessKey");
|
|
||||||
String secretKey = EnvironmentUtil.getProperties("qiniu.secretKey");
|
|
||||||
if (auth == null || uploadManager == null || bucketManager == null) {
|
|
||||||
auth = Auth.create(accessKey, secretKey);
|
|
||||||
uploadManager = new UploadManager(cfg);
|
|
||||||
bucketManager = new BucketManager(auth, cfg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QiniuResponse uploadFile(InputStream is, String fileName) {
|
|
||||||
init();
|
|
||||||
String bucket = EnvironmentUtil.getProperties("qiniu.bucket");
|
|
||||||
//文件存在则删除文件
|
|
||||||
if (continueFile(fileName)) {
|
|
||||||
try {
|
|
||||||
System.out.println(bucketManager.delete(bucket, fileName).toString());
|
|
||||||
} catch (QiniuException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//上传
|
|
||||||
try {
|
|
||||||
Response response = uploadManager.put(is, fileName, auth.uploadToken(bucket), null, null);
|
|
||||||
return response.jsonToObject(QiniuResponse.class);
|
|
||||||
} catch (QiniuException e) {
|
|
||||||
Response r = e.response;
|
|
||||||
System.err.println(r.toString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileInfo[] getFileList() {
|
|
||||||
init();
|
|
||||||
String bucket = EnvironmentUtil.getProperties("qiniu.bucket");
|
|
||||||
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucket, "", 1000, "");
|
|
||||||
FileInfo[] items = null;
|
|
||||||
while (fileListIterator.hasNext()) {
|
|
||||||
//处理获取的file list结果
|
|
||||||
items = fileListIterator.next();
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean continueFile(String key) {
|
|
||||||
FileInfo[] allFile = getFileList();
|
|
||||||
for (FileInfo fileInfo : allFile) {
|
|
||||||
if (key.equals(fileInfo.key)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _
|
|
||||||
| | | | (_) | _ \ | | | | (_)
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ ___ __ __ | |_ ___ _ __ ___ _ ___ _ __
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| / _ \ \ \/ / | __| / _ \ | '_ \ / __| | | / _ \ | '_ \
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | __/ > < | |_ | __/ | | | | \__ \ | | | (_) | | | | |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | \___| /_/\_\ \__| \___| |_| |_| |___/ |_| \___/ |_| |_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-partnersite</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- OkHttp -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>4.9.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.jetbrains.kotlin</groupId>-->
|
|
||||||
<!-- <artifactId>kotlin-stdlib</artifactId>-->
|
|
||||||
<!-- <version>1.4.20</version>-->
|
|
||||||
<!-- <scope>compile</scope>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sourceforge.htmlunit</groupId>
|
|
||||||
<artifactId>htmlunit</artifactId>
|
|
||||||
<version>2.45.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package cn.celess.partnersite;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {PartnerSiteApplication.class, CommonApplication.class, UserApplication.class})
|
|
||||||
public class PartnerSiteApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(PartnerSiteApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _ _
|
|
||||||
| | | | (_) | _ \ | | | | (_) | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ _ __ __ _ _ __ | |_ _ __ ___ _ __ ___ _ | |_ ___
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| | '_ \ / _` | | '__| | __| | '_ \ / _ \ | '__| / __| | | | __| / _ \
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | |_) | | (_| | | | | |_ | | | | | __/ | | \__ \ | | | |_ | __/
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | | .__/ \__,_| |_| \__| |_| |_| \___| |_| |___/ |_| \__| \___|
|
|
||||||
__/ | | |
|
|
||||||
|___/ |_|
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.partnersite;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseRedisTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = PartnerSiteApplication.class)
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class PartnerSiteBaseTest extends BaseRedisTest {
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-resource</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>13</maven.compiler.source>
|
|
||||||
<maven.compiler.target>13</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-siteinfo</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package cn.celess.siteinfo;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {SiteInfoApplication.class, CommonApplication.class, UserApplication.class})
|
|
||||||
public class SiteInfoApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(SiteInfoApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _ _ __
|
|
||||||
| | | | (_) | _ \ | | (_) | | (_) / _|
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ ___ _ | |_ ___ _ _ __ | |_ ___
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| / __| | | | __| / _ \ | | | '_ \ | _| / _ \
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | \__ \ | | | |_ | __/ | | | | | | | | | (_) |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | |___/ |_| \__| \___| |_| |_| |_| |_| \___/
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.siteinfo;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = SiteInfoApplication.class)
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class SiteInfoBaseTest extends BaseTest {
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JJwt -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
<version>0.9.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
<version>2.3.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-impl</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-core</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.activation</groupId>
|
|
||||||
<artifactId>activation</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package cn.celess.user;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {UserApplication.class, CommonApplication.class})
|
|
||||||
public class UserApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(UserApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package cn.celess.user.config;
|
|
||||||
|
|
||||||
import cn.celess.user.filter.AuthenticationFilter;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: 小海
|
|
||||||
* @Date: 2019/10/18 14:19
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class AuthorizationInterceptorConfig implements WebMvcConfigurer {
|
|
||||||
@Override
|
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
|
||||||
registry.addInterceptor(authenticationFilter()).addPathPatterns("/**");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AuthenticationFilter authenticationFilter() {
|
|
||||||
return new AuthenticationFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _
|
|
||||||
| | | | (_) | _ \ | | | | | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ | | | | ___ ___ _ __
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| | | | | / __| / _ \ | '__|
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | | |__| | \__ \ | __/ | |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | \____/ |___/ \___| |_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package cn.celess.user;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseRedisTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Component
|
|
||||||
public abstract class UserBaseTest extends BaseRedisTest {
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>blog</artifactId>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>blog-visitor</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-common</artifactId>
|
|
||||||
<version>${blog-common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-user</artifactId>
|
|
||||||
<version>${blog-user.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.celess</groupId>
|
|
||||||
<artifactId>blog-extension</artifactId>
|
|
||||||
<version>${blog-extension.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Ua解析-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.bitwalker</groupId>
|
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
|
||||||
<version>1.21</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
<version>1.7.2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package cn.celess.visitor;
|
|
||||||
|
|
||||||
import cn.celess.common.CommonApplication;
|
|
||||||
import cn.celess.extension.ExtensionApplication;
|
|
||||||
import cn.celess.user.UserApplication;
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.core.SpringVersion;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackageClasses = {
|
|
||||||
VisitorApplication.class,
|
|
||||||
CommonApplication.class,
|
|
||||||
ExtensionApplication.class,
|
|
||||||
UserApplication.class
|
|
||||||
})
|
|
||||||
public class VisitorApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new SpringApplicationBuilder(VisitorApplication.class)
|
|
||||||
.main(SpringVersion.class)
|
|
||||||
.bannerMode(Banner.Mode.CONSOLE)
|
|
||||||
.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
${AnsiColor.BRIGHT_GREEN}
|
|
||||||
_ _ _ ____ _ _ _ _
|
|
||||||
| | | | (_) | _ \ | | (_) (_) | |
|
|
||||||
| |__| | _ | |_) | | | ___ __ _ ______ __ __ _ ___ _ | |_ ___ _ __
|
|
||||||
| __ | | | | _ < | | / _ \ / _` | |______| \ \ / / | | / __| | | | __| / _ \ | '__|
|
|
||||||
| | | | | | | |_) | | | | (_) | | (_| | \ V / | | \__ \ | | | |_ | (_) | | |
|
|
||||||
|_| |_| |_| |____/ |_| \___/ \__, | \_/ |_| |___/ |_| \__| \___/ |_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${AnsiColor.BRIGHT_RED}
|
|
||||||
Application Version: ${application.version}${application.formatted-version}
|
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.celess.visitor;
|
|
||||||
|
|
||||||
import cn.celess.common.test.BaseRedisTest;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = VisitorApplication.class)
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
public abstract class VisitorBaseTest extends BaseRedisTest {
|
|
||||||
}
|
|
||||||
299
doc/API.md
299
doc/API.md
@@ -1411,6 +1411,78 @@
|
|||||||
| 401 | Unauthorized ||
|
| 401 | Unauthorized ||
|
||||||
| 403 | Forbidden ||
|
| 403 | Forbidden ||
|
||||||
| 404 | Not Found ||
|
| 404 | Not Found ||
|
||||||
|
## fileUpload
|
||||||
|
|
||||||
|
|
||||||
|
**接口描述**:
|
||||||
|
|
||||||
|
|
||||||
|
**接口地址**:`/fileUpload`
|
||||||
|
|
||||||
|
|
||||||
|
**请求方式**:`POST`
|
||||||
|
|
||||||
|
|
||||||
|
**consumes**:`["application/json"]`
|
||||||
|
|
||||||
|
|
||||||
|
**produces**:`["*/*"]`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
|
||||||
|
| ------------ | -------------------------------- |-----------|--------|----|--- |
|
||||||
|
|file[]| file[] | formData | true |array | file |
|
||||||
|
|
||||||
|
**响应示例**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"result": [
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应参数**:
|
||||||
|
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | -------------------|-------|----------- |
|
||||||
|
|code| |integer(int32) | integer(int32) |
|
||||||
|
|msg| |string | |
|
||||||
|
|result| |array | Map«string,object» |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**schema属性说明**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Map«string,object»**
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | ------------------|--------|----------- |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**响应状态**:
|
||||||
|
|
||||||
|
|
||||||
|
| 状态码 | 说明 | schema |
|
||||||
|
| ------------ | -------------------------------- |---------------------- |
|
||||||
|
| 200 | OK |Response«List«Map«string,object»»»|
|
||||||
|
| 201 | Created ||
|
||||||
|
| 401 | Unauthorized ||
|
||||||
|
| 403 | Forbidden ||
|
||||||
|
| 404 | Not Found ||
|
||||||
## headerInfo
|
## headerInfo
|
||||||
|
|
||||||
|
|
||||||
@@ -1623,6 +1695,231 @@
|
|||||||
| 401 | Unauthorized ||
|
| 401 | Unauthorized ||
|
||||||
| 403 | Forbidden ||
|
| 403 | Forbidden ||
|
||||||
| 404 | Not Found ||
|
| 404 | Not Found ||
|
||||||
|
# config-controller
|
||||||
|
|
||||||
|
## getConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
**接口描述**:
|
||||||
|
|
||||||
|
|
||||||
|
**接口地址**:`/admin/config`
|
||||||
|
|
||||||
|
|
||||||
|
**请求方式**:`GET`
|
||||||
|
|
||||||
|
|
||||||
|
**consumes**:``
|
||||||
|
|
||||||
|
|
||||||
|
**produces**:`["*/*"]`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
暂无
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**响应示例**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应参数**:
|
||||||
|
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | -------------------|-------|----------- |
|
||||||
|
|code| |integer(int32) | integer(int32) |
|
||||||
|
|msg| |string | |
|
||||||
|
|result| |array | Config |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**schema属性说明**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Config**
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | ------------------|--------|----------- |
|
||||||
|
|id | |integer(int32) | |
|
||||||
|
|name | |string | |
|
||||||
|
|value | |string | |
|
||||||
|
|
||||||
|
**响应状态**:
|
||||||
|
|
||||||
|
|
||||||
|
| 状态码 | 说明 | schema |
|
||||||
|
| ------------ | -------------------------------- |---------------------- |
|
||||||
|
| 200 | OK |Response«List«Config»»|
|
||||||
|
| 401 | Unauthorized ||
|
||||||
|
| 403 | Forbidden ||
|
||||||
|
| 404 | Not Found ||
|
||||||
|
## addConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
**接口描述**:
|
||||||
|
|
||||||
|
|
||||||
|
**接口地址**:`/admin/config`
|
||||||
|
|
||||||
|
|
||||||
|
**请求方式**:`POST`
|
||||||
|
|
||||||
|
|
||||||
|
**consumes**:`["application/json"]`
|
||||||
|
|
||||||
|
|
||||||
|
**produces**:`["*/*"]`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
|
||||||
|
| ------------ | -------------------------------- |-----------|--------|----|--- |
|
||||||
|
|configs| configs | query | false |array | Config |
|
||||||
|
|
||||||
|
**响应示例**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应参数**:
|
||||||
|
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | -------------------|-------|----------- |
|
||||||
|
|code| |integer(int32) | integer(int32) |
|
||||||
|
|msg| |string | |
|
||||||
|
|result| |array | Config |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**schema属性说明**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Config**
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | ------------------|--------|----------- |
|
||||||
|
|id | |integer(int32) | |
|
||||||
|
|name | |string | |
|
||||||
|
|value | |string | |
|
||||||
|
|
||||||
|
**响应状态**:
|
||||||
|
|
||||||
|
|
||||||
|
| 状态码 | 说明 | schema |
|
||||||
|
| ------------ | -------------------------------- |---------------------- |
|
||||||
|
| 200 | OK |Response«List«Config»»|
|
||||||
|
| 201 | Created ||
|
||||||
|
| 401 | Unauthorized ||
|
||||||
|
| 403 | Forbidden ||
|
||||||
|
| 404 | Not Found ||
|
||||||
|
## updateConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
**接口描述**:
|
||||||
|
|
||||||
|
|
||||||
|
**接口地址**:`/admin/config`
|
||||||
|
|
||||||
|
|
||||||
|
**请求方式**:`PUT`
|
||||||
|
|
||||||
|
|
||||||
|
**consumes**:`["application/json"]`
|
||||||
|
|
||||||
|
|
||||||
|
**produces**:`["*/*"]`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
|
||||||
|
| ------------ | -------------------------------- |-----------|--------|----|--- |
|
||||||
|
|configs| configs | query | false |array | Config |
|
||||||
|
|
||||||
|
**响应示例**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应参数**:
|
||||||
|
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | -------------------|-------|----------- |
|
||||||
|
|code| |integer(int32) | integer(int32) |
|
||||||
|
|msg| |string | |
|
||||||
|
|result| |array | Config |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**schema属性说明**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Config**
|
||||||
|
|
||||||
|
| 参数名称 | 参数说明 | 类型 | schema |
|
||||||
|
| ------------ | ------------------|--------|----------- |
|
||||||
|
|id | |integer(int32) | |
|
||||||
|
|name | |string | |
|
||||||
|
|value | |string | |
|
||||||
|
|
||||||
|
**响应状态**:
|
||||||
|
|
||||||
|
|
||||||
|
| 状态码 | 说明 | schema |
|
||||||
|
| ------------ | -------------------------------- |---------------------- |
|
||||||
|
| 200 | OK |Response«List«Config»»|
|
||||||
|
| 201 | Created ||
|
||||||
|
| 401 | Unauthorized ||
|
||||||
|
| 403 | Forbidden ||
|
||||||
|
| 404 | Not Found ||
|
||||||
# links-controller
|
# links-controller
|
||||||
|
|
||||||
## all
|
## all
|
||||||
@@ -1649,8 +1946,8 @@
|
|||||||
| 参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
|
| 参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
|
||||||
| ------------ | -------------------------------- |-----------|--------|----|--- |
|
| ------------ | -------------------------------- |-----------|--------|----|--- |
|
||||||
|count| count | query | true |integer | |
|
|count| count | query | true |integer | |
|
||||||
|page| page | query | true |integer | |
|
|
||||||
|deleted| deleted | query | false |boolean | |
|
|deleted| deleted | query | false |boolean | |
|
||||||
|
|page| page | query | true |integer | |
|
||||||
|
|
||||||
**响应示例**:
|
**响应示例**:
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ git clone git@github.com:xiaohai2271/blog-backEnd.git
|
|||||||
|
|
||||||
### 3. maven构建
|
### 3. maven构建
|
||||||
```shell script
|
```shell script
|
||||||
mvn clean package -pl blog-deploy -am
|
mvn package
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. 运行
|
### 4. 运行
|
||||||
```shell script
|
```shell script
|
||||||
java -jar blog-deploy/target/blog-*.jar
|
java -jar target/blog-0.0.1-SNAPSHOT.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. 其他命令
|
### 5. 其他命令
|
||||||
|
|||||||
230
pom.xml
230
pom.xml
@@ -2,72 +2,230 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>pom</packaging>
|
|
||||||
<modules>
|
|
||||||
<module>blog-common</module>
|
|
||||||
<module>blog-article</module>
|
|
||||||
<module>blog-categorytag</module>
|
|
||||||
<module>blog-user</module>
|
|
||||||
<module>blog-comment</module>
|
|
||||||
<module>blog-partnersite</module>
|
|
||||||
<module>blog-visitor</module>
|
|
||||||
<module>blog-siteinfo</module>
|
|
||||||
<module>blog-extension</module>
|
|
||||||
<module>blog-deploy</module>
|
|
||||||
<module>blog-resource</module>
|
|
||||||
</modules>
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.5.6</version>
|
<version>2.1.3.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>cn.celess</groupId>
|
<groupId>cn.celess</groupId>
|
||||||
<artifactId>blog</artifactId>
|
<artifactId>blog</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>blog</name>
|
<name>blog</name>
|
||||||
<description>personal blog system project for Spring Boot</description>
|
<description>personal blog system project for Spring Boot</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<blog-common.version>1.0.0</blog-common.version>
|
|
||||||
<blog-article.version>1.0.0</blog-article.version>
|
|
||||||
<blog-categorytag.version>1.0.0</blog-categorytag.version>
|
|
||||||
<blog-user.version>1.0.0</blog-user.version>
|
|
||||||
<blog-comment.version>1.0.0</blog-comment.version>
|
|
||||||
<blog-partnersite.version>1.0.0</blog-partnersite.version>
|
|
||||||
<blog-visitor.version>1.0.0</blog-visitor.version>
|
|
||||||
<blog-siteinfo.version>1.0.0</blog-siteinfo.version>
|
|
||||||
<blog-extension.version>1.0.0</blog-extension.version>
|
|
||||||
<blog-resource.version>1.0.0</blog-resource.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--druid-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid</artifactId>
|
||||||
|
<version>1.1.14</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- lombok -->
|
<!-- lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.22</version>
|
<version>1.18.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
|
<version>1.9.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--MarkDown 2 html -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.youbenzi</groupId>
|
||||||
|
<artifactId>MDTool</artifactId>
|
||||||
|
<version>1.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.minidev</groupId>
|
||||||
|
<artifactId>json-smart</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 七牛云SDK -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
<version>[7.2.0, 7.2.99]</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Email-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- redis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- pageHelper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.12</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- protostuff序列化依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dyuproject.protostuff</groupId>
|
||||||
|
<artifactId>protostuff-core</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dyuproject.protostuff</groupId>
|
||||||
|
<artifactId>protostuff-runtime</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Ua解析-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.bitwalker</groupId>
|
||||||
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
|
<version>1.20</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.2</version>
|
<version>4.13.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JJwt -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OkHttp -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.vintage</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>junit-vintage-engine</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>5.8.2</version>
|
<version>1.3.72</version>
|
||||||
<scope>test</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sourceforge.htmlunit</groupId>
|
||||||
|
<artifactId>htmlunit</artifactId>
|
||||||
|
<version>2.42.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>2.0.206</version>
|
<version>1.4.200</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.kstyrc</groupId>
|
||||||
|
<artifactId>embedded-redis</artifactId>
|
||||||
|
<version>0.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
<version>2.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<version>2.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-core</artifactId>
|
||||||
|
<version>2.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.activation</groupId>
|
||||||
|
<artifactId>activation</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lionsoul</groupId>
|
||||||
|
<artifactId>ip2region</artifactId>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>1.3.72</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>process-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
34
src/main/java/cn/celess/blog/BlogApplication.java
Normal file
34
src/main/java/cn/celess/blog/BlogApplication.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package cn.celess.blog;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zheng
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableAsync
|
||||||
|
@MapperScan("cn.celess.blog.mapper")
|
||||||
|
public class BlogApplication {
|
||||||
|
public static ConfigurableApplicationContext context;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
context = SpringApplication.run(BlogApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void restart() {
|
||||||
|
ApplicationArguments args = context.getBean(ApplicationArguments.class);
|
||||||
|
|
||||||
|
Thread thread = new Thread(() -> {
|
||||||
|
context.close();
|
||||||
|
context = SpringApplication.run(BlogApplication.class, args.getSourceArgs());
|
||||||
|
});
|
||||||
|
thread.setDaemon(false);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
|
import cn.celess.blog.enmu.ConfigKeyEnum;
|
||||||
|
import cn.celess.blog.entity.Config;
|
||||||
|
import cn.celess.blog.mapper.ConfigMapper;
|
||||||
|
import cn.celess.blog.service.fileserviceimpl.LocalFileServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/16 16:00
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ApplicationListener implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ConfigMapper configMapper;
|
||||||
|
@Autowired
|
||||||
|
Environment env;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("博客启动!");
|
||||||
|
// 设置初始值
|
||||||
|
setProperty(ConfigKeyEnum.FILE_QINIU_SECRET_KEY);
|
||||||
|
setProperty(ConfigKeyEnum.FILE_QINIU_ACCESS_KEY);
|
||||||
|
setProperty(ConfigKeyEnum.FILE_QINIU_BUCKET);
|
||||||
|
setProperty(ConfigKeyEnum.BLOG_FILE_PATH);
|
||||||
|
|
||||||
|
List<Config> configurations = configMapper.getConfigurations()
|
||||||
|
.stream()
|
||||||
|
.filter(config -> config.getValue() != null && !"".equals(config.getValue()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
configurations.forEach(config -> System.setProperty(config.getName(), config.getValue()));
|
||||||
|
log.debug("注入配置成功 {}", configurations.stream().map(Config::getName).collect(Collectors.toList()));
|
||||||
|
File path = new File(LocalFileServiceImpl.getPath(System.getProperty(ConfigKeyEnum.BLOG_FILE_PATH.getKey())));
|
||||||
|
if (!path.exists() && !path.mkdirs()) {
|
||||||
|
throw new IllegalAccessException("创建数据目录失败==>" + path.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setProperty(ConfigKeyEnum e) {
|
||||||
|
String property = env.getProperty(e.getKey());
|
||||||
|
if (property != null) {
|
||||||
|
System.setProperty(e.getKey(), property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.celess.configuration;
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
@@ -14,6 +14,8 @@ import org.springframework.web.filter.CorsFilter;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class CorsConfig {
|
public class CorsConfig {
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String activeModel;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CorsFilter corsFilter() {
|
public CorsFilter corsFilter() {
|
||||||
@@ -24,7 +26,7 @@ public class CorsConfig {
|
|||||||
config.addAllowedOrigin("https://celess.cn");
|
config.addAllowedOrigin("https://celess.cn");
|
||||||
config.addAllowedOrigin("https://www.celess.cn");
|
config.addAllowedOrigin("https://www.celess.cn");
|
||||||
// 本地调试时的跨域
|
// 本地调试时的跨域
|
||||||
if (!"prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
if (!"prod".equals(activeModel)) {
|
||||||
config.addAllowedOrigin("http://localhost:4200");
|
config.addAllowedOrigin("http://localhost:4200");
|
||||||
config.addAllowedOrigin("http://127.0.0.1:4200");
|
config.addAllowedOrigin("http://127.0.0.1:4200");
|
||||||
}
|
}
|
||||||
81
src/main/java/cn/celess/blog/configuration/DruidConfig.java
Normal file
81
src/main/java/cn/celess/blog/configuration/DruidConfig.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2019/03/28 14:26
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
public class DruidConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Environment env;
|
||||||
|
|
||||||
|
public static final String DB_CONFIG_PATH = System.getProperty("user.home") + "/blog/application.properties";
|
||||||
|
public static final String DB_CONFIG_URL_PREFIX = "spring.datasource.url";
|
||||||
|
public static final String DB_CONFIG_USERNAME_PREFIX = "spring.datasource.username";
|
||||||
|
public static final String DB_CONFIG_PASSWORD_PREFIX = "spring.datasource.password";
|
||||||
|
public static final String DB_CONFIG_DRIVER_CLASS_NAME_PREFIX = "spring.datasource.driver-class-name";
|
||||||
|
public static final String TEST_PROFILES = "test";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DruidDataSource initDataSource() throws IOException {
|
||||||
|
DruidDataSource dataSource;
|
||||||
|
File file = new File(DB_CONFIG_PATH);
|
||||||
|
if (file.exists() && !Arrays.asList(env.getActiveProfiles()).contains(TEST_PROFILES)) {
|
||||||
|
log.debug("从文件中获取数据库配置");
|
||||||
|
dataSource = readConfigFromFile(file);
|
||||||
|
} else {
|
||||||
|
log.debug("默认数据库配置");
|
||||||
|
dataSource = defaultDruidSource();
|
||||||
|
}
|
||||||
|
dataSource.setInitialSize(10);
|
||||||
|
dataSource.setMinIdle(10);
|
||||||
|
dataSource.setMaxActive(100);
|
||||||
|
dataSource.setValidationQuery("select 1");
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DruidDataSource readConfigFromFile(File file) throws IOException {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
properties.load(fis);
|
||||||
|
fis.close();
|
||||||
|
String url = properties.getProperty(DB_CONFIG_URL_PREFIX, null);
|
||||||
|
String username = properties.getProperty(DB_CONFIG_USERNAME_PREFIX, null);
|
||||||
|
String password = properties.getProperty(DB_CONFIG_PASSWORD_PREFIX, null);
|
||||||
|
String className = properties.getProperty(DB_CONFIG_DRIVER_CLASS_NAME_PREFIX, null);
|
||||||
|
if (url == null || username == null || password == null || className == null) {
|
||||||
|
return defaultDruidSource();
|
||||||
|
}
|
||||||
|
DruidDataSource dataSource = new DruidDataSource();
|
||||||
|
dataSource.setDriverClassName(className);
|
||||||
|
dataSource.setUrl(url);
|
||||||
|
dataSource.setUsername(username);
|
||||||
|
dataSource.setPassword(password);
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DruidDataSource defaultDruidSource() {
|
||||||
|
DruidDataSource dataSource = new DruidDataSource();
|
||||||
|
dataSource.setDriverClassName(env.getProperty(DruidConfig.DB_CONFIG_DRIVER_CLASS_NAME_PREFIX));
|
||||||
|
dataSource.setUrl(env.getProperty(DruidConfig.DB_CONFIG_URL_PREFIX));
|
||||||
|
dataSource.setUsername(env.getProperty(DruidConfig.DB_CONFIG_USERNAME_PREFIX));
|
||||||
|
dataSource.setPassword(env.getProperty(DruidConfig.DB_CONFIG_PASSWORD_PREFIX));
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package cn.celess.configuration;
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
import cn.celess.configuration.filter.MultipleSubmitFilter;
|
import cn.celess.blog.configuration.filter.AuthenticationFilter;
|
||||||
import cn.celess.configuration.filter.VisitorRecord;
|
import cn.celess.blog.configuration.filter.MultipleSubmitFilter;
|
||||||
import cn.celess.configuration.listener.SessionListener;
|
import cn.celess.blog.configuration.filter.VisitorRecord;
|
||||||
|
import cn.celess.blog.configuration.listener.SessionListener;
|
||||||
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -15,12 +16,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DeployInterceptorConfig implements WebMvcConfigurer {
|
public class InterceptorConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(new MultipleSubmitFilter()).addPathPatterns("/**");
|
registry.addInterceptor(new MultipleSubmitFilter()).addPathPatterns("/**");
|
||||||
registry.addInterceptor(new VisitorRecord()).addPathPatterns("/**");
|
registry.addInterceptor(new VisitorRecord()).addPathPatterns("/**");
|
||||||
|
registry.addInterceptor(authenticationFilter()).addPathPatterns("/**");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AuthenticationFilter authenticationFilter() {
|
||||||
|
return new AuthenticationFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.celess.configuration;
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
@@ -12,6 +12,8 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.celess.configuration;
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
@@ -20,13 +20,16 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String environment;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi() {
|
public Docket createRestApi() {
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
.enable(!"prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev")))
|
.enable(!"prod".equals(environment))
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("cn.celess"))
|
.apis(RequestHandlerSelectors.basePackage("cn.celess.blog"))
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package cn.celess.user.filter;
|
package cn.celess.blog.configuration.filter;
|
||||||
|
|
||||||
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import cn.celess.common.constant.ResponseEnum;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.service.UserService;
|
||||||
import cn.celess.common.service.UserService;
|
import cn.celess.blog.util.JwtUtil;
|
||||||
import cn.celess.common.util.RedisUtil;
|
import cn.celess.blog.util.RedisUtil;
|
||||||
import cn.celess.user.util.JwtUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -28,6 +27,8 @@ public class AuthenticationFilter implements HandlerInterceptor {
|
|||||||
private static final String ROLE_ADMIN = "admin";
|
private static final String ROLE_ADMIN = "admin";
|
||||||
private static final String ROLE_USER = "user";
|
private static final String ROLE_USER = "user";
|
||||||
@Autowired
|
@Autowired
|
||||||
|
JwtUtil jwtUtil;
|
||||||
|
@Autowired
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
UserService userService;
|
UserService userService;
|
||||||
@@ -39,23 +40,23 @@ public class AuthenticationFilter implements HandlerInterceptor {
|
|||||||
int indexOf = path.indexOf("/", 1);
|
int indexOf = path.indexOf("/", 1);
|
||||||
String rootPath = indexOf == -1 ? path : path.substring(0, indexOf);
|
String rootPath = indexOf == -1 ? path : path.substring(0, indexOf);
|
||||||
String jwtStr = request.getHeader("Authorization");
|
String jwtStr = request.getHeader("Authorization");
|
||||||
if (jwtStr != null && !jwtStr.isEmpty() && !JwtUtil.isTokenExpired(jwtStr)) {
|
if (jwtStr != null && !jwtStr.isEmpty() && !jwtUtil.isTokenExpired(jwtStr)) {
|
||||||
// 已登录 记录当前email
|
// 已登录 记录当前email
|
||||||
request.getSession().setAttribute("email", JwtUtil.getUsernameFromToken(jwtStr));
|
request.getSession().setAttribute("email", jwtUtil.getUsernameFromToken(jwtStr));
|
||||||
}
|
}
|
||||||
// 不需要鉴权的路径
|
// 不需要鉴权的路径
|
||||||
if (!USER_PREFIX.equalsIgnoreCase(rootPath) && !ADMIN_PREFIX.equalsIgnoreCase(rootPath)) {
|
if (!USER_PREFIX.equals(rootPath.toLowerCase()) && !ADMIN_PREFIX.equals(rootPath.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jwtStr == null || jwtStr.isEmpty()) {
|
if (jwtStr == null || jwtStr.isEmpty()) {
|
||||||
return writeResponse(ResponseEnum.HAVE_NOT_LOG_IN, response, request);
|
return writeResponse(ResponseEnum.HAVE_NOT_LOG_IN, response, request);
|
||||||
}
|
}
|
||||||
if (JwtUtil.isTokenExpired(jwtStr)) {
|
if (jwtUtil.isTokenExpired(jwtStr)) {
|
||||||
return writeResponse(ResponseEnum.LOGIN_EXPIRED, response, request);
|
return writeResponse(ResponseEnum.LOGIN_EXPIRED, response, request);
|
||||||
}
|
}
|
||||||
String email = JwtUtil.getUsernameFromToken(jwtStr);
|
String email = jwtUtil.getUsernameFromToken(jwtStr);
|
||||||
if (JwtUtil.isTokenExpired(jwtStr)) {
|
if (jwtUtil.isTokenExpired(jwtStr)) {
|
||||||
// 登陆过期
|
// 登陆过期
|
||||||
return writeResponse(ResponseEnum.LOGIN_EXPIRED, response, request);
|
return writeResponse(ResponseEnum.LOGIN_EXPIRED, response, request);
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,7 @@ public class AuthenticationFilter implements HandlerInterceptor {
|
|||||||
String role = userService.getUserRoleByEmail(email);
|
String role = userService.getUserRoleByEmail(email);
|
||||||
if (role.equals(ROLE_USER) || role.equals(ROLE_ADMIN)) {
|
if (role.equals(ROLE_USER) || role.equals(ROLE_ADMIN)) {
|
||||||
// 更新token
|
// 更新token
|
||||||
String token = JwtUtil.updateTokenDate(jwtStr);
|
String token = jwtUtil.updateTokenDate(jwtStr);
|
||||||
response.setHeader("Authorization", token);
|
response.setHeader("Authorization", token);
|
||||||
}
|
}
|
||||||
if (role.equals(ROLE_ADMIN)) {
|
if (role.equals(ROLE_ADMIN)) {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package cn.celess.configuration.filter;
|
package cn.celess.blog.configuration.filter;
|
||||||
|
|
||||||
import cn.celess.common.constant.ResponseEnum;
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.util.StringUtil;
|
import cn.celess.blog.util.RequestUtil;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -24,12 +24,12 @@ public class MultipleSubmitFilter implements HandlerInterceptor {
|
|||||||
if (lastSubmitTime == null || completeUrl == null) {
|
if (lastSubmitTime == null || completeUrl == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - lastSubmitTime < WAIT_TIME && StringUtil.getCompleteUrlAndMethod(request).equals(completeUrl)) {
|
if (System.currentTimeMillis() - lastSubmitTime < WAIT_TIME && RequestUtil.getCompleteUrlAndMethod(request).equals(completeUrl)) {
|
||||||
// 请求参数和路径均相同 且请求时间间隔小于 WAIT_TIME
|
// 请求参数和路径均相同 且请求时间间隔小于 WAIT_TIME
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
Response result = new Response(ResponseEnum.FAILURE.getCode(), "重复请求", null);
|
Response result = new Response(ResponseEnum.FAILURE.getCode(), "重复请求", null);
|
||||||
response.getWriter().println(result);
|
response.getWriter().println(result.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -39,6 +39,6 @@ public class MultipleSubmitFilter implements HandlerInterceptor {
|
|||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
session.setAttribute("lastSubmitTime", System.currentTimeMillis());
|
session.setAttribute("lastSubmitTime", System.currentTimeMillis());
|
||||||
session.setAttribute("completeUrl&method", StringUtil.getCompleteUrlAndMethod(request));
|
session.setAttribute("completeUrl&method", RequestUtil.getCompleteUrlAndMethod(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.celess.configuration.filter;
|
package cn.celess.blog.configuration.filter;
|
||||||
|
|
||||||
import cn.celess.common.util.StringUtil;
|
import cn.celess.blog.util.RequestUtil;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
@@ -27,11 +27,11 @@ public class VisitorRecord implements HandlerInterceptor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 获取访问次数
|
// 获取访问次数
|
||||||
Integer count = visitDetail.get(StringUtil.getCompleteUrlAndMethod(request));
|
Integer count = visitDetail.get(RequestUtil.getCompleteUrlAndMethod(request));
|
||||||
// 自增
|
// 自增
|
||||||
count = count == null ? 1 : ++count;
|
count = count == null ? 1 : ++count;
|
||||||
// 更新
|
// 更新
|
||||||
visitDetail.put(StringUtil.getCompleteUrlAndMethod(request), count);
|
visitDetail.put(RequestUtil.getCompleteUrlAndMethod(request), count);
|
||||||
session.setAttribute("ip", request.getRemoteAddr());
|
session.setAttribute("ip", request.getRemoteAddr());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.celess.configuration.listener;
|
package cn.celess.blog.configuration.listener;
|
||||||
|
|
||||||
import cn.celess.user.util.RedisUserUtil;
|
import cn.celess.blog.util.RedisUserUtil;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package cn.celess.article.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.article.util.SitemapGenerateUtil;
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import cn.celess.common.constant.ResponseEnum;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.model.ArticleModel;
|
||||||
import cn.celess.common.entity.dto.ArticleReq;
|
import cn.celess.blog.entity.request.ArticleReq;
|
||||||
import cn.celess.common.entity.vo.ArticleModel;
|
import cn.celess.blog.service.ArticleService;
|
||||||
import cn.celess.common.service.ArticleService;
|
import cn.celess.blog.util.RedisUserUtil;
|
||||||
import cn.celess.common.util.EnvironmentUtil;
|
import cn.celess.blog.util.SitemapGenerateUtil;
|
||||||
import cn.celess.user.util.RedisUserUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -25,6 +25,8 @@ public class ArticleController {
|
|||||||
SitemapGenerateUtil sitemapGenerateUtil;
|
SitemapGenerateUtil sitemapGenerateUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
RedisUserUtil redisUserUtil;
|
RedisUserUtil redisUserUtil;
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String activeModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新建一篇文章
|
* 新建一篇文章
|
||||||
@@ -35,7 +37,7 @@ public class ArticleController {
|
|||||||
@PostMapping("/admin/article/create")
|
@PostMapping("/admin/article/create")
|
||||||
public Response create(@RequestBody ArticleReq body) {
|
public Response create(@RequestBody ArticleReq body) {
|
||||||
ArticleModel articleModel = articleService.create(body);
|
ArticleModel articleModel = articleService.create(body);
|
||||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
if ("prod".equals(activeModel)) {
|
||||||
sitemapGenerateUtil.createSitemap();
|
sitemapGenerateUtil.createSitemap();
|
||||||
}
|
}
|
||||||
return Response.success(articleModel);
|
return Response.success(articleModel);
|
||||||
@@ -50,7 +52,7 @@ public class ArticleController {
|
|||||||
@DeleteMapping("/admin/article/del")
|
@DeleteMapping("/admin/article/del")
|
||||||
public Response delete(@RequestParam("articleID") long articleId) {
|
public Response delete(@RequestParam("articleID") long articleId) {
|
||||||
boolean delete = articleService.delete(articleId);
|
boolean delete = articleService.delete(articleId);
|
||||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
if ("prod".equals(activeModel)) {
|
||||||
sitemapGenerateUtil.createSitemap();
|
sitemapGenerateUtil.createSitemap();
|
||||||
}
|
}
|
||||||
return Response.success(delete);
|
return Response.success(delete);
|
||||||
@@ -65,7 +67,7 @@ public class ArticleController {
|
|||||||
@PutMapping("/admin/article/update")
|
@PutMapping("/admin/article/update")
|
||||||
public Response update(@RequestBody ArticleReq body) {
|
public Response update(@RequestBody ArticleReq body) {
|
||||||
ArticleModel update = articleService.update(body);
|
ArticleModel update = articleService.update(body);
|
||||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
if ("prod".equals(activeModel)) {
|
||||||
sitemapGenerateUtil.createSitemap();
|
sitemapGenerateUtil.createSitemap();
|
||||||
}
|
}
|
||||||
return Response.success(update);
|
return Response.success(update);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.celess.categorytag.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.service.CategoryService;
|
import cn.celess.blog.service.CategoryService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package cn.celess.comment.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.dto.CommentReq;
|
import cn.celess.blog.entity.request.CommentReq;
|
||||||
import cn.celess.common.service.CommentService;
|
import cn.celess.blog.service.CommentService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package cn.celess.extension.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.constant.ResponseEnum;
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.vo.QiniuResponse;
|
import cn.celess.blog.entity.model.FileResponse;
|
||||||
import cn.celess.common.exception.BlogResponseException;
|
import cn.celess.blog.exception.MyException;
|
||||||
import cn.celess.common.service.CountService;
|
import cn.celess.blog.service.CountService;
|
||||||
import cn.celess.common.service.QiniuService;
|
import cn.celess.blog.service.FileService;
|
||||||
import cn.celess.common.util.HttpUtil;
|
import cn.celess.blog.util.HttpUtil;
|
||||||
import cn.celess.common.util.RedisUtil;
|
import cn.celess.blog.util.RedisUserUtil;
|
||||||
import cn.celess.common.util.VeriCodeUtil;
|
import cn.celess.blog.util.RedisUtil;
|
||||||
import cn.celess.user.util.RedisUserUtil;
|
import cn.celess.blog.util.VeriCodeUtil;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -37,16 +36,16 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @date : 2019/04/02 22:03
|
* @date : 2019/04/02 22:03
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class ExtensionController {
|
public class CommonController {
|
||||||
public static final Logger logger = LoggerFactory.getLogger(Object.class);
|
public static final Logger logger = LoggerFactory.getLogger(Object.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CountService countService;
|
CountService countService;
|
||||||
@Autowired
|
@Autowired
|
||||||
QiniuService qiniuService;
|
FileService fileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
@Resource
|
@Autowired
|
||||||
RedisUserUtil redisUserUtil;
|
RedisUserUtil redisUserUtil;
|
||||||
|
|
||||||
|
|
||||||
@@ -112,10 +111,10 @@ public class ExtensionController {
|
|||||||
request.getSession().setAttribute("verImgCodeStatus", false);
|
request.getSession().setAttribute("verImgCodeStatus", false);
|
||||||
String codeStr = (String) request.getSession().getAttribute("code");
|
String codeStr = (String) request.getSession().getAttribute("code");
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||||
}
|
}
|
||||||
if (codeStr == null) {
|
if (codeStr == null) {
|
||||||
throw new BlogResponseException(ResponseEnum.IMG_CODE_TIMEOUT);
|
throw new MyException(ResponseEnum.IMG_CODE_TIMEOUT);
|
||||||
}
|
}
|
||||||
code = code.toLowerCase();
|
code = code.toLowerCase();
|
||||||
codeStr = codeStr.toLowerCase();
|
codeStr = codeStr.toLowerCase();
|
||||||
@@ -147,7 +146,7 @@ public class ExtensionController {
|
|||||||
uploadTimes = Integer.parseInt(uploadTimesStr);
|
uploadTimes = Integer.parseInt(uploadTimesStr);
|
||||||
}
|
}
|
||||||
if (uploadTimes == 10) {
|
if (uploadTimes == 10) {
|
||||||
throw new BlogResponseException(ResponseEnum.FAILURE.getCode(), "上传次数已达10次,请2小时后在上传");
|
throw new MyException(ResponseEnum.FAILURE.getCode(), "上传次数已达10次,请2小时后在上传");
|
||||||
}
|
}
|
||||||
request.setCharacterEncoding("utf-8");
|
request.setCharacterEncoding("utf-8");
|
||||||
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
||||||
@@ -160,12 +159,12 @@ public class ExtensionController {
|
|||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
assert fileName != null;
|
assert fileName != null;
|
||||||
String mime = fileName.substring(fileName.lastIndexOf("."));
|
String mime = fileName.substring(fileName.lastIndexOf("."));
|
||||||
if (".png".equalsIgnoreCase(mime) || ".jpg".equalsIgnoreCase(mime) ||
|
if (".png".equals(mime.toLowerCase()) || ".jpg".equals(mime.toLowerCase()) ||
|
||||||
".jpeg".equalsIgnoreCase(mime) || ".bmp".equalsIgnoreCase(mime)) {
|
".jpeg".equals(mime.toLowerCase()) || ".bmp".equals(mime.toLowerCase())) {
|
||||||
QiniuResponse qiniuResponse = qiniuService.uploadFile(file.getInputStream(), "img_" + System.currentTimeMillis() + mime);
|
FileResponse fileResponse = fileService.getFileManager().uploadFile(file.getInputStream(), "img_" + System.currentTimeMillis() + mime);
|
||||||
map.put("success", 1);
|
map.put("success", 1);
|
||||||
map.put("message", "上传成功");
|
map.put("message", "上传成功");
|
||||||
map.put("url", "http://cdn.celess.cn/" + qiniuResponse.key);
|
map.put("url", "http://cdn.celess.cn/" + fileResponse.key);
|
||||||
response.getWriter().println(mapper.writeValueAsString(map));
|
response.getWriter().println(mapper.writeValueAsString(map));
|
||||||
redisUtil.setEx(request.getRemoteAddr() + "-ImgUploadTimes", uploadTimes + 1 + "", 2, TimeUnit.HOURS);
|
redisUtil.setEx(request.getRemoteAddr() + "-ImgUploadTimes", uploadTimes + 1 + "", 2, TimeUnit.HOURS);
|
||||||
return;
|
return;
|
||||||
@@ -180,7 +179,7 @@ public class ExtensionController {
|
|||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
JsonNode root;
|
JsonNode root;
|
||||||
try {
|
try {
|
||||||
root = mapper.readTree(HttpUtil.getHttpResponse("https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN"));
|
root = mapper.readTree(HttpUtil.get("https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return Response.failure(null);
|
return Response.failure(null);
|
||||||
}
|
}
|
||||||
@@ -197,10 +196,10 @@ public class ExtensionController {
|
|||||||
uploadTimes = Integer.parseInt(uploadTimesStr);
|
uploadTimes = Integer.parseInt(uploadTimesStr);
|
||||||
}
|
}
|
||||||
if (uploadTimes == 10) {
|
if (uploadTimes == 10) {
|
||||||
throw new BlogResponseException(ResponseEnum.FAILURE.getCode(), "上传次数已达10次,请2小时后在上传");
|
throw new MyException(ResponseEnum.FAILURE.getCode(), "上传次数已达10次,请2小时后在上传");
|
||||||
}
|
}
|
||||||
if (files.length == 0) {
|
if (files.length == 0) {
|
||||||
throw new BlogResponseException(ResponseEnum.NO_FILE);
|
throw new MyException(ResponseEnum.NO_FILE);
|
||||||
}
|
}
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
Map<String, Object> resp = new HashMap<>(4);
|
Map<String, Object> resp = new HashMap<>(4);
|
||||||
@@ -209,12 +208,12 @@ public class ExtensionController {
|
|||||||
assert fileName != null;
|
assert fileName != null;
|
||||||
String mime = fileName.substring(fileName.lastIndexOf("."));
|
String mime = fileName.substring(fileName.lastIndexOf("."));
|
||||||
String name = fileName.replace(mime, "").replaceAll(" ", "");
|
String name = fileName.replace(mime, "").replaceAll(" ", "");
|
||||||
QiniuResponse qiniuResponse = qiniuService.uploadFile(file.getInputStream(), "file_" + name + '_' + System.currentTimeMillis() + mime);
|
FileResponse fileResponse = fileService.getFileManager().uploadFile(file.getInputStream(), "file_" + name + '_' + System.currentTimeMillis() + mime);
|
||||||
resp.put("originalFilename", fileName);
|
resp.put("originalFilename", fileName);
|
||||||
resp.put("success", qiniuResponse != null);
|
resp.put("success", fileResponse != null);
|
||||||
if (qiniuResponse != null) {
|
if (fileResponse != null) {
|
||||||
resp.put("host", "http://cdn.celess.cn/");
|
resp.put("host", "http://cdn.celess.cn/");
|
||||||
resp.put("path", qiniuResponse.key);
|
resp.put("path", fileResponse.key);
|
||||||
}
|
}
|
||||||
result.add(resp);
|
result.add(resp);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
|
import cn.celess.blog.entity.Config;
|
||||||
|
import cn.celess.blog.entity.Response;
|
||||||
|
import cn.celess.blog.mapper.ConfigMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/16 20:56
|
||||||
|
* @desc : 配置管理接口
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class ConfigController {
|
||||||
|
@Autowired
|
||||||
|
ConfigMapper configMapper;
|
||||||
|
|
||||||
|
@GetMapping("/admin/config")
|
||||||
|
public Response<List<Config>> getConfiguration() {
|
||||||
|
return Response.success(configMapper.getConfigurations());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/admin/config")
|
||||||
|
public Response<List<Config>> updateConfiguration(@RequestBody List<Config> configs) {
|
||||||
|
configs.forEach(config -> configMapper.updateConfiguration(config));
|
||||||
|
configs.forEach(config -> System.setProperty(config.getName(), config.getValue()));
|
||||||
|
return Response.success(configMapper.getConfigurations());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/admin/config")
|
||||||
|
public Response<List<Config>> addConfiguration(@RequestBody List<Config> configs) {
|
||||||
|
configs.forEach(config -> configMapper.addConfiguration(config));
|
||||||
|
configs.forEach(config -> System.setProperty(config.getName(), config.getValue()));
|
||||||
|
return Response.success(configMapper.getConfigurations());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
|
import cn.celess.blog.BlogApplication;
|
||||||
|
import cn.celess.blog.enmu.ConfigKeyEnum;
|
||||||
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
|
import cn.celess.blog.entity.Config;
|
||||||
|
import cn.celess.blog.entity.InstallParam;
|
||||||
|
import cn.celess.blog.entity.Response;
|
||||||
|
import cn.celess.blog.exception.MyException;
|
||||||
|
import cn.celess.blog.mapper.ConfigMapper;
|
||||||
|
import cn.celess.blog.service.InstallService;
|
||||||
|
import cn.celess.blog.util.RegexUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/18 15:36
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@Validated
|
||||||
|
public class InstallController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
InstallService installService;
|
||||||
|
@Autowired
|
||||||
|
ConfigMapper configMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/is_install")
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Map<String, Object>> isInstall() {
|
||||||
|
Map<String, Object> install = installService.isInstall();
|
||||||
|
return Response.success(install);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/install")
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> install(@Valid @RequestBody InstallParam installParam) {
|
||||||
|
if (!RegexUtil.emailMatch(installParam.getEmail())) {
|
||||||
|
throw new MyException(ResponseEnum.PARAMETERS_EMAIL_ERROR);
|
||||||
|
}
|
||||||
|
if (!RegexUtil.pwdMatch(installParam.getPassword())) {
|
||||||
|
throw new MyException(ResponseEnum.PARAMETERS_PWD_ERROR);
|
||||||
|
}
|
||||||
|
return Response.success(installService.install(installParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/default_config")
|
||||||
|
@ResponseBody
|
||||||
|
public Response<String> defaultConfig() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/install")
|
||||||
|
public String install() {
|
||||||
|
Config configuration = configMapper.getConfiguration(ConfigKeyEnum.BLOG_INSTALLED.getKey());
|
||||||
|
if (Boolean.parseBoolean(configuration.getValue())) {
|
||||||
|
return "index.html";
|
||||||
|
}
|
||||||
|
log.info("博客第一次运行,还未安装");
|
||||||
|
return "install.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
package cn.celess.partnersite.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
|
import cn.celess.blog.entity.PartnerSite;
|
||||||
import cn.celess.common.entity.PartnerSite;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.request.LinkApplyReq;
|
||||||
import cn.celess.common.entity.dto.LinkApplyReq;
|
import cn.celess.blog.entity.request.LinkReq;
|
||||||
import cn.celess.common.entity.dto.LinkReq;
|
import cn.celess.blog.service.MailService;
|
||||||
import cn.celess.common.service.MailService;
|
import cn.celess.blog.service.PartnerSiteService;
|
||||||
import cn.celess.common.service.PartnerSiteService;
|
import cn.celess.blog.util.RedisUtil;
|
||||||
import cn.celess.common.util.RedisUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ import java.util.stream.Collectors;
|
|||||||
* @date : 2019/05/12 13:26
|
* @date : 2019/05/12 13:26
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class PartnerSiteController {
|
public class LinksController {
|
||||||
@Autowired
|
@Autowired
|
||||||
PartnerSiteService partnerSiteService;
|
PartnerSiteService partnerSiteService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package cn.celess.categorytag.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.vo.TagModel;
|
import cn.celess.blog.entity.model.TagModel;
|
||||||
import cn.celess.common.service.TagService;
|
import cn.celess.blog.service.TagService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package cn.celess.user.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.entity.dto.LoginReq;
|
import cn.celess.blog.entity.request.LoginReq;
|
||||||
import cn.celess.common.entity.dto.UserReq;
|
import cn.celess.blog.entity.request.UserReq;
|
||||||
import cn.celess.common.service.UserService;
|
import cn.celess.blog.service.UserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -61,8 +61,8 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String mime = fileName.substring(fileName.lastIndexOf("."));
|
String mime = fileName.substring(fileName.lastIndexOf("."));
|
||||||
if (".png".equalsIgnoreCase(mime) || ".jpg".equalsIgnoreCase(mime) ||
|
if (".png".equals(mime.toLowerCase()) || ".jpg".equals(mime.toLowerCase()) ||
|
||||||
".jpeg".equalsIgnoreCase(mime) || ".bmp".equalsIgnoreCase(mime)) {
|
".jpeg".equals(mime.toLowerCase()) || ".bmp".equals(mime.toLowerCase())) {
|
||||||
return (Response) userService.updateUserAavatarImg(file.getInputStream(), mime);
|
return (Response) userService.updateUserAavatarImg(file.getInputStream(), mime);
|
||||||
}
|
}
|
||||||
return Response.failure("请上传图片文件");
|
return Response.failure("请上传图片文件");
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package cn.celess.visitor.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.service.CountService;
|
import cn.celess.blog.service.CountService;
|
||||||
import cn.celess.common.service.VisitorService;
|
import cn.celess.blog.service.VisitorService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.celess.siteinfo.controller;
|
package cn.celess.blog.controller;
|
||||||
|
|
||||||
import cn.celess.common.entity.Response;
|
import cn.celess.blog.entity.Response;
|
||||||
import cn.celess.common.service.WebUpdateInfoService;
|
import cn.celess.blog.service.WebUpdateInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.celess.common.constant;
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
37
src/main/java/cn/celess/blog/enmu/ConfigKeyEnum.java
Normal file
37
src/main/java/cn/celess/blog/enmu/ConfigKeyEnum.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/16 16:41
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
public enum ConfigKeyEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 枚举
|
||||||
|
*/
|
||||||
|
FILE_TYPE("file.type"),
|
||||||
|
FILE_QINIU_ACCESS_KEY("file.qiniu.accessKey"),
|
||||||
|
FILE_QINIU_SECRET_KEY("file.qiniu.secretKey"),
|
||||||
|
FILE_QINIU_BUCKET("file.qiniu.bucket"),
|
||||||
|
FILE_LOCAL_DIRECTORY_PATH("file.local.directoryPath"),
|
||||||
|
BLOG_FILE_PATH("blog.file.path"),
|
||||||
|
BLOG_INSTALLED("blog.installed"),
|
||||||
|
DB_TYPE("db.type"),
|
||||||
|
DB_URL("spring.datasource.url"),
|
||||||
|
DB_USERNAME("spring.datasource.username"),
|
||||||
|
DB_PASSWORD("spring.datasource.password"),
|
||||||
|
DB_DRIVER_CLASS_NAME("spring.datasource.driver-class-name"),
|
||||||
|
BLOG_DB_PATH("blog.db.path");
|
||||||
|
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
ConfigKeyEnum(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.celess.common.constant;
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.celess.common.constant;
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.celess.common.constant;
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ import java.util.List;
|
|||||||
* @date : 2019/03/28 14:51
|
* @date : 2019/03/28 14:51
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class Article implements Serializable {
|
public class Article {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: 小海
|
* @Author: 小海
|
||||||
* @Date: 2020-05-24 14:52
|
* @Date: 2020-05-24 14:52
|
||||||
@@ -14,7 +12,7 @@ import java.io.Serializable;
|
|||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ArticleTag implements Serializable {
|
public class ArticleTag {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Article article;
|
private Article article;
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
* @date : 2019/03/28 22:18
|
* @date : 2019/03/28 22:18
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class Category extends TagCategory implements Serializable {
|
public class Category extends TagCategory {
|
||||||
public Category(String name) {
|
public Category(String name) {
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Comment implements Serializable {
|
public class Comment {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
26
src/main/java/cn/celess/blog/entity/Config.java
Normal file
26
src/main/java/cn/celess/blog/entity/Config.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
|
import cn.celess.blog.enmu.ConfigKeyEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/16 15:24
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Config {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public Config(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Config(ConfigKeyEnum e) {
|
||||||
|
this.name = e.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/cn/celess/blog/entity/InstallParam.java
Normal file
38
src/main/java/cn/celess/blog/entity/InstallParam.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/18 14:52
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class InstallParam {
|
||||||
|
@NotBlank(message = "数据库类型不可为空")
|
||||||
|
private String dbType;
|
||||||
|
|
||||||
|
@NotBlank(message = "数据库主机不可为空")
|
||||||
|
private String dbHost;
|
||||||
|
|
||||||
|
@NotBlank(message = "数据库名称不可为空")
|
||||||
|
private String dbName;
|
||||||
|
|
||||||
|
@NotBlank(message = "数据库用户名不可为空")
|
||||||
|
private String dbUsername;
|
||||||
|
|
||||||
|
@NotBlank(message = "数据库密码不可为空")
|
||||||
|
private String dbPassword;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user 相关
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "用户邮箱地址不可为空")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@NotBlank(message = "用户密码不可为空")
|
||||||
|
private String password;
|
||||||
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 友链
|
* 友链
|
||||||
*
|
*
|
||||||
@@ -11,7 +9,7 @@ import java.io.Serializable;
|
|||||||
* @date : 2019/05/12 11:33
|
* @date : 2019/05/12 11:33
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class PartnerSite implements Serializable {
|
public class PartnerSite {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.celess.common.entity;
|
package cn.celess.blog.entity;
|
||||||
|
|
||||||
import cn.celess.common.constant.ResponseEnum;
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user