环境:开发工具:idea,数据库:MySQL5.7 jdk1.8
架构:SpringBoot,前端HTML
主要功能
1.普通用户
查看文章信息:文章列表、推荐文章、文章标题、文章内容、发布时间、访问量以及评论等信息
查看分类文章:分类列表、分类文章信息
查看时间轴:按照文章时间发布顺序查看文章
搜索文章:导航栏右边搜索框根据关键字搜索
听音乐:上一曲、下一曲、音量控制、播放顺序控制、查看歌词等
留言:留言并回复
查看友链:查看并访问博主在友链页面添加的友链连接
查看相册信息:相册列表、照片名称、照片拍摄地点、时间、照片描述
2.管理员用户(栈主)
拥有普通用户所有功能权限
登录:在主页路径下加“/admin”,可进入登录页面,根据数据库的用户名和密码进行登录
文章管理:查询文章列表、新增文章、编辑文章、删除文章、搜索文章
分类管理:查询分类列表、新增分类、编辑分类、删除分类
友链管理:查询友链列表、新增友链、编辑友链、删除友链
相册管理:查询相册列表、新增照片、编辑照片、删除照片
消息管理:登录后恢复评论留言会显示栈主的头像信息,并能显示删除消息按键,可以对消息进行删除
项目图片:
部分代码:
@Controller
public class IndexController {
@Autowired
private BlogDao blogDao;
@Autowired
private BlogService blogService;
// @Autowired
// private TypeService typeService;
@Autowired
private CommentService commentService;
// 分页查询列表
@GetMapping("/")
public String index(Model model, @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum, RedirectAttributes attributes){
PageHelper.startPage(pageNum,10);
List<FirstPageBlog> allFirstPageBlog = blogService.getAllFirstPageBlog();
List<RecommendBlog> recommendedBlog = blogService.getRecommendedBlog(); // 根据推荐进行查询
PageInfo<FirstPageBlog> pageInfo = new PageInfo<>(allFirstPageBlog);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("recommendedBlogs", recommendedBlog);
return "index";
}
// 搜索
@PostMapping("/search")
public String search(Model model,
@RequestParam(defaultValue = "1", value = "pageNum") Integer pageNum,
@RequestParam String query) {
PageHelper.startPage(pageNum, 1000);
List<FirstPageBlog> searchBlog = blogService.getSearchBlog(query);
PageInfo<FirstPageBlog> pageInfo = new PageInfo<>(searchBlog);
model.addAttribute("pageInfo", pageInfo);
model.addAttribute("query", query);
return "search";
}
// 跳转详情页面
@GetMapping("/blog/{id}")
public String blog(@PathVariable Long id, Model model) {
DetailedBlog detailedBlog = blogService.getDetailedBlog(id);
List<Comment> comments = commentService.listCommentByBlogId(id);
model.addAttribute("comments", comments);
model.addAttribute("blog", detailedBlog);
return "blog";
}
// 最新博客列表
// @GetMapping("/footer/newblog")
// public String newblogs(Model model) {
// List<FirstPageBlog> newBlog = blogService.getNewBlog();
// model.addAttribute("newblogs", newBlog);
// return "index :: newblogList";
// }
// 博客信息
@GetMapping("/footer/blogmessage")
public String blogMessage(Model model){
// 总数量
int blogTotal = blogService.getBlogTotal();
// 查看数量
int blogViewTotal = blogService.getBlogViewTotal();
//评论数量
int blogCommentTotal = blogService.getBlogCommentTotal();
// 留言
int blogMessageTotal = blogService.getBlogMessageTotal();
model.addAttribute("blogTotal",blogTotal);
model.addAttribute("blogViewTotal",blogViewTotal);
model.addAttribute("blogCommentTotal",blogCommentTotal);
model.addAttribute("blogMessageTotal",blogMessageTotal);
return "index :: blogMessage";
}
获取方式:联系下方名片获取