目录
一、系统架构
- 基于Springboot+JPA+Thymeleaf+MySQL的个人博客系统
二、模块分析
- 本系统主要针对发博客而设计,其系统内有管理员端和用户端。基于Springboot+JPA+Thymeleaf+MySQL的个人博客系统。
三、项目介绍
本项目主要开发管理员管理页面(Admin)、博客分类页面、博客发表页面、标签页面、最新推荐页面、设备管理分类页面以及退出系统等功能
四、项目结构
五、首页页面
1.博客储存
public interface BlogRepository extends JpaRepository<Blog,Long>, JpaSpecificationExecutor<Blog> {
@Query("select b from t_blog b where b.recommend=true ")
List<Blog> findTop(Pageable pageable);
@Query("select b from t_blog b where b.title like ?1 or b.content like ?1")
Page<Blog> findByQuery(String query,Pageable pageable);
@Transactional
@Modifying
@Query("update t_blog b set b.views=b.views+1 where b.id=?1")
int updateViews(Long id);
@Query("select function('date_format',b.updateTime,'%Y') as year from t_blog b group by function('date_format',b.updateTime,'%Y') " +
"order by function('date_format',b.updateTime,'%Y') desc ")
List<String> findGroupYear();
@Query("select b from t_blog b where function('date_format',b.updateTime,'%Y')= ?1")
List<Blog> findByYear(String year);
2.评论
@Id @GeneratedValue private Long id; private String nickname; private String email; private String content; @NestedConfigurationProperty private String avatar; @Temporal(TemporalType.TIMESTAMP) private Date createTime; @ManyToOne private Blog blog; @OneToMany(mappedBy = "parentComment") private List<Comment> replyComments = new ArrayList<>(); @ManyToOne private Comment parentComment; private boolean adminComment; public Comment() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNickname() { return nickname; } public void setNickname(