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"?> <?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" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.allms</groupId> <groupId>cn.allms</groupId>
<artifactId>blog</artifactId> <artifactId>blog</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>blog</name> <name>blog</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version> <version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<repositories> <repositories>
<repository> <repository>
<id>public</id> <id>public</id>
<name>aliyun nexus</name> <name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url> <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>public</id> <id>public</id>
<name>aliyun nexus</name> <name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url> <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>
<snapshots> <snapshots>
<enabled>false</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<!--设置tymeleaf的版本--> </properties>
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
<dependencies> <dependencies>
<dependency> <!--jpa-->
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-aop</artifactId> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-starter-data-jpa</artifactId>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <!--thymeleaf-->
<artifactId>spring-boot-starter-data-jpa</artifactId> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-thymeleaf</artifactId>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <!--web-->
</dependency> <dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-web</artifactId> </dependency>
</dependency> <!--devtools-->
<dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
<artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope>
<scope>runtime</scope> <optional>true</optional>
</dependency> </dependency>
<dependency> <!--mysql-->
<groupId>mysql</groupId> <dependency>
<artifactId>mysql-connector-java</artifactId> <groupId>mysql</groupId>
<scope>runtime</scope> <artifactId>mysql-connector-java</artifactId>
</dependency> <scope>runtime</scope>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <!--lombok-->
<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>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <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> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> <version>2.3.0.RELEASE</version>
<!-- <plugin>--> <executions>
<!-- <groupId>com.spotify</groupId>--> <execution>
<!-- <artifactId>docker-maven-plugin</artifactId>--> <goals>
<!-- <version>1.2.0</version>--> <goal>repackage</goal>
<!-- <executions>--> </goals>
<!-- <execution>--> </execution>
<!-- <id>build-image</id>--> </executions>
<!-- <phase>package</phase>--> </plugin>
<!-- <goals>--> </plugins>
<!-- <goal>build</goal>--> </build>
<!-- </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>
</project> </project>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@
</div> </div>
</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 "> <a href="" class="ui teal basic center pointing large label ">
JavaEE JavaEE
<div class="detail">23</div> <div class="detail">23</div>

View File

@ -18,7 +18,7 @@
<h2 class="ui teal header item">浅枫沐雪</h2> <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 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 " ><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 clone icon"></i>归档</a>
<a href="#" class="m-item item m-mobile-hide"><i class="small info 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"> <div class="right m-item item m-mobile-hide">
@ -203,6 +203,8 @@
<!--引入所需要的JS--> <!--引入所需要的JS-->
<th:block th:replace="_fragments :: script"> <th:block th:replace="_fragments :: script">
</th:block>
<!--声明行内js代码域--> <!--声明行内js代码域-->
<script> <script>
$('.menu.toggle').click(function () { $('.menu.toggle').click(function () {