Compare commits
75 Commits
feat-multl
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bc627817f | ||
|
|
c8e93c45c7 | ||
|
|
32de31a21e | ||
|
|
cc20df91e6 | ||
|
|
71d79ed008 | ||
|
|
f7ff494ea4 | ||
|
|
971f48c5f9 | ||
|
|
e1522a8cc1 | ||
|
|
3cc4989960 | ||
|
|
8c751e6e76 | ||
|
|
af47631126 | ||
|
|
2107a1c100 | ||
|
|
2eac16dbe4 | ||
|
|
d248e15cea | ||
|
|
91a818d293 | ||
|
|
65c31e96b4 | ||
|
|
81b4851e42 | ||
|
|
9c580cf6d9 | ||
|
|
9eea5b3db9 | ||
|
|
eacb2e29f3 | ||
|
|
fafee4f918 | ||
|
|
30a4c11366 | ||
|
|
5632d47674 | ||
|
|
15b5d89554 | ||
|
|
79426dbe24 | ||
|
|
b3b19dbc45 | ||
|
|
87ec6d24ca | ||
|
|
0148c5e3f5 | ||
|
|
7cff3b9c08 | ||
|
|
a354f48edf | ||
|
|
2cd2dc93d7 | ||
|
|
d5fbc0fbf1 | ||
|
|
b29362eb8c | ||
|
|
d7c6cca683 | ||
|
|
8020eaeff3 | ||
|
|
aedcaf207b | ||
|
|
af9bf9ef46 | ||
|
|
b38ce4c8ce | ||
|
|
3d3548b984 | ||
|
|
4be9eda566 | ||
|
|
e5711746fb | ||
|
|
cc9cf8b1e8 | ||
|
|
ff076f8366 | ||
|
|
dd9ae0b3f9 | ||
|
|
0e7d5f2d23 | ||
|
|
1de1af2a54 | ||
|
|
857a3d9473 | ||
|
|
78efa62476 | ||
|
|
674812c5c6 | ||
|
|
14ce46c312 | ||
|
|
5f5fbadfd8 | ||
|
|
c153d9a0e3 | ||
|
|
18d35809f5 | ||
|
|
75e2424f75 | ||
|
|
b6c4251198 | ||
|
|
fc1bfa0e4f | ||
|
|
e37de0e177 | ||
|
|
082662af66 | ||
|
|
0c0e2404d0 | ||
|
|
71f82bfe32 | ||
|
|
61ce2fddad | ||
|
|
a245f259f7 | ||
|
|
aa22369b13 | ||
|
|
8c3866afe6 | ||
|
|
2c85c3eaac | ||
|
|
2559937e02 | ||
|
|
8de4be602e | ||
|
|
1f88995884 | ||
|
|
c879fbff5f | ||
|
|
f6020bf8d0 | ||
|
|
418b1d78e5 | ||
|
|
98ed489bb1 | ||
|
|
cfdd818829 | ||
|
|
3afbef009f | ||
|
|
8f4d1cd6c8 |
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "maven" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@@ -10,7 +10,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '.md')" # 如果 commit 信息包含以下关键字则跳过该任务
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
KEY: ${{ secrets.WEB_HOOK_ACCESS_KEY }}
|
KEY: ${{ secrets.WEB_HOOK_ACCESS_KEY }}
|
||||||
@@ -22,5 +22,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 1.8
|
||||||
|
|
||||||
|
- name: Sync repository
|
||||||
|
uses: x-dr/sync-repo-to-gitee@v1.0
|
||||||
|
env:
|
||||||
|
# 在 Settings->Secrets 配置 GITEE_KEY
|
||||||
|
SSH_KEY: ${{ secrets.GITEE_KEY }}
|
||||||
|
with:
|
||||||
|
# GitHub存储库的SSH URL.
|
||||||
|
github-repo: git@github.com:xiaohai2271/blog-backEnd.git
|
||||||
|
# Gitee存储库的SSH URL.
|
||||||
|
gitee-repo: git@gitee.com:xiaohai2271/blog-backEnd.git
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: mvn -B test --file pom.xml && curl http://bt.celess.cn:2271/hook?access_key=$KEY
|
run: mvn -B test --file pom.xml && curl http://bt.celess.cn:2271/hook?access_key=$KEY
|
||||||
|
|||||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -10,7 +10,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '.md')" # 如果 commit 信息包含以下关键字则跳过该任务
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# env:
|
# env:
|
||||||
# APPLICATION_PROPERTIES_TEST: ${{ secrets.APPLICATION_PROPERTIES_TEST }}
|
# APPLICATION_PROPERTIES_TEST: ${{ secrets.APPLICATION_PROPERTIES_TEST }}
|
||||||
|
|||||||
36
pom.xml
36
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.1.3.RELEASE</version>
|
<version>2.1.3.RELEASE</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>cn.celess</groupId>
|
<groupId>cn.celess</groupId>
|
||||||
<artifactId>blog</artifactId>
|
<artifactId>blog</artifactId>
|
||||||
@@ -40,14 +40,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid</artifactId>
|
<artifactId>druid</artifactId>
|
||||||
<version>1.1.14</version>
|
<version>1.2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- lombok -->
|
<!-- lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.6</version>
|
<version>1.18.20</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
@@ -67,12 +67,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.youbenzi</groupId>
|
<groupId>com.youbenzi</groupId>
|
||||||
<artifactId>MDTool</artifactId>
|
<artifactId>MDTool</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.minidev</groupId>
|
<groupId>net.minidev</groupId>
|
||||||
<artifactId>json-smart</artifactId>
|
<artifactId>json-smart</artifactId>
|
||||||
<version>2.3</version>
|
<version>2.4.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -99,39 +99,39 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis.spring.boot</groupId>
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- pageHelper -->
|
<!-- pageHelper -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>1.2.12</version>
|
<version>1.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- protostuff序列化依赖 -->
|
<!-- protostuff序列化依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dyuproject.protostuff</groupId>
|
<groupId>com.dyuproject.protostuff</groupId>
|
||||||
<artifactId>protostuff-core</artifactId>
|
<artifactId>protostuff-core</artifactId>
|
||||||
<version>1.0.8</version>
|
<version>1.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dyuproject.protostuff</groupId>
|
<groupId>com.dyuproject.protostuff</groupId>
|
||||||
<artifactId>protostuff-runtime</artifactId>
|
<artifactId>protostuff-runtime</artifactId>
|
||||||
<version>1.0.8</version>
|
<version>1.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Ua解析-->
|
<!-- Ua解析-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.bitwalker</groupId>
|
<groupId>eu.bitwalker</groupId>
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
<version>1.20</version>
|
<version>1.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>4.13.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JJwt -->
|
<!-- JJwt -->
|
||||||
@@ -145,12 +145,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.8.0</version>
|
<version>4.9.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>1.3.72</version>
|
<version>1.4.20</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sourceforge.htmlunit</groupId>
|
<groupId>net.sourceforge.htmlunit</groupId>
|
||||||
<artifactId>htmlunit</artifactId>
|
<artifactId>htmlunit</artifactId>
|
||||||
<version>2.42.0</version>
|
<version>2.45.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
@@ -178,17 +178,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>2.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>2.3.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.activation</groupId>
|
<groupId>javax.activation</groupId>
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
<version>1.3.72</version>
|
<version>1.5.10</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>compile</id>
|
<id>compile</id>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.celess.blog.mapper;
|
package cn.celess.blog.mapper;
|
||||||
|
|
||||||
import cn.celess.blog.entity.ArticleTag;
|
import cn.celess.blog.entity.ArticleTag;
|
||||||
|
import cn.celess.blog.entity.Tag;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ public interface ArticleTagMapper {
|
|||||||
|
|
||||||
List<ArticleTag> findAllByArticleId(Long articleId);
|
List<ArticleTag> findAllByArticleId(Long articleId);
|
||||||
|
|
||||||
|
List<Tag> findTagByArticleId(Long articleId);
|
||||||
|
|
||||||
int deleteMultiById(List<ArticleTag> articleTags);
|
int deleteMultiById(List<ArticleTag> articleTags);
|
||||||
|
|
||||||
List<ArticleTag> findArticleByTag(Long tagId);
|
List<ArticleTag> findArticleByTag(Long tagId);
|
||||||
|
|||||||
@@ -279,21 +279,20 @@ public class ArticleServiceImpl implements ArticleService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageData<ArticleModel> adminArticles(int count, int page, Boolean deleted) {
|
public PageData<ArticleModel> adminArticles(int count, int page, Boolean deleted) {
|
||||||
|
PageHelper.startPage(page, count);
|
||||||
List<Article> articleList = articleMapper.findAll();
|
List<Article> articleList = articleMapper.findAll();
|
||||||
|
|
||||||
PageData<ArticleModel> pageData = new PageData<>(null, 0, count, page);
|
PageData<ArticleModel> pageData = new PageData<>(new PageInfo<>(articleList));
|
||||||
|
|
||||||
List<Article> collect;
|
List<Article> collect;
|
||||||
if (deleted != null) {
|
if (deleted != null) {
|
||||||
collect = articleList.stream().filter(article -> article.isDeleted() == deleted).collect(Collectors.toList());
|
collect = articleList.stream().filter(article -> article.isDeleted() == deleted).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
collect = articleList;
|
collect = articleList;
|
||||||
}
|
}
|
||||||
pageData.setTotal(collect.size());
|
|
||||||
List<ArticleModel> articleModels = collect.stream()
|
List<ArticleModel> articleModels = collect.stream()
|
||||||
.peek(article -> article.setMdContent(null))
|
.peek(article -> article.setMdContent(null))
|
||||||
.map(ModalTrans::article)
|
.map(ModalTrans::article)
|
||||||
.skip((page - 1) * count)
|
|
||||||
.limit(count)
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
pageData.setList(articleModels);
|
pageData.setList(articleModels);
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class JwtUtil {
|
|||||||
*/
|
*/
|
||||||
public static final long EXPIRATION_SHORT_TIME = 7200000;
|
public static final long EXPIRATION_SHORT_TIME = 7200000;
|
||||||
private static final String CLAIM_KEY_USERNAME = "sub";
|
private static final String CLAIM_KEY_USERNAME = "sub";
|
||||||
|
private static final String BEARER_PREFIX_UPPER = "Bearer";
|
||||||
|
private static final String BEARER_PREFIX_LOWER = "bearer";
|
||||||
/**
|
/**
|
||||||
* JWT 秘钥需自行设置不可泄露
|
* JWT 秘钥需自行设置不可泄露
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +50,7 @@ public class JwtUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String updateTokenDate(String token) {
|
public String updateTokenDate(String token) {
|
||||||
Claims claims = Jwts.parser().setSigningKey(SECRET).parseClaimsJws(token).getBody();
|
Claims claims = Jwts.parser().setSigningKey(SECRET).parseClaimsJws(getJwtString(token)).getBody();
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.setExpiration(new Date(claims.getExpiration().getTime() + EXPIRATION_SHORT_TIME))
|
.setExpiration(new Date(claims.getExpiration().getTime() + EXPIRATION_SHORT_TIME))
|
||||||
@@ -60,7 +62,7 @@ public class JwtUtil {
|
|||||||
* 获取token是否过期
|
* 获取token是否过期
|
||||||
*/
|
*/
|
||||||
public Boolean isTokenExpired(String token) {
|
public Boolean isTokenExpired(String token) {
|
||||||
Date expiration = getExpirationDateFromToken(token);
|
Date expiration = getExpirationDateFromToken(getJwtString(token));
|
||||||
return expiration == null || expiration.before(new Date());
|
return expiration == null || expiration.before(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ public class JwtUtil {
|
|||||||
* 根据token获取username
|
* 根据token获取username
|
||||||
*/
|
*/
|
||||||
public String getUsernameFromToken(String token) {
|
public String getUsernameFromToken(String token) {
|
||||||
Claims claims = getClaimsFromToken(token);
|
Claims claims = getClaimsFromToken(getJwtString(token));
|
||||||
return claims == null ? null : claims.getSubject();
|
return claims == null ? null : claims.getSubject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ public class JwtUtil {
|
|||||||
* 获取token的过期时间
|
* 获取token的过期时间
|
||||||
*/
|
*/
|
||||||
public Date getExpirationDateFromToken(String token) {
|
public Date getExpirationDateFromToken(String token) {
|
||||||
Claims claims = getClaimsFromToken(token);
|
Claims claims = getClaimsFromToken(getJwtString(token));
|
||||||
return claims == null ? null : claims.getExpiration();
|
return claims == null ? null : claims.getExpiration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +90,7 @@ public class JwtUtil {
|
|||||||
try {
|
try {
|
||||||
claims = Jwts.parser()
|
claims = Jwts.parser()
|
||||||
.setSigningKey(SECRET)
|
.setSigningKey(SECRET)
|
||||||
.parseClaimsJws(token)
|
.parseClaimsJws(getJwtString(token))
|
||||||
.getBody();
|
.getBody();
|
||||||
} catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
log.info("JWT令牌过期");
|
log.info("JWT令牌过期");
|
||||||
@@ -107,4 +109,9 @@ public class JwtUtil {
|
|||||||
return claims;
|
return claims;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getJwtString(String token) {
|
||||||
|
if (token == null) return token;
|
||||||
|
return token.replaceFirst(BEARER_PREFIX_UPPER, "").replace(BEARER_PREFIX_LOWER, "");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,14 @@
|
|||||||
and article_tag.t_id = tag_category.t_id
|
and article_tag.t_id = tag_category.t_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="findTagByArticleId" resultMap="cn.celess.blog.mapper.TagMapper.tagResultMap">
|
||||||
|
select tag_category.*
|
||||||
|
from article_tag,
|
||||||
|
tag_category
|
||||||
|
where a_id = #{articleId}
|
||||||
|
and article_tag.t_id = tag_category.t_id
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="findOneById" resultMap="articleTagResultMap">
|
<select id="findOneById" resultMap="articleTagResultMap">
|
||||||
select *
|
select *
|
||||||
from article_tag,
|
from article_tag,
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
<association property="category" column="a_category_id" javaType="cn.celess.blog.entity.TagCategory"
|
<association property="category" column="a_category_id" javaType="cn.celess.blog.entity.TagCategory"
|
||||||
resultMap="cn.celess.blog.mapper.CategoryMapper.categoryResultMap">
|
resultMap="cn.celess.blog.mapper.CategoryMapper.categoryResultMap">
|
||||||
</association>
|
</association>
|
||||||
<collection property="tags" ofType="cn.celess.blog.entity.TagCategory"
|
<collection property="tags" ofType="cn.celess.blog.entity.Tag"
|
||||||
resultMap="cn.celess.blog.mapper.CategoryMapper.categoryResultMap">
|
select="cn.celess.blog.mapper.ArticleTagMapper.findTagByArticleId" column="a_id">
|
||||||
|
<id column="tagId" property="id"/>
|
||||||
|
<result column="tagName" property="name"/>
|
||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@@ -49,7 +51,8 @@
|
|||||||
<result column="userAvatar" property="avatarImgUrl"/>
|
<result column="userAvatar" property="avatarImgUrl"/>
|
||||||
<result column="userDisplayName" property="displayName"/>
|
<result column="userDisplayName" property="displayName"/>
|
||||||
</association>
|
</association>
|
||||||
<collection property="tags" ofType="cn.celess.blog.entity.Tag">
|
<collection property="tags" ofType="cn.celess.blog.entity.Tag"
|
||||||
|
select="cn.celess.blog.mapper.ArticleTagMapper.findTagByArticleId" column="{articleId=articleId}">
|
||||||
<id column="tagId" property="id"/>
|
<id column="tagId" property="id"/>
|
||||||
<result column="tagName" property="name"/>
|
<result column="tagName" property="name"/>
|
||||||
</collection>
|
</collection>
|
||||||
@@ -119,11 +122,37 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAllByOpen" resultMap="articleViewResultMap">
|
<select id="findAllByOpen" resultMap="articleViewResultMap">
|
||||||
select *
|
select article.a_id as articleId,
|
||||||
from articleView
|
article.a_title as title,
|
||||||
where isOpen = #{isOpen}
|
article.a_summary as summary,
|
||||||
and isDelete = false
|
article.a_md_content as mdContent,
|
||||||
order by articleId desc
|
article.a_url as url,
|
||||||
|
article.a_is_original as isOriginal,
|
||||||
|
article.a_reading_number as readingCount,
|
||||||
|
article.a_like as likeCount,
|
||||||
|
article.a_dislike as dislikeCount,
|
||||||
|
article.a_publish_date as publishDate,
|
||||||
|
article.a_update_date as updateDate,
|
||||||
|
article.a_is_open as isOpen,
|
||||||
|
category.t_id as categoryId,
|
||||||
|
category.t_name as categoryName,
|
||||||
|
user.u_id as authorId,
|
||||||
|
user.u_email as userEmail,
|
||||||
|
user.u_avatar as userAvatar,
|
||||||
|
user.u_display_name as userDisplayName,
|
||||||
|
article.is_delete as isDelete
|
||||||
|
from article,
|
||||||
|
tag_category as category,
|
||||||
|
article_tag,
|
||||||
|
user
|
||||||
|
where article.a_is_open = #{isOpen}
|
||||||
|
and article.is_delete = false
|
||||||
|
and article.a_id = article_tag.a_id
|
||||||
|
and article.a_category_id = category.t_id
|
||||||
|
and category.is_category = true
|
||||||
|
and article.a_author_id = user.u_id
|
||||||
|
group by article.a_id
|
||||||
|
order by article.a_id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -152,9 +181,35 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="findAll" resultMap="articleViewResultMap">
|
<select id="findAll" resultMap="articleViewResultMap">
|
||||||
select *
|
select article.a_id as articleId,
|
||||||
from articleView
|
article.a_title as title,
|
||||||
order by articleId desc
|
article.a_summary as summary,
|
||||||
|
article.a_md_content as mdContent,
|
||||||
|
article.a_url as url,
|
||||||
|
article.a_is_original as isOriginal,
|
||||||
|
article.a_reading_number as readingCount,
|
||||||
|
article.a_like as likeCount,
|
||||||
|
article.a_dislike as dislikeCount,
|
||||||
|
article.a_publish_date as publishDate,
|
||||||
|
article.a_update_date as updateDate,
|
||||||
|
article.a_is_open as isOpen,
|
||||||
|
category.t_id as categoryId,
|
||||||
|
category.t_name as categoryName,
|
||||||
|
user.u_id as authorId,
|
||||||
|
user.u_email as userEmail,
|
||||||
|
user.u_avatar as userAvatar,
|
||||||
|
user.u_display_name as userDisplayName,
|
||||||
|
article.is_delete as isDelete
|
||||||
|
from article,
|
||||||
|
tag_category as category,
|
||||||
|
article_tag,
|
||||||
|
user
|
||||||
|
where article.a_id = article_tag.a_id
|
||||||
|
and article.a_category_id = category.t_id
|
||||||
|
and category.is_category = true
|
||||||
|
and article.a_author_id = user.u_id
|
||||||
|
group by article.a_id
|
||||||
|
order by article.a_id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -169,7 +224,8 @@
|
|||||||
from articleView
|
from articleView
|
||||||
where articleId = (select max(articleId)
|
where articleId = (select max(articleId)
|
||||||
from articleView
|
from articleView
|
||||||
where articleId < #{id}
|
where isOpen = true
|
||||||
|
and articleId < #{id}
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
<select id="getNextArticle" resultMap="articleViewResultMap">
|
<select id="getNextArticle" resultMap="articleViewResultMap">
|
||||||
@@ -177,7 +233,8 @@
|
|||||||
from articleView
|
from articleView
|
||||||
where articleId = (select min(articleId)
|
where articleId = (select min(articleId)
|
||||||
from articleView
|
from articleView
|
||||||
where articleId > #{id}
|
where isOpen = true
|
||||||
|
and articleId > #{id}
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class BaseTest {
|
|||||||
protected ResultActions getMockData(MockHttpServletRequestBuilder builder, String token, Object content) throws Exception {
|
protected ResultActions getMockData(MockHttpServletRequestBuilder builder, String token, Object content) throws Exception {
|
||||||
// MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get(url);
|
// MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get(url);
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
builder.header("Authorization", token);
|
builder.header("Authorization", "Bearer "+token);
|
||||||
}
|
}
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
builder.content(mapper.writeValueAsString(content)).contentType(MediaType.APPLICATION_JSON);
|
builder.content(mapper.writeValueAsString(content)).contentType(MediaType.APPLICATION_JSON);
|
||||||
|
|||||||
@@ -134,4 +134,13 @@ public class ArticleTagMapperTest extends BaseTest {
|
|||||||
|
|
||||||
return articleTag;
|
return articleTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findTagByArticleId() {
|
||||||
|
Article article = articleMapper.findAll().get(0);
|
||||||
|
assertNotNull(article);
|
||||||
|
|
||||||
|
List<Tag> tagByArticleId = articleTagMapper.findTagByArticleId(article.getId());
|
||||||
|
assertNotEquals(0, tagByArticleId.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@ package cn.celess.blog.service;
|
|||||||
import cn.celess.blog.BaseTest;
|
import cn.celess.blog.BaseTest;
|
||||||
import cn.celess.blog.entity.model.ArticleModel;
|
import cn.celess.blog.entity.model.ArticleModel;
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
|
import cn.celess.blog.mapper.ArticleMapper;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -12,6 +14,8 @@ public class ArticleServiceTest extends BaseTest {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ArticleService articleService;
|
ArticleService articleService;
|
||||||
|
@Autowired
|
||||||
|
ArticleMapper articleMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void adminArticles() {
|
public void adminArticles() {
|
||||||
@@ -24,4 +28,25 @@ public class ArticleServiceTest extends BaseTest {
|
|||||||
assertTrue(pageData.getList().stream().anyMatch(ArticleModel::isDeleted));
|
assertTrue(pageData.getList().stream().anyMatch(ArticleModel::isDeleted));
|
||||||
assertTrue(pageData.getList().stream().anyMatch(articleModel -> !articleModel.isDeleted()));
|
assertTrue(pageData.getList().stream().anyMatch(articleModel -> !articleModel.isDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void retrievePageForOpen() {
|
||||||
|
PageData<ArticleModel> articleModelPageData = articleService.retrievePageForOpen(10, 1);
|
||||||
|
assertEquals(10, articleModelPageData.getPageSize());
|
||||||
|
assertEquals(1, articleModelPageData.getPageNum());
|
||||||
|
assertEquals(10, articleModelPageData.getList().size());
|
||||||
|
articleModelPageData.getList().forEach(Assert::assertNotNull);
|
||||||
|
|
||||||
|
// 测试open字段
|
||||||
|
articleModelPageData.getList().forEach(articleModel -> {
|
||||||
|
// 当前文章
|
||||||
|
assertTrue(articleMapper.findArticleById(articleModel.getId()).getOpen());
|
||||||
|
if (articleModel.getPreArticle() != null) {
|
||||||
|
assertTrue(articleMapper.findArticleById(articleModel.getPreArticle().getId()).getOpen());
|
||||||
|
}
|
||||||
|
if (articleModel.getNextArticle() != null) {
|
||||||
|
assertTrue(articleMapper.findArticleById(articleModel.getNextArticle().getId()).getOpen());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user