package com.dreamchaser.controller;
import com.dreamchaser.pojo.*;
import com.dreamchaser.service.*;
import com.dreamchaser.utils.ArchivesUtil;
import com.dreamchaser.utils.MapUtil;
import com.dreamchaser.utils.MarkdownUtil;
import com.dreamchaser.utils.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class PageController {
@Autowired
BlogService blogService;
@Autowired
TypeService typeService;
@Autowired
TagService tagService;
@Autowired
CommentService commentService;
@Autowired
BlogCombinationService blogCombinationService;
@Autowired
CommentCombinationService commentCombinationService;
@GetMapping("/login")
public String login(){
return "admin/login";
}
@GetMapping("/admin/blog-input")
public ModelAndView blog_input(){
ModelAndView mv=new ModelAndView();
mv.addObject("types",typeService.findTypeAll());
mv.addObject("tags",tagService.findTagAll());
mv.addObject("method","post");
mv.setViewName("admin/blog-input");
return getModelAndView(mv);
}
@GetMapping("/admin/blog-input/{blogId}")
public ModelAndView blog_input_update(@PathVariable Integer blogId){
ModelAndView mv=new ModelAndView();
mv.addObject("types",typeService.findTypeAll());
mv.addObject("tags",tagService.findTagAll());
mv.addObject("blog",blogService.findBlogById(blogId));
mv.addObject("method","put");
mv.setViewName("admin/blog-input");
return getModelAndView(mv);
}
@GetMapping("/admin/blogs")
public ModelAndView blogs(){
ModelAndView mv=new ModelAndView();
Map<String,Object>map=new HashMap<>();
map.put("begin",0);
map.put("size",6);
mv.setViewName("admin/blogs");
mv.addObject("types",typeService.findTypeAll());
mv.addObject("blogs",blogCombinationService.findBlogCombinationByCondition(map));
return getModelAndView(mv);
}
@GetMapping("/admin/comments")
public ModelAndView comments(){
ModelAndView mv=new ModelAndView();
Map<String,Object> map=new HashMap<>();
map.put("begin",0);
map.put("size",6);
mv.addObject("comments",commentCombinationService.findCommentByPage(map));
mv.setViewName("admin/comments");
return getModelAndView(mv);
}
@GetMapping("/admin/comments-details/{id}")
public ModelAndView comments_details(@PathVariable Integer id){
ModelAndView mv=new ModelAndView();
mv.addObject("comment",commentCombinationService.findCommentById(id));
mv.setViewName("admin/comments-details");
return getModelAndView(mv);
}
@GetMapping("/admin/tag-input")
public ModelAndView tag_input(){
ModelAndView mv=new ModelAndView();
mv.addObject("method","post");
mv.setViewName("admin/tag-input");
return getModelAndView(mv);
}
@GetMapping("/admin/tag-input/{id}")
public ModelAndView tag_input(@PathVariable Integer id){
ModelAndView mv=new ModelAndView();
mv.addObject("tag",tagService.findTagById(id));
mv.addObject("method","put");
mv.setViewName("admin/tag-input");
return getModelAndView(mv);
}
@GetMapping("/admin/tags")
public ModelAndView tags(){
ModelAndView mv=new ModelAndView();
Map<String,Object> map=new HashMap<>();
map.put("begin",0);
map.put("size",6);
mv.addObject("tags",tagService.findTagByPage(map));
mv.setViewName("admin/tags");
return getModelAndView(mv);
}
@GetMapping("/admin/types")
public ModelAndView types(){
ModelAndView mv=new ModelAndView();
Map<String,Object> map=new HashMap<>();
map.put("begin",0);
map.put("size",6);
mv.addObject("types",typeService.findTypeByPage(map));
mv.setViewName("admin/types");
return getModelAndView(mv);
}
@GetMapping("/admin/types-input")
public ModelAndView types_input(){
ModelAndView mv=new ModelAndView();
mv.setViewName("admin/types-input");
mv.addObject("method","post");
return getModelAndView(mv);
}
@GetMapping("/admin/types-input/{id}")
public ModelAndView types_input(@PathVariable Integer id){
ModelAndView mv=new ModelAndView();
mv.setViewName("admin/types-input");
mv.addObject("type",typeService.findTypeById(id));
mv.addObject("method","put");
return getModelAndView(mv);
}
@GetMapping("/page_blog/{id}")
public ModelAndView blog(@PathVariable Integer id){
ModelAndView mv=new ModelAndView();
mv.setViewName("blog");
BlogCombination blogCombination=blogCombinationService.findBlogCombinationById(id);
blogCombination.setContent(MarkdownUtil.markdownToHtmlExtens(blogCombination.getContent()));
mv.addObject("blog",blogCombination);
Map<String,List<Comment>> map=commentService.findCommentsByBlog(id);
mv.addObject("parents",map.get("parents"));
mv.addObject("sons",map.get("sons"));
return getModelAndView(mv);
}
@GetMapping("/archives")
public ModelAndView archives(){
ModelAndView mv=new ModelAndView();
List<Blog>blogs=blogService.findBlogAllVisible();
mv.addObject("number",blogs.size());
mv.addObject("years", ArchivesUtil.handle(blogs));
mv.setViewName("archives");
return getModelAndView(mv);
}
@GetMapping("/")
public ModelAndView index(@RequestParam Map<String,Object> map){
ModelAndView mv=new ModelAndView();
//预处理
if (map.get("begin")==null){
map.put("begin",0);
}else if (ObjectUtil.ObjectToInteger(map.get("begin")) <ObjectUtil.ObjectToInteger(map.get("size"))){
map.replace("begin",0);
}
if (map.get("size")==null){
map.put("size",8);
}
//所有博客分页查询
//因为有一种情况是上一页下一页,前端发送begin和size,而后端接受到时是string,而数据库中limit后只能跟数字,所以得先对其做处理
mv.addObject("blogs",blogCombinationService.findBlogCombinationByConditionVisible(MapUtil.handle(map)));
//注意此时map其实已经处理过了,所以取出来的begin和size类型就是Integer
mv.addObject("begin",map.get("begin"));
mv.addObject("size",map.get("size"));
map.put("begin",0);
map.put("size",10);
mv.addObject("types",typeService.findTypeByPage(map));
mv.addObject("tags",tagService.findTagByPage(map));
mv.setViewName("index");
//最新推荐的博客
map.put("isRecommend",1);
mv.addObject("recommendedBlogs",blogService.findBlogByConditionVisible(map));
//为了显示博客数量
List<Blog>blogs=blogService.findBlogAllVisible();
mv.addObject("number",blogs.size());
return getModelAndView(mv);
}
/**
* 实现前台展示的search功能
* @param map
* @return
*/
@GetMapping("/search")
public ModelAndView index_search(@RequestParam Map<String, Object> map){
ModelAndView mv=new ModelAndView();
mv.addObject("blogs",blogCombinationService.findBlogCombinationByConditionVisible(map));
mv.setViewName("search");
return getModelAndView(mv);
}
@GetMapping("/page_tags")
public ModelAndView page_tags(@RequestParam Map<String,Object>map){
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java和HTML的个人博客系统设计源码

共653个文件
js:249个
css:153个
html:118个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 92 浏览量
2024-04-15
03:26:12
上传
评论
收藏 13.67MB ZIP 举报
温馨提示
基于Java和HTML的个人博客系统设计源码,该项目包含655个文件,主要文件类型有249个javascript文件,153个css样式文件,以及118个html页面文件。此外,还包括46个java源文件,22个png图像文件,以及7个xml配置文件。该项目是一个基于Java和HTML的个人博客系统设计源码,可能涉及用户界面设计、应用逻辑实现、数据存储等多个方面。
资源推荐
资源详情
资源评论
























收起资源包目录





































































































共 653 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论


沐知全栈开发
- 粉丝: 5843
- 资源: 5218
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- S7-300 和S7-400编程语句表(STL)参考手册
- Deepseek智能助手本地化部署及其应用:Linux环境下的安装、Docker容器部署与对话系统集成
- 机器学习_AndrewNG_课程资料_学习辅助_1741397822.zip
- 机器学习与深度学习实验教程_Python_入门_教育_1741397125.zip
- 机器学习_快速学习要点_理论实战转换_入门教程_1741397080.zip
- COMP639 Flask Web应用程序设计:林肯社区露营地问题跟踪系统
- anaconda配置pytorch环境.md
- 机器视觉_OpenCV_图像处理与识别_教育与实践_1741397761.zip
- Web开发_Python_Flask_共享单车需求预测系统_1741397989.zip
- 机器学习_Python基础教程代码改写_学习工具_1741397853.zip
- anaconda配置pytorch环境.md
- 乐尚代驾项目总结文档.docx
- 知识领域_Python3_爬虫学习_入门教程_1741397340.zip
- anaconda配置pytorch环境.md
- 网络安全_AI_恶意代码分析_教学笔记_1741397779.zip
- ximinng_chatbot_1741397572.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
