Compare commits
29 Commits
main
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14c9a95a61 | ||
|
|
2d649b0373 | ||
|
|
4ed8939945 | ||
|
|
2c287b5c08 | ||
|
|
d07b1f9b96 | ||
|
|
4879a4bb79 | ||
|
|
027b81c006 | ||
|
|
1c976f1310 | ||
|
|
a544e1bd54 | ||
|
|
5a00e6c62f | ||
|
|
07e84ab875 | ||
|
|
a6c91fc3f1 | ||
|
|
fb88f90b70 | ||
|
|
692ce19320 | ||
|
|
5c7e3344c9 | ||
|
|
6ac9c69ff9 | ||
|
|
c6a5de6335 | ||
|
|
ab13a1713f | ||
|
|
f8ee1da333 | ||
|
|
366ce4b829 | ||
|
|
fa120a6da5 | ||
|
|
ef2f98e45f | ||
|
|
7e700b6499 | ||
|
|
c1c7f38ee9 | ||
|
|
fd509e0042 | ||
|
|
330d4d525a | ||
|
|
8c18abf120 | ||
|
|
113a054bea | ||
|
|
6d3739517a |
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@@ -1,16 +1,20 @@
|
||||
# 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
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- "doc/**"
|
||||
- "**/README.md"
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- "doc/**"
|
||||
- "**/README.md"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '.md')" # 如果 commit 信息包含以下关键字则跳过该任务
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')" # 如果 commit 信息包含以下关键字则跳过该任务
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
KEY: ${{ secrets.WEB_HOOK_ACCESS_KEY }}
|
||||
@@ -33,5 +37,13 @@ jobs:
|
||||
# Gitee存储库的SSH URL.
|
||||
gitee-repo: git@gitee.com:xiaohai2271/blog-backEnd.git
|
||||
|
||||
- name: Deploy
|
||||
run: mvn -B test --file pom.xml && curl http://bt.celess.cn:2271/hook?access_key=$KEY
|
||||
- name: Cache local Maven repository
|
||||
uses: actions/cache@v2
|
||||
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
71
.github/workflows/codeql-analysis.yml
vendored
@@ -1,71 +0,0 @@
|
||||
# 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
|
||||
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
@@ -1,29 +0,0 @@
|
||||
# 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:
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '.md')" # 如果 commit 信息包含以下关键字则跳过该任务
|
||||
runs-on: ubuntu-latest
|
||||
# env:
|
||||
# APPLICATION_PROPERTIES_TEST: ${{ secrets.APPLICATION_PROPERTIES_TEST }}
|
||||
# APPLICATION_PROPERTIES_PROD: ${{ secrets.APPLICATION_PROPERTIES_PROD }}
|
||||
|
||||
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/
|
||||
|
||||
# 本地项目的私有文件
|
||||
src/main/resources/application-dev.properties
|
||||
blog-deploy/src/main/resources/application-dev.properties
|
||||
src/main/resources/application-prod.properties
|
||||
|
||||
45
blog-article/pom.xml
Normal file
45
blog-article/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,18 @@
|
||||
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,14 +1,14 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.article.controller;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.request.ArticleReq;
|
||||
import cn.celess.blog.service.ArticleService;
|
||||
import cn.celess.blog.util.RedisUserUtil;
|
||||
import cn.celess.blog.util.SitemapGenerateUtil;
|
||||
import cn.celess.article.util.SitemapGenerateUtil;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.dto.ArticleReq;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.service.ArticleService;
|
||||
import cn.celess.common.util.EnvironmentUtil;
|
||||
import cn.celess.user.util.RedisUserUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -25,8 +25,6 @@ public class ArticleController {
|
||||
SitemapGenerateUtil sitemapGenerateUtil;
|
||||
@Autowired
|
||||
RedisUserUtil redisUserUtil;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeModel;
|
||||
|
||||
/**
|
||||
* 新建一篇文章
|
||||
@@ -37,7 +35,7 @@ public class ArticleController {
|
||||
@PostMapping("/admin/article/create")
|
||||
public Response create(@RequestBody ArticleReq body) {
|
||||
ArticleModel articleModel = articleService.create(body);
|
||||
if ("prod".equals(activeModel)) {
|
||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
||||
sitemapGenerateUtil.createSitemap();
|
||||
}
|
||||
return Response.success(articleModel);
|
||||
@@ -52,7 +50,7 @@ public class ArticleController {
|
||||
@DeleteMapping("/admin/article/del")
|
||||
public Response delete(@RequestParam("articleID") long articleId) {
|
||||
boolean delete = articleService.delete(articleId);
|
||||
if ("prod".equals(activeModel)) {
|
||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
||||
sitemapGenerateUtil.createSitemap();
|
||||
}
|
||||
return Response.success(delete);
|
||||
@@ -67,7 +65,7 @@ public class ArticleController {
|
||||
@PutMapping("/admin/article/update")
|
||||
public Response update(@RequestBody ArticleReq body) {
|
||||
ArticleModel update = articleService.update(body);
|
||||
if ("prod".equals(activeModel)) {
|
||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
||||
sitemapGenerateUtil.createSitemap();
|
||||
}
|
||||
return Response.success(update);
|
||||
@@ -1,28 +1,30 @@
|
||||
package cn.celess.blog.service.serviceimpl;
|
||||
package cn.celess.article.serviceimpl;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.enmu.RoleEnum;
|
||||
import cn.celess.blog.entity.*;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.ArticleReq;
|
||||
import cn.celess.blog.exception.MyException;
|
||||
import cn.celess.blog.mapper.*;
|
||||
import cn.celess.blog.service.ArticleService;
|
||||
import cn.celess.blog.service.UserService;
|
||||
import cn.celess.blog.util.ModalTrans;
|
||||
import cn.celess.blog.util.RedisUserUtil;
|
||||
import cn.celess.blog.util.RegexUtil;
|
||||
import cn.celess.blog.util.StringFromHtmlUtil;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.constant.RoleEnum;
|
||||
import cn.celess.common.entity.*;
|
||||
import cn.celess.common.entity.dto.ArticleReq;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.exception.BlogResponseException;
|
||||
import cn.celess.common.mapper.*;
|
||||
import cn.celess.common.service.ArticleService;
|
||||
import cn.celess.common.service.UserService;
|
||||
import cn.celess.common.util.ModalTrans;
|
||||
import cn.celess.common.util.RegexUtil;
|
||||
import cn.celess.common.util.StringUtil;
|
||||
import cn.celess.user.util.RedisUserUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.youbenzi.mdtool.tool.MDTool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -37,57 +39,57 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
TagMapper tagMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
CategoryMapper categoryMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
CommentMapper commentMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleTagMapper articleTagMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
UserService userService;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
@Resource
|
||||
RedisUserUtil redisUserUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ArticleModel create(ArticleReq reqBody) {
|
||||
if (reqBody == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
//数据判断
|
||||
if (reqBody.getTitle() == null || reqBody.getTitle().replaceAll(" ", "").isEmpty()) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
} else if (reqBody.getMdContent() == null || reqBody.getMdContent().replaceAll(" ", "").isEmpty()) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
//转载 判断链接
|
||||
if (!reqBody.getType()) {
|
||||
if (reqBody.getUrl() == null || reqBody.getUrl().replaceAll(" ", "").isEmpty()) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
} else if (!RegexUtil.urlMatch(reqBody.getUrl())) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_URL_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_URL_ERROR);
|
||||
}
|
||||
}
|
||||
if (reqBody.getCategory() == null || reqBody.getCategory().replaceAll(" ", "").isEmpty()) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
if (reqBody.getTags() == null || reqBody.getTags().length == 0) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
if (articleMapper.existsByTitle(reqBody.getTitle())) {
|
||||
throw new MyException(ResponseEnum.ARTICLE_HAS_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.ARTICLE_HAS_EXIST);
|
||||
}
|
||||
// 查看是否存在已有的分类
|
||||
Category category = categoryMapper.findCategoryByName(reqBody.getCategory());
|
||||
if (category == null) {
|
||||
throw new MyException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
|
||||
// 构建 需要写入数据库的对象数据
|
||||
@@ -97,7 +99,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
article.setUser(redisUserUtil.get());
|
||||
|
||||
//markdown->html->summary
|
||||
String str = StringFromHtmlUtil.getString(MDTool.markdown2Html(article.getMdContent()));
|
||||
String str = StringUtil.getString(MDTool.markdown2Html(article.getMdContent()));
|
||||
//获取摘要 摘要长度为255个字符
|
||||
String summary = str.length() > 240 ? str.substring(0, 240) + "......" : str;
|
||||
article.setSummary(summary);
|
||||
@@ -135,13 +137,13 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
if (articleForDel == null) {
|
||||
//文章不存在
|
||||
throw new MyException(ResponseEnum.ARTICLE_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.ARTICLE_NOT_EXIST);
|
||||
}
|
||||
|
||||
//对访问情况进行判断 非admin 权限不可删除文章
|
||||
User user = redisUserUtil.get();
|
||||
if (!RoleEnum.ADMIN_ROLE.getRoleName().equals(user.getRole())) {
|
||||
throw new MyException(ResponseEnum.PERMISSION_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PERMISSION_ERROR);
|
||||
}
|
||||
//删除指定文章
|
||||
articleMapper.delete(articleId);
|
||||
@@ -155,7 +157,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
@Override
|
||||
public ArticleModel update(ArticleReq reqBody) {
|
||||
if (reqBody == null || reqBody.getId() == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
// 查找数据
|
||||
Article article = articleMapper.findArticleById(reqBody.getId());
|
||||
@@ -163,7 +165,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
//数据判断
|
||||
if (reqBody.getTitle() != null && !reqBody.getTitle().replaceAll(" ", "").isEmpty()) {
|
||||
if (!article.getTitle().equals(reqBody.getTitle()) && articleMapper.existsByTitle(reqBody.getTitle())) {
|
||||
throw new MyException(ResponseEnum.ARTICLE_HAS_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.ARTICLE_HAS_EXIST);
|
||||
}
|
||||
article.setTitle(reqBody.getTitle());
|
||||
}
|
||||
@@ -174,11 +176,11 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
//转载 判断链接
|
||||
if (reqBody.getType() != null) {
|
||||
if (!reqBody.getType() && reqBody.getUrl() == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
|
||||
if (!reqBody.getType() && !RegexUtil.urlMatch(reqBody.getUrl())) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_URL_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_URL_ERROR);
|
||||
}
|
||||
article.setType(reqBody.getType());
|
||||
article.setUrl(reqBody.getUrl());
|
||||
@@ -195,7 +197,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
//写入数据库的数据
|
||||
article.setOpen(reqBody.getOpen() == null ? article.getOpen() : reqBody.getOpen());
|
||||
String str = StringFromHtmlUtil.getString(MDTool.markdown2Html(article.getMdContent()));
|
||||
String str = StringUtil.getString(MDTool.markdown2Html(article.getMdContent()));
|
||||
article.setSummary(str.length() > 240 ? str.substring(0, 240) + "......" : str);
|
||||
articleMapper.update(article);
|
||||
|
||||
@@ -249,15 +251,16 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = {"article"}, key = "'retrieveOneById'+#articleId")
|
||||
public ArticleModel retrieveOneById(long articleId, boolean is4update) {
|
||||
Article article = articleMapper.findArticleById(articleId);
|
||||
if (article == null) {
|
||||
throw new MyException(ResponseEnum.ARTICLE_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.ARTICLE_NOT_EXIST);
|
||||
}
|
||||
if (!article.getOpen()) {
|
||||
User user = redisUserUtil.getWithOutExc();
|
||||
if (user == null || "user".equals(user.getRole())) {
|
||||
throw new MyException(ResponseEnum.ARTICLE_NOT_PUBLIC);
|
||||
throw new BlogResponseException(ResponseEnum.ARTICLE_NOT_PUBLIC);
|
||||
}
|
||||
}
|
||||
ArticleModel articleModel = ModalTrans.article(article);
|
||||
@@ -300,6 +303,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = {"article"}, key = "'retrievePageForOpen:'+#page+':'+#count")
|
||||
public PageData<ArticleModel> retrievePageForOpen(int count, int page) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<Article> articleList = articleMapper.findAllByOpen(true);
|
||||
@@ -314,10 +318,11 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = {"article"}, key = "'findByCategory:'+#name")
|
||||
public PageData<ArticleModel> findByCategory(String name, int page, int count) {
|
||||
Category category = categoryMapper.findCategoryByName(name);
|
||||
if (category == null) {
|
||||
throw new MyException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
PageHelper.startPage(page, count);
|
||||
List<Article> open = articleMapper.findAllByCategoryIdAndOpen(category.getId());
|
||||
@@ -333,10 +338,11 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = {"article"}, key = "'findByTag:'+#name")
|
||||
public PageData<ArticleModel> findByTag(String name, int page, int count) {
|
||||
Tag tag = tagMapper.findTagByName(name);
|
||||
if (tag == null) {
|
||||
throw new MyException(ResponseEnum.TAG_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.TAG_NOT_EXIST);
|
||||
}
|
||||
PageHelper.startPage(page, count);
|
||||
List<ArticleTag> articleByTag = articleTagMapper.findArticleByTagAndOpen(tag.getId());
|
||||
@@ -350,6 +356,7 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
return new PageData<>(new PageInfo<>(articleByTag), modelList);
|
||||
}
|
||||
|
||||
|
||||
private ArticleModel setPreAndNextArticle(ArticleModel articleModel) {
|
||||
if (articleModel == null) {
|
||||
return null;
|
||||
@@ -1,9 +1,11 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.article.util;
|
||||
|
||||
import cn.celess.blog.entity.Article;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.util.DateFormatUtil;
|
||||
import cn.celess.common.util.EnvironmentUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -36,8 +38,6 @@ public class SitemapGenerateUtil {
|
||||
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
@Value("${sitemap.path}")
|
||||
private String path;
|
||||
private Map<String, String> urlList;
|
||||
|
||||
private static DocumentBuilder getDocumentBuilder() {
|
||||
@@ -54,7 +54,8 @@ public class SitemapGenerateUtil {
|
||||
@Async
|
||||
public void createSitemap() {
|
||||
initList();
|
||||
if ("".equals(path) || "classpath".equals(path)) {
|
||||
String path = EnvironmentUtil.getProperties("sitemap.path", System.getProperty("user.dir"));
|
||||
if ("classpath".equals(path)) {
|
||||
path = System.getProperty("user.dir") + "/sitemap.xml";
|
||||
}
|
||||
File file = new File(path);
|
||||
@@ -108,4 +109,3 @@ public class SitemapGenerateUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
12
blog-article/src/main/resources/banner.txt
Normal file
12
blog-article/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
_ _ _ ____ _ _ _ _
|
||||
| | | | (_) | _ \ | | /\ | | (_) | |
|
||||
| |__| | _ | |_) | | | ___ __ _ ______ / \ _ __ | |_ _ ___ | | ___
|
||||
| __ | | | | _ < | | / _ \ / _` | |______| / /\ \ | '__| | __| | | / __| | | / _ \
|
||||
| | | | | | | |_) | | | | (_) | | (_| | / ____ \ | | | |_ | | | (__ | | | __/
|
||||
|_| |_| |_| |____/ |_| \___/ \__, | /_/ \_\ |_| \__| |_| \___| |_| \___|
|
||||
__/ |
|
||||
|___/
|
||||
${AnsiColor.BRIGHT_RED}
|
||||
Application Version: ${application.version}${application.formatted-version}
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
@@ -0,0 +1,11 @@
|
||||
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,27 +1,28 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.article.controller;
|
||||
|
||||
import cn.celess.blog.BaseTest;
|
||||
import cn.celess.blog.entity.Article;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.ArticleReq;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
|
||||
import cn.celess.article.ArticleBaseTest;
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import cn.celess.common.entity.dto.ArticleReq;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.*;
|
||||
import static cn.celess.common.constant.ResponseEnum.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class ArticleControllerTest extends BaseTest {
|
||||
@Autowired
|
||||
public class ArticleControllerTest extends ArticleBaseTest {
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
private static final TypeReference<?> ARTICLE_MODEL_TYPE = new TypeReference<Response<ArticleModel>>() {
|
||||
};
|
||||
@@ -203,18 +204,18 @@ public class ArticleControllerTest extends BaseTest {
|
||||
@Test
|
||||
public void adminArticles() {
|
||||
try {
|
||||
getMockData(get("/admin/articles?page=1&count=10")).andExpect(result ->
|
||||
assertEquals(HAVE_NOT_LOG_IN.getCode(), getResponse(result, STRING_TYPE).getCode())
|
||||
getMockData(get("/admin/articles?page=1&count=5")).andExpect(result ->
|
||||
assertEquals(HAVE_NOT_LOG_IN.getCode(), getResponse(result, ARTICLE_MODEL_PAGE_TYPE).getCode())
|
||||
);
|
||||
|
||||
// User权限登陆
|
||||
getMockData(get("/admin/articles?page=1&count=10"), userLogin()).andDo(result ->
|
||||
assertEquals(PERMISSION_ERROR.getCode(), getResponse(result, STRING_TYPE).getCode())
|
||||
getMockData(get("/admin/articles?page=1&count=5"), userLogin()).andDo(result ->
|
||||
assertEquals(PERMISSION_ERROR.getCode(), getResponse(result, ARTICLE_MODEL_PAGE_TYPE).getCode())
|
||||
);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// admin权限登陆
|
||||
int finalI = i;
|
||||
getMockData(get("/admin/articles?page=1&count=10&deleted=" + (i == 1)), adminLogin()).andDo(result -> {
|
||||
getMockData(get("/admin/articles?page=1&count=5&deleted=" + (i == 1)), adminLogin()).andDo(result -> {
|
||||
Response<PageData<ArticleModel>> response = getResponse(result, ARTICLE_MODEL_PAGE_TYPE);
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
assertNotNull(response.getResult());
|
||||
@@ -222,7 +223,7 @@ public class ArticleControllerTest extends BaseTest {
|
||||
PageData<ArticleModel> pageData = response.getResult();
|
||||
assertNotEquals(0, pageData.getTotal());
|
||||
assertEquals(1, pageData.getPageNum());
|
||||
assertEquals(10, pageData.getPageSize());
|
||||
assertEquals(5, pageData.getPageSize());
|
||||
// 内容完整
|
||||
for (ArticleModel a : pageData.getList()) {
|
||||
assertNotNull(a.getTitle());
|
||||
@@ -1,20 +1,23 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.article.serviceimpl;
|
||||
|
||||
import cn.celess.blog.BaseTest;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
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 BaseTest {
|
||||
public class ArticleServiceTest extends ArticleBaseTest {
|
||||
|
||||
@Autowired
|
||||
ArticleService articleService;
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Test
|
||||
33
blog-categorytag/pom.xml
Normal file
33
blog-categorytag/pom.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,19 @@
|
||||
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,7 +1,7 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.service.CategoryService;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.service.CategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -37,17 +37,6 @@ public class CategoryController {
|
||||
return Response.success(categoryService.delete(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个分类
|
||||
*
|
||||
* @param id 分类id
|
||||
* @return Response
|
||||
*/
|
||||
@DeleteMapping("/admin/category/del/{id}")
|
||||
public Response deleteOne(@PathVariable("id") long id) {
|
||||
return Response.success(categoryService.delete(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新一个分类
|
||||
*
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.model.TagModel;
|
||||
import cn.celess.blog.service.TagService;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.vo.TagModel;
|
||||
import cn.celess.common.service.TagService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package cn.celess.blog.service.serviceimpl;
|
||||
package cn.celess.categorytag.serviceimpl;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.entity.Article;
|
||||
import cn.celess.blog.entity.Category;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.CategoryModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.exception.MyException;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
import cn.celess.blog.mapper.CategoryMapper;
|
||||
import cn.celess.blog.service.CategoryService;
|
||||
import cn.celess.blog.util.ModalTrans;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.entity.Category;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.CategoryModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.exception.BlogResponseException;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.CategoryMapper;
|
||||
import cn.celess.common.service.CategoryService;
|
||||
import cn.celess.common.util.ModalTrans;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,7 +36,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
@Override
|
||||
public CategoryModel create(String name) {
|
||||
if (categoryMapper.existsByName(name)) {
|
||||
throw new MyException(ResponseEnum.CATEGORY_HAS_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.CATEGORY_HAS_EXIST);
|
||||
}
|
||||
Category category = new Category();
|
||||
category.setName(name);
|
||||
@@ -48,7 +48,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
public boolean delete(long id) {
|
||||
Category category = categoryMapper.findCategoryById(id);
|
||||
if (category == null) {
|
||||
throw new MyException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
return categoryMapper.delete(id) == 1;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
@Override
|
||||
public CategoryModel update(Long id, String name) {
|
||||
if (id == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR.getCode(), "id不可为空");
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR.getCode(), "id不可为空");
|
||||
}
|
||||
Category category = categoryMapper.findCategoryById(id);
|
||||
category.setName(name);
|
||||
@@ -1,17 +1,17 @@
|
||||
package cn.celess.blog.service.serviceimpl;
|
||||
package cn.celess.categorytag.serviceimpl;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.entity.ArticleTag;
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.TagModel;
|
||||
import cn.celess.blog.exception.MyException;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
import cn.celess.blog.mapper.ArticleTagMapper;
|
||||
import cn.celess.blog.mapper.TagMapper;
|
||||
import cn.celess.blog.service.TagService;
|
||||
import cn.celess.blog.util.ModalTrans;
|
||||
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.entity.ArticleTag;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.TagModel;
|
||||
import cn.celess.common.exception.BlogResponseException;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.ArticleTagMapper;
|
||||
import cn.celess.common.mapper.TagMapper;
|
||||
import cn.celess.common.service.TagService;
|
||||
import cn.celess.common.util.ModalTrans;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,7 +42,7 @@ public class TagServiceImpl implements TagService {
|
||||
public TagModel create(String name) {
|
||||
boolean b = tagMapper.existsByName(name);
|
||||
if (b) {
|
||||
throw new MyException(ResponseEnum.TAG_HAS_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.TAG_HAS_EXIST);
|
||||
}
|
||||
Tag tag = new Tag();
|
||||
tag.setName(name);
|
||||
@@ -55,7 +55,7 @@ public class TagServiceImpl implements TagService {
|
||||
public boolean delete(long tagId) {
|
||||
Tag tag = tagMapper.findTagById(tagId);
|
||||
if (tag == null) {
|
||||
throw new MyException(ResponseEnum.TAG_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.TAG_NOT_EXIST);
|
||||
}
|
||||
List<ArticleTag> articleByTag = articleTagMapper.findArticleByTag(tagId);
|
||||
// 删除文章
|
||||
@@ -67,7 +67,7 @@ public class TagServiceImpl implements TagService {
|
||||
@Override
|
||||
public TagModel update(Long id, String name) {
|
||||
if (id == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR.getCode(), "缺少ID");
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR.getCode(), "缺少ID");
|
||||
}
|
||||
Tag tag = tagMapper.findTagById(id);
|
||||
tag.setName(name);
|
||||
12
blog-categorytag/src/main/resources/banner.txt
Normal file
12
blog-categorytag/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
_ _ _ ____ _ _______
|
||||
| | | | (_) | _ \ | | |__ __|
|
||||
| |__| | _ | |_) | | | ___ __ _ ______ | | __ _ __ _
|
||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _` | / _` |
|
||||
| | | | | | | |_) | | | | (_) | | (_| | | | | (_| | | (_| |
|
||||
|_| |_| |_| |____/ |_| \___/ \__, | |_| \__,_| \__, |
|
||||
__/ | __/ |
|
||||
|___/ |___/
|
||||
${AnsiColor.BRIGHT_RED}
|
||||
Application Version: ${application.version}${application.formatted-version}
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
@@ -0,0 +1,11 @@
|
||||
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,20 +1,20 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
import cn.celess.blog.BaseTest;
|
||||
import cn.celess.blog.entity.Category;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.model.CategoryModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.mapper.CategoryMapper;
|
||||
import cn.celess.categorytag.CategoryTagBaseTest;
|
||||
import cn.celess.common.entity.Category;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.vo.CategoryModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.mapper.CategoryMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.SUCCESS;
|
||||
import static cn.celess.common.constant.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class CategoryControllerTest extends BaseTest {
|
||||
public class CategoryControllerTest extends CategoryTagBaseTest {
|
||||
|
||||
@Autowired
|
||||
CategoryMapper categoryMapper;
|
||||
@@ -1,11 +1,12 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
import cn.celess.blog.BaseTest;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.TagModel;
|
||||
import cn.celess.blog.mapper.TagMapper;
|
||||
|
||||
import cn.celess.categorytag.CategoryTagBaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.TagModel;
|
||||
import cn.celess.common.mapper.TagMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,11 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.*;
|
||||
import static cn.celess.common.constant.ResponseEnum.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class TagControllerTest extends BaseTest {
|
||||
public class TagControllerTest extends CategoryTagBaseTest {
|
||||
@Autowired
|
||||
TagMapper tagMapper;
|
||||
private static final TypeReference<?> TAG_MODEL_TYPE = new TypeReference<Response<TagModel>>() {
|
||||
34
blog-comment/pom.xml
Normal file
34
blog-comment/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,18 @@
|
||||
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,8 +1,8 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.comment.controller;
|
||||
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.request.CommentReq;
|
||||
import cn.celess.blog.service.CommentService;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.dto.CommentReq;
|
||||
import cn.celess.common.service.CommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package cn.celess.blog.service.serviceimpl;
|
||||
package cn.celess.comment.serviceimpl;
|
||||
|
||||
import cn.celess.blog.enmu.CommentStatusEnum;
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.entity.Comment;
|
||||
import cn.celess.blog.entity.User;
|
||||
import cn.celess.blog.entity.model.CommentModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.CommentReq;
|
||||
import cn.celess.blog.exception.MyException;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
import cn.celess.blog.mapper.CommentMapper;
|
||||
import cn.celess.blog.mapper.UserMapper;
|
||||
import cn.celess.blog.service.CommentService;
|
||||
import cn.celess.blog.util.ModalTrans;
|
||||
import cn.celess.blog.util.RedisUserUtil;
|
||||
import cn.celess.common.constant.CommentStatusEnum;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.entity.Comment;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.common.entity.dto.CommentReq;
|
||||
import cn.celess.common.entity.vo.CommentModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.exception.BlogResponseException;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.CommentMapper;
|
||||
import cn.celess.common.mapper.UserMapper;
|
||||
import cn.celess.common.service.CommentService;
|
||||
import cn.celess.common.util.ModalTrans;
|
||||
import cn.celess.user.util.RedisUserUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class CommentServiceImpl implements CommentService {
|
||||
@Override
|
||||
public CommentModel create(CommentReq reqBody) {
|
||||
if (reqBody == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
User user = redisUserUtil.get();
|
||||
Comment pComment = null;
|
||||
@@ -55,7 +54,7 @@ public class CommentServiceImpl implements CommentService {
|
||||
//不是一级评论
|
||||
if (reqBody.getPid() != -1 && pComment == null) {
|
||||
//父评论不存在
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR);
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR);
|
||||
}
|
||||
Comment comment = new Comment();
|
||||
comment.setFromUser(user);
|
||||
@@ -76,10 +75,10 @@ public class CommentServiceImpl implements CommentService {
|
||||
public boolean delete(long id) {
|
||||
Comment b = commentMapper.findCommentById(id);
|
||||
if (b == null) {
|
||||
throw new MyException(ResponseEnum.COMMENT_NOT_EXIST);
|
||||
throw new BlogResponseException(ResponseEnum.COMMENT_NOT_EXIST);
|
||||
}
|
||||
if (b.getStatus() == CommentStatusEnum.DELETED.getCode()) {
|
||||
throw new MyException(ResponseEnum.DATA_IS_DELETED);
|
||||
throw new BlogResponseException(ResponseEnum.DATA_IS_DELETED);
|
||||
}
|
||||
commentMapper.delete(id);
|
||||
return true;
|
||||
@@ -88,7 +87,7 @@ public class CommentServiceImpl implements CommentService {
|
||||
@Override
|
||||
public CommentModel update(CommentReq reqBody) {
|
||||
if (reqBody.getId() == null) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_ERROR.getCode(), "id不可为空");
|
||||
throw new BlogResponseException(ResponseEnum.PARAMETERS_ERROR.getCode(), "id不可为空");
|
||||
}
|
||||
Comment comment = commentMapper.findCommentById(reqBody.getId());
|
||||
if (!comment.getContent().equals(reqBody.getContent())) {
|
||||
12
blog-comment/src/main/resources/banner.txt
Normal file
12
blog-comment/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
_ _ _ ____ _ _____ _
|
||||
| | | | (_) | _ \ | | / ____| | |
|
||||
| |__| | _ | |_) | | | ___ __ _ ______ | | ___ _ __ ___ _ __ ___ ___ _ __ | |_
|
||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _ \ | '_ ` _ \ | '_ ` _ \ / _ \ | '_ \ | __|
|
||||
| | | | | | | |_) | | | | (_) | | (_| | | |____ | (_) | | | | | | | | | | | | | | __/ | | | | | |_
|
||||
|_| |_| |_| |____/ |_| \___/ \__, | \_____| \___/ |_| |_| |_| |_| |_| |_| \___| |_| |_| \__|
|
||||
__/ |
|
||||
|___/
|
||||
${AnsiColor.BRIGHT_RED}
|
||||
Application Version: ${application.version}${application.formatted-version}
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
@@ -0,0 +1,11 @@
|
||||
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,27 +1,27 @@
|
||||
package cn.celess.blog.controller;
|
||||
package cn.celess.comment.controller;
|
||||
|
||||
import cn.celess.blog.BaseTest;
|
||||
import cn.celess.blog.entity.Article;
|
||||
import cn.celess.blog.entity.Comment;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.User;
|
||||
import cn.celess.blog.entity.model.CommentModel;
|
||||
import cn.celess.blog.entity.request.CommentReq;
|
||||
import cn.celess.blog.mapper.ArticleMapper;
|
||||
import cn.celess.blog.mapper.CommentMapper;
|
||||
import cn.celess.blog.mapper.UserMapper;
|
||||
import cn.celess.comment.CommentBaseTest;
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.entity.Comment;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.common.entity.dto.CommentReq;
|
||||
import cn.celess.common.entity.vo.CommentModel;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.CommentMapper;
|
||||
import cn.celess.common.mapper.UserMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.DATA_IS_DELETED;
|
||||
import static cn.celess.blog.enmu.ResponseEnum.SUCCESS;
|
||||
import static cn.celess.common.constant.ResponseEnum.DATA_IS_DELETED;
|
||||
import static cn.celess.common.constant.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class CommentControllerTest extends BaseTest {
|
||||
public class CommentControllerTest extends CommentBaseTest {
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
@Autowired
|
||||
116
blog-common/pom.xml
Normal file
116
blog-common/pom.xml
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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.3.0</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>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
<version>2.53.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- protostuff序列化依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.dyuproject.protostuff</groupId>
|
||||
<artifactId>protostuff-core</artifactId>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dyuproject.protostuff</groupId>
|
||||
<artifactId>protostuff-runtime</artifactId>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,26 @@
|
||||
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,7 +1,6 @@
|
||||
package cn.celess.blog.configuration;
|
||||
package cn.celess.common.config;
|
||||
|
||||
import cn.celess.blog.util.EnvironmentUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import cn.celess.common.util.EnvironmentUtil;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.boot.logging.DeferredLog;
|
||||
@@ -13,20 +12,11 @@ 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.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* <p>date: 2022/12/02</P>
|
||||
* <p>desc: </p>
|
||||
* <p>mail: a@celess.cn</p>
|
||||
*
|
||||
* @author 禾几海
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class CommonEnvPostProcessor implements EnvironmentPostProcessor, ApplicationListener<ApplicationEvent>, Ordered {
|
||||
public static final DeferredLog log = new DeferredLog();
|
||||
@@ -43,7 +33,7 @@ public class CommonEnvPostProcessor implements EnvironmentPostProcessor, Applica
|
||||
//获取环境变量
|
||||
String homeEnv = EnvironmentUtil.getEnv("BLOG_HOME", EnvironmentUtil.getEnv("USERPROFILE"));
|
||||
String configPath = (homeEnv + CONFIG_PATH).replaceAll("[\\|/]+", Matcher.quoteReplacement(File.separator));
|
||||
try (InputStream input = Files.newInputStream(Paths.get(configPath))) {
|
||||
try (InputStream input = new FileInputStream(configPath)) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(input);
|
||||
PropertiesPropertySource propertySource = new PropertiesPropertySource(SOURCE_NAME, properties);
|
||||
@@ -55,7 +45,7 @@ public class CommonEnvPostProcessor implements EnvironmentPostProcessor, Applica
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(@NotNull ApplicationEvent event) {
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
log.replayTo(CommonEnvPostProcessor.class);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.enmu;
|
||||
package cn.celess.common.constant;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.enmu;
|
||||
package cn.celess.common.constant;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.enmu;
|
||||
package cn.celess.common.constant;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.enmu;
|
||||
package cn.celess.common.constant;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,7 +11,7 @@ import java.util.List;
|
||||
* @date : 2019/03/28 14:51
|
||||
*/
|
||||
@Data
|
||||
public class Article {
|
||||
public class Article implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,11 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 14:52
|
||||
@@ -12,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ArticleTag {
|
||||
public class ArticleTag implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private Article article;
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:18
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class Category extends TagCategory {
|
||||
public class Category extends TagCategory implements Serializable {
|
||||
public Category(String name) {
|
||||
super.setName(name);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -10,7 +11,7 @@ import java.util.Date;
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class Comment {
|
||||
public class Comment implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 友链
|
||||
*
|
||||
@@ -9,7 +11,7 @@ import lombok.Data;
|
||||
* @date : 2019/05/12 11:33
|
||||
*/
|
||||
@Data
|
||||
public class PartnerSite {
|
||||
public class PartnerSite implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Data;
|
||||
import lombok.SneakyThrows;
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:19
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class Tag extends TagCategory {
|
||||
public class Tag extends TagCategory implements Serializable {
|
||||
|
||||
public Tag(String name) {
|
||||
super.setName(name);
|
||||
@@ -1,14 +1,16 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 14:03
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
public class TagCategory {
|
||||
public class TagCategory implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -12,7 +13,7 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class User {
|
||||
public class User implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -9,7 +10,7 @@ import java.util.Date;
|
||||
* @date : 2019/04/02 22:14
|
||||
*/
|
||||
@Data
|
||||
public class Visitor {
|
||||
public class Visitor implements Serializable {
|
||||
|
||||
private long id;
|
||||
private String ip;
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.entity;
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -9,7 +10,7 @@ import java.util.Date;
|
||||
* @date : 2019/05/12 11:29
|
||||
*/
|
||||
@Data
|
||||
public class WebUpdate {
|
||||
public class WebUpdate implements Serializable {
|
||||
|
||||
private long id;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/01 22:46
|
||||
*/
|
||||
@Data
|
||||
public class ArticleReq {
|
||||
public class ArticleReq implements Serializable {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String mdContent;
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/02 10:35
|
||||
*/
|
||||
@Data
|
||||
public class CommentReq {
|
||||
public class CommentReq implements Serializable {
|
||||
private Long id;
|
||||
private String content;
|
||||
private long pid = -1;
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2020/07/31 20:50
|
||||
*/
|
||||
@Data
|
||||
public class LinkApplyReq {
|
||||
public class LinkApplyReq implements Serializable {
|
||||
private String name;
|
||||
private String email;
|
||||
private String url;
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/02 11:40
|
||||
*/
|
||||
@Data
|
||||
public class LinkReq {
|
||||
public class LinkReq implements Serializable {
|
||||
private long id;
|
||||
private String name;
|
||||
private String url;
|
||||
@@ -1,9 +1,11 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/01 22:47
|
||||
@@ -11,7 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginReq {
|
||||
public class LoginReq implements Serializable {
|
||||
private String email;
|
||||
private String password;
|
||||
/**
|
||||
@@ -1,14 +1,16 @@
|
||||
package cn.celess.blog.entity.request;
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/09/06 13:33
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserReq {
|
||||
public class UserReq implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String email;
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -12,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ArticleModel {
|
||||
public class ArticleModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CategoryModel {
|
||||
public class CategoryModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
@@ -1,8 +1,9 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ import java.util.List;
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class CommentModel {
|
||||
public class CommentModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private UserModel fromUser;
|
||||
@@ -1,10 +1,11 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageData<T> {
|
||||
public class PageData<T> implements Serializable {
|
||||
|
||||
private List<T> list;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/21 22:43
|
||||
*/
|
||||
public class QiniuResponse {
|
||||
public class QiniuResponse implements Serializable {
|
||||
public String key;
|
||||
public String hash;
|
||||
public String bucket;
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TagModel {
|
||||
public class TagModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
@@ -1,16 +1,18 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import cn.celess.blog.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.common.constant.UserAccountStatusEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/22 23:13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserModel {
|
||||
public class UserModel implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/05 16:05
|
||||
*/
|
||||
@Data
|
||||
public class VisitorModel {
|
||||
public class VisitorModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private String ip;
|
||||
@@ -1,15 +1,17 @@
|
||||
package cn.celess.blog.entity.model;
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:32
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class WebUpdateModel {
|
||||
public class WebUpdateModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private String info;
|
||||
@@ -1,13 +1,13 @@
|
||||
package cn.celess.blog.exception;
|
||||
package cn.celess.common.exception;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.service.MailService;
|
||||
import cn.celess.blog.util.DateFormatUtil;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.service.MailService;
|
||||
import cn.celess.common.util.DateFormatUtil;
|
||||
import cn.celess.common.util.EnvironmentUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
@@ -25,21 +25,19 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*/
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandle {
|
||||
public static final Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
|
||||
public class BlogExceptionHandler {
|
||||
public static final Logger logger = LoggerFactory.getLogger(BlogExceptionHandler.class);
|
||||
@Autowired
|
||||
MailService mailService;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeModel;
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public Response handle(Exception e) {
|
||||
//自定义错误
|
||||
if (e instanceof MyException) {
|
||||
MyException exception = (MyException) e;
|
||||
if (e instanceof BlogResponseException) {
|
||||
BlogResponseException exception = (BlogResponseException) e;
|
||||
logger.debug("返回了自定义的exception,[code={},msg={},result={}]", exception.getCode(), e.getMessage(), exception.getResult());
|
||||
return new Response(exception.getCode(), e.getMessage(), exception.getResult());
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public class ExceptionHandle {
|
||||
}
|
||||
|
||||
// 发送错误信息到邮箱
|
||||
if ("prod".equals(activeModel)) {
|
||||
if ("prod".equals(EnvironmentUtil.getProperties("spring.profiles.active", "dev"))) {
|
||||
logger.debug("有一个未捕获的bug,已发送到邮箱");
|
||||
sendMessage(e);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.exception;
|
||||
package cn.celess.common.exception;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.common.constant.ResponseEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -8,32 +8,32 @@ import lombok.Data;
|
||||
* @date : 2019/03/28 16:56
|
||||
*/
|
||||
@Data
|
||||
public class MyException extends RuntimeException {
|
||||
public class BlogResponseException extends RuntimeException {
|
||||
private int code;
|
||||
private Object result;
|
||||
|
||||
public MyException(int code, String msg) {
|
||||
public BlogResponseException(int code, String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e) {
|
||||
public BlogResponseException(ResponseEnum e) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, Object result) {
|
||||
public BlogResponseException(ResponseEnum e, Object result) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, String msg) {
|
||||
public BlogResponseException(ResponseEnum e, String msg) {
|
||||
super(msg + e.getMsg());
|
||||
this.code = e.getCode();
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, String msg, Object result) {
|
||||
public BlogResponseException(ResponseEnum e, String msg, Object result) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
this.result = result;
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.Article;
|
||||
import cn.celess.common.entity.Article;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -41,8 +42,10 @@ public interface ArticleMapper {
|
||||
|
||||
List<Article> findAll();
|
||||
|
||||
@Cacheable(value = {"articleDao"}, key = "'getPreArticle:'+#id")
|
||||
Article getPreArticle(Long id);
|
||||
|
||||
@Cacheable(value = {"articleDao"}, key = "'getNextArticle:'+#id")
|
||||
Article getNextArticle(Long id);
|
||||
|
||||
int updateReadingNumber(long id);
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.ArticleTag;
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.common.entity.ArticleTag;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.Category;
|
||||
import cn.celess.common.entity.Category;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.Comment;
|
||||
import cn.celess.common.entity.Comment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.PartnerSite;
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.Tag;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.User;
|
||||
import cn.celess.common.entity.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.Visitor;
|
||||
import cn.celess.common.entity.Visitor;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.blog.entity.WebUpdate;
|
||||
import cn.celess.common.entity.WebUpdate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.ArticleModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.ArticleReq;
|
||||
import cn.celess.common.entity.dto.ArticleReq;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.CategoryModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.common.entity.vo.CategoryModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -1,8 +1,9 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.CommentModel;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.CommentReq;
|
||||
|
||||
import cn.celess.common.entity.dto.CommentReq;
|
||||
import cn.celess.common.entity.vo.CommentModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.PartnerSite;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.request.LinkApplyReq;
|
||||
import cn.celess.blog.entity.request.LinkReq;
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import cn.celess.common.entity.dto.LinkApplyReq;
|
||||
import cn.celess.common.entity.dto.LinkReq;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.QiniuResponse;
|
||||
import cn.celess.common.entity.vo.QiniuResponse;
|
||||
import com.qiniu.storage.model.FileInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.TagModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.TagModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.UserModel;
|
||||
import cn.celess.blog.entity.request.LoginReq;
|
||||
import cn.celess.blog.entity.request.UserReq;
|
||||
import cn.celess.common.entity.dto.LoginReq;
|
||||
import cn.celess.common.entity.dto.UserReq;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.UserModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.VisitorModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.VisitorModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.celess.blog.service;
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
import cn.celess.blog.entity.model.WebUpdateModel;
|
||||
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.WebUpdateModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,41 @@
|
||||
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,12 +1,12 @@
|
||||
package cn.celess.blog;
|
||||
package cn.celess.common.test;
|
||||
|
||||
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.model.QiniuResponse;
|
||||
import cn.celess.blog.entity.model.UserModel;
|
||||
import cn.celess.blog.entity.request.LoginReq;
|
||||
import cn.celess.blog.service.MailService;
|
||||
import cn.celess.blog.service.QiniuService;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.dto.LoginReq;
|
||||
import cn.celess.common.entity.vo.QiniuResponse;
|
||||
import cn.celess.common.entity.vo.UserModel;
|
||||
import cn.celess.common.service.MailService;
|
||||
import cn.celess.common.service.QiniuService;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -14,22 +14,21 @@ import com.qiniu.storage.model.FileInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
@@ -40,23 +39,18 @@ import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static cn.celess.common.constant.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/08/22 12:46
|
||||
* @Description: 测试基类
|
||||
*/
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("test")
|
||||
public class BaseTest {
|
||||
|
||||
public abstract class BaseTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@@ -69,7 +63,6 @@ public class BaseTest {
|
||||
/**
|
||||
* jackson 序列化/反序列化Json
|
||||
*/
|
||||
protected final ObjectMapper mapper = new ObjectMapper();
|
||||
protected static final TypeReference<?> BOOLEAN_TYPE = new TypeReference<Response<Boolean>>() {
|
||||
};
|
||||
protected static final TypeReference<?> STRING_TYPE = new TypeReference<Response<String>>() {
|
||||
@@ -134,9 +127,9 @@ public class BaseTest {
|
||||
protected String login(LoginReq req) {
|
||||
String str = null;
|
||||
try {
|
||||
str = getMockData(post("/login"), null, req)
|
||||
str = getMockData(MockMvcRequestBuilders.post("/login"), null, req)
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
Response<UserModel> response = mapper.readValue(str, new TypeReference<Response<UserModel>>() {
|
||||
Response<UserModel> response = new ObjectMapper().readValue(str, new TypeReference<Response<UserModel>>() {
|
||||
});
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
String token = response.getResult().getToken();
|
||||
@@ -150,20 +143,6 @@ public class BaseTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// 测试登录
|
||||
assertNotNull(userLogin());
|
||||
assertNotNull(adminLogin());
|
||||
assertNotEquals(userLogin(), adminLogin());
|
||||
try {
|
||||
// 测试getMockData方法
|
||||
assertNotNull(getMockData(get("/headerInfo")));
|
||||
getMockData((get("/headerInfo"))).andDo(result -> assertNotNull(getResponse(result, OBJECT_TYPE)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 产生指定长度的随机字符
|
||||
@@ -222,10 +201,11 @@ public class BaseTest {
|
||||
builder.header("Authorization", "Bearer "+token);
|
||||
}
|
||||
if (content != null) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
builder.content(mapper.writeValueAsString(content)).contentType(MediaType.APPLICATION_JSON);
|
||||
logger.debug("param::json->{}", mapper.writeValueAsString(content));
|
||||
}
|
||||
return mockMvc.perform(builder).andExpect(status().isOk());
|
||||
return mockMvc.perform(builder).andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +227,8 @@ public class BaseTest {
|
||||
protected <T> Response<T> getResponse(String json, TypeReference<?> responseType) {
|
||||
Response<T> response = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
|
||||
response = mapper.readValue(json, responseType);
|
||||
} catch (IOException e) {
|
||||
logger.error("解析json Response对象错误,json:[{}]", json);
|
||||
@@ -294,6 +276,7 @@ public class BaseTest {
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service("mailService")
|
||||
public static class TestMailServiceImpl implements MailService {
|
||||
|
||||
@Override
|
||||
@@ -325,6 +308,7 @@ public class BaseTest {
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
@Service("qiniuService")
|
||||
public static class TestQiNiuServiceImpl implements QiniuService {
|
||||
@Override
|
||||
public QiniuResponse uploadFile(InputStream is, String fileName) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
@@ -1,17 +1,9 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* <p>date: 2022/12/02</P>
|
||||
* <p>desc: </p>
|
||||
* <p>mail: a@celess.cn</p>
|
||||
*
|
||||
* @author 禾几海
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class EnvironmentUtil {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import com.gargoylesoftware.htmlunit.BrowserVersion;
|
||||
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
|
||||
import com.gargoylesoftware.htmlunit.Page;
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
@@ -17,23 +15,37 @@ import java.util.Objects;
|
||||
* @Desc:
|
||||
*/
|
||||
public class HttpUtil {
|
||||
private static final OkHttpClient CLIENT = new OkHttpClient();
|
||||
|
||||
public static String get(String urlStr) {
|
||||
Request request = new Request.Builder()
|
||||
.url(urlStr)
|
||||
.get()
|
||||
.build();
|
||||
try (Response response = CLIENT.newCall(request).execute()) {
|
||||
return Objects.requireNonNull(response.body()).string();
|
||||
/**
|
||||
* 获取http请求的响应
|
||||
*
|
||||
* @param url url链接
|
||||
* @return 请求的响应
|
||||
*/
|
||||
public static String getHttpResponse(String url) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
webClient.getOptions().setJavaScriptEnabled(false);
|
||||
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
|
||||
webClient.getOptions().setThrowExceptionOnScriptError(false);
|
||||
webClient.getOptions().setDownloadImages(false);
|
||||
webClient.getOptions().setActiveXNative(false);
|
||||
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
|
||||
Page clientPage = webClient.getPage(url);
|
||||
return clientPage.getWebResponse().getContentAsString();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取渲染后的网页数据
|
||||
*
|
||||
* @param url url链接
|
||||
* @return 经js渲染后的网页源代码
|
||||
*/
|
||||
public static String getAfterRendering(String url) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
webClient.getOptions().setJavaScriptEnabled(true);
|
||||
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
|
||||
@@ -1,8 +1,9 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import cn.celess.blog.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.blog.entity.*;
|
||||
import cn.celess.blog.entity.model.*;
|
||||
|
||||
import cn.celess.common.constant.UserAccountStatusEnum;
|
||||
import cn.celess.common.entity.*;
|
||||
import cn.celess.common.entity.vo.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import com.dyuproject.protostuff.LinkedBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -1369,12 +1369,9 @@ public class RedisUtil {
|
||||
public <T> boolean putListCacheWithExpireTime(String key, List<T> objList, final long expireTime) {
|
||||
final byte[] bkey = key.getBytes();
|
||||
final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
|
||||
boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
boolean result = redisTemplate.execute((RedisCallback<Boolean>) connection -> {
|
||||
connection.setEx(bkey, expireTime, bvalue);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -0,0 +1,42 @@
|
||||
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,4 +1,4 @@
|
||||
package cn.celess.blog.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
@@ -79,9 +79,8 @@ public class VeriCodeUtil {
|
||||
*/
|
||||
public static Color getRandomColor() {
|
||||
Random ran = new Random();
|
||||
Color color = new Color(ran.nextInt(256),
|
||||
return new Color(ran.nextInt(256),
|
||||
ran.nextInt(256), ran.nextInt(256));
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
2
blog-common/src/main/resources/META-INF/spring.factories
Normal file
2
blog-common/src/main/resources/META-INF/spring.factories
Normal file
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=cn.celess.common.config.CommonEnvPostProcessor
|
||||
org.springframework.context.ApplicationListener=cn.celess.common.config.CommonEnvPostProcessor
|
||||
12
blog-common/src/main/resources/banner.txt
Normal file
12
blog-common/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
_ _ _ ____ _ _____
|
||||
| | | | (_) | _ \ | | / ____|
|
||||
| |__| | _ | |_) | | | ___ __ _ ______ | | ___ _ __ ___ _ __ ___ ___ _ __
|
||||
| __ | | | | _ < | | / _ \ / _` | |______| | | / _ \ | '_ ` _ \ | '_ ` _ \ / _ \ | '_ \
|
||||
| | | | | | | |_) | | | | (_) | | (_| | | |____ | (_) | | | | | | | | | | | | | | (_) | | | | |
|
||||
|_| |_| |_| |____/ |_| \___/ \__, | \_____| \___/ |_| |_| |_| |_| |_| |_| \___/ |_| |_|
|
||||
__/ |
|
||||
|___/
|
||||
${AnsiColor.BRIGHT_RED}
|
||||
Application Version: ${application.version}${application.formatted-version}
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
BIN
blog-common/src/main/resources/lib/jconsole.jar
Normal file
BIN
blog-common/src/main/resources/lib/jconsole.jar
Normal file
Binary file not shown.
BIN
blog-common/src/main/resources/lib/tools.jar
Normal file
BIN
blog-common/src/main/resources/lib/tools.jar
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user