1. 修正分类页下拉
2. 隐藏移动端手机阅读量
3. 更新SpringBoot版本为2.3.0
4. 修正版本更新后JPA语法失效问题
This commit is contained in:
josxy 2021-04-24 16:29:24 +08:00
parent fdc65c125f
commit 809a753e18
9 changed files with 163 additions and 160 deletions

268
pom.xml
View File

@ -1,152 +1,150 @@
<?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">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.allms</groupId>
<artifactId>blog</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<groupId>cn.allms</groupId>
<artifactId>blog</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>blog</name>
<description>Demo project for Spring Boot</description>
<name>blog</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<!--设置tymeleaf的版本-->
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--引入Markdown转HTML的插件-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.10.0</version>
</dependency>
<!--扩展 标题-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark-ext-heading-anchor</artifactId>
<version>0.10.0</version>
</dependency>
<!--扩展 表格-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark-ext-gfm-tables</artifactId>
<version>0.10.0</version>
</dependency>
<dependencies>
<!--jpa-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--devtools-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--aop-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!--引入Markdown转HTML的插件-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.10.0</version>
</dependency>
<!--扩展 标题-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark-ext-heading-anchor</artifactId>
<version>0.10.0</version>
</dependency>
<!--扩展 表格-->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark-ext-gfm-tables</artifactId>
<version>0.10.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.5.Final</version>
</dependency>
<!--配置文件:注解-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<!--服务监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin>-->
<!-- <groupId>com.spotify</groupId>-->
<!-- <artifactId>docker-maven-plugin</artifactId>-->
<!-- <version>1.2.0</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>build-image</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>build</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <configuration>-->
<!-- <dockerHost>http://103.153.100.47:2375</dockerHost>-->
<!-- <imageName>mx/${project.artifactId}</imageName>-->
<!-- <imageTags>-->
<!-- <imageTag>${project.version}</imageTag>-->
<!-- </imageTags>-->
<!-- <forceTags>true</forceTags>-->
<!-- <dockerDirectory>${project.basedir}</dockerDirectory>-->
<!-- <resources>-->
<!-- <resource>-->
<!-- <targetPath>/</targetPath>-->
<!-- <directory>${project.build.directory}</directory>-->
<!-- <include>${project.build.finalName}.jar</include>-->
<!-- </resource>-->
<!-- </resources>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -37,12 +37,12 @@ public class BlogServiceImpl implements BlogService
@Override
public Blog getBlog(Long id) {
return blogRepository.findOne(id);
return blogRepository.findById(id).orElse(null);
}
@Override
public Blog getAadConvertBlog(Long id) {
Blog blog = blogRepository.findOne(id);
Blog blog = blogRepository.findById(id).orElse(null);
if (blog == null){
throw new NotFoundException("该博客不存在!");
}
@ -105,8 +105,8 @@ public class BlogServiceImpl implements BlogService
@Override
public List<Blog> listRecommendBlogTop(Integer size) {
Sort sort = new Sort(Sort.Direction.DESC,"updateTime");
Pageable pageable = new PageRequest(0,size,sort);
Sort sort = Sort.by(Sort.Direction.DESC,"updateTime");
Pageable pageable = PageRequest.of(0,size,sort);
return blogRepository.findTop(pageable);
}
@ -148,7 +148,7 @@ public class BlogServiceImpl implements BlogService
@Transactional
@Override
public Blog updateBlog(Long id, Blog blog) {
Blog b = blogRepository.findOne(id);
Blog b = blogRepository.findById(id).orElse(null);
//判断是否存在这条数据
if(b == null){
throw new NotFoundException("该博客不存在");
@ -159,9 +159,9 @@ public class BlogServiceImpl implements BlogService
return blogRepository.save(b);
}
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override
public void deleteBlog(Long id) {
blogRepository.delete(id);
blogRepository.deleteById(id);
}
}

View File

@ -26,7 +26,7 @@ public class CommentServiceImpl implements CommentService {
@Override
public List<Comment> listCommentByBlogId(Long blogId) {
Sort sort = new Sort("createTime");
Sort sort = Sort.by("createTime");
List<Comment> comments = commentRepository.findByBlogIdAndParentCommentNull(blogId,sort);
return CommentUtil.eachComment(comments);
}
@ -38,7 +38,7 @@ public class CommentServiceImpl implements CommentService {
Long parentCommentId = comment.getParentComment().getId();
System.out.println(parentCommentId);
if(parentCommentId != -1){
comment.setParentComment(commentRepository.findOne(parentCommentId));
comment.setParentComment(commentRepository.findById(parentCommentId).orElse(null));
} else {
//发布评论:
comment.setParentComment(null);

View File

@ -35,7 +35,7 @@ public class TagServiceImpl implements TagService {
@Override
public Tag getTag(Long id) {
return tagRepository.findOne(id);
return tagRepository.findById(id).orElse(null);
}
@Override
@ -45,8 +45,8 @@ public class TagServiceImpl implements TagService {
@Override
public List<Tag> ListTagTop(Integer size) {
Sort sort = new Sort(Sort.Direction.DESC,"blogs.size");
Pageable pageable = new PageRequest(0,size,sort);
Sort sort = Sort.by(Sort.Direction.DESC,"blogs.size");
Pageable pageable = PageRequest.of(0,size,sort);
return tagRepository.findTop(pageable);
}
@ -57,12 +57,13 @@ public class TagServiceImpl implements TagService {
@Override
public List<Tag> ListTag(String ids) {
return tagRepository.findAll(convertToList(ids));
// todo
return tagRepository.findAll();
}
@Override
public Tag updateTag(Long id, Tag tag) {
Tag t = tagRepository.findOne(id);
Tag t = tagRepository.findById(id).orElse(null);
if(t==null){
throw new NotFoundException("不存在该标签");
}
@ -73,7 +74,7 @@ public class TagServiceImpl implements TagService {
@Override
public void deleteTag(Long id) {
tagRepository.delete(id);
tagRepository.deleteById(id);
}
@Override

View File

@ -38,7 +38,7 @@ public class TypeServiceImpl implements TypeService {
@Transactional
@Override
public Type getType(Long id) {
return typeRepository.findOne(id);
return typeRepository.findById(id).orElse(null);
}
@Transactional
@ -54,15 +54,15 @@ public class TypeServiceImpl implements TypeService {
@Override
public List<Type> listTypeTop(Integer size) {
Sort sort = new Sort(Sort.Direction.DESC, "blogs.size");
Pageable pageable = new PageRequest(0, size, sort);
Sort sort = Sort.by(Sort.Direction.DESC, "blogs.size");
Pageable pageable = PageRequest.of(0, size, sort);
return typeRepository.findTop(pageable);
}
@Transactional
@Override
public Type updateType(Long id, Type type) {
Type t = typeRepository.findOne(id);
Type t = typeRepository.findById(id).orElse(null);
if(t == null){
throw new NotFoundException("不存在该类型");
}
@ -70,10 +70,10 @@ public class TypeServiceImpl implements TypeService {
return typeRepository.save(t);
}
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override
public void deleteType(Long id) {
typeRepository.delete(id);
typeRepository.deleteById(id);
}
@Override

View File

@ -1,7 +1,7 @@
#thymeleaf模板
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/blog?useUnicode=true&characterEncoding=utf-8
username: root
password: 123456
@ -16,5 +16,7 @@ logging:
root: warn
com.yrp: info
file: log/-blogpro.log
# 服务端口
server:
port: 9420

View File

@ -50,7 +50,7 @@
<div class="item">
<i class="calendar icon"></i><span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2019-10-01</span>
</div>
<div class="item">
<div class="item m-mobile-hide">
<i class="eye icon"></i><span th:text="${blog.views}">7437</span>
</div>
</div>

View File

@ -31,7 +31,7 @@
</div>
</div>
<!--分类列表区域-->
<div class="ui attached segment m-padded-tb-large ">
<div class="ui attached segment m-padded-tb-large " style="display: none">
<a href="" class="ui teal basic center pointing large label ">
JavaEE
<div class="detail">23</div>

View File

@ -18,7 +18,7 @@
<h2 class="ui teal header item">浅枫沐雪</h2>
<a href="#" class="m-item item m-mobile-hide" ><i class="small home icon"></i>首页</a>
<a href="#" class="m-item item m-mobile-hide " ><i class="small idea icon"></i>分类</a>
<a href="#" class="m-item item m-mobile-hide active"><i class="small tags icon"></i>标签</a>
<a href="#" class="m-item item m-mobile-hide"><i class="small tags icon"></i>标签</a>
<a href="#" class="m-item item m-mobile-hide"><i class="small clone icon"></i>归档</a>
<a href="#" class="m-item item m-mobile-hide"><i class="small info icon"></i>站长信息</a>
<div class="right m-item item m-mobile-hide">
@ -203,6 +203,8 @@
<!--引入所需要的JS-->
<th:block th:replace="_fragments :: script">
</th:block>
<!--声明行内js代码域-->
<script>
$('.menu.toggle').click(function () {