项目介绍
本项目为前后台管理系统,包括博主与游客两种角色;
博主角色包含以下功能:
博主登录,发博客,博主可以删除博客等功能。
游客角色包含以下功能:
首页,查看博客,添加评论,搜索-标签筛选等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
后端:SpringBoot
前端:HTML+CSS+JavaScript+jsp
使用说明
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
return ResultGenerator.genFailResult("参数异常!");
}
if (tagService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("有关联数据请勿强行删除");
}
}
}
前台用户博客管理控制层:
@Controller
public class MyblogController {
// public static String theme = "default";
public static String theme = "amaze";
@Resource
private BlogService blogService;
@Resource
private TagService tagService;
@Resource
* @param commentBody 评论内容
* @return com.hbu.myblog.util.Result
*/
@PostMapping(value = "/blog/comment")
@ResponseBody
public Result comment(HttpServletRequest request, HttpSession session,
@RequestParam Long blogId, @RequestParam String verifyCode,
@RequestParam String commentator, @RequestParam String email,
@RequestParam String websiteUrl, @RequestParam String commentBody) {
if (StringUtils.isEmpty(verifyCode)) {
return ResultGenerator.genFailResult("验证码不能为空");
}
String kaptchaCode = session.getAttribute("verifyCode") + "";
* 标签列表页
*
* @param request http请求
* @param tagName 标签名称
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}"})
public String tag(HttpServletRequest request, @PathVariable("tagName") String tagName) {
return tag(request, tagName, 1);
}
/**
* 标签列表页(带页码)
*
* @param request http请求
* @param tagName 标签名称
* @param page 页码
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}/{page}"})
public String tag(HttpServletRequest request, @PathVariable("tagName") String tagName, @PathVariable("page") Integer page) {
PageResult blogPageResult = blogService.getBlogsPageByTag(tagName, page);
request.setAttribute("blogPageResult", blogPageResult);
request.setAttribute("pageName", "标签");
request.setAttribute("pageUrl", "tag");
public static String theme = "amaze";
@Resource
private BlogService blogService;
@Resource
private TagService tagService;
@Resource
private CommentService commentService;
@Resource
private ConfigService configService;
@Resource
private CategoryService categoryService;
/**
* 首页
*
* @param request http请求
* @return java.lang.String
*/
@GetMapping({"/", "/index", "index.html"})
public String index(HttpServletRequest request) {
request.setAttribute("blogPageResult", blogPageResult);
request.setAttribute("pageName", "分类");
request.setAttribute("pageUrl", "category");
request.setAttribute("keyword", categoryName);
request.setAttribute("newBlogs", blogService.getBlogListForIndexPage(1));
request.setAttribute("hotBlogs", blogService.getBlogListForIndexPage(0));
request.setAttribute("hotTags", tagService.getBlogTagCountForIndex());
request.setAttribute("configurations", configService.getAllConfigs());
return "blog/" + theme + "/list";
}
/**
* 搜索列表页
*
* @param request http请求
* @param keyword 关键词
* @return java.lang.String
*/
@GetMapping({"/search/{keyword}"})
public String search(HttpServletRequest request, @PathVariable("keyword") String keyword) {
return search(request, keyword, 1);
}
/**
* 标签列表页
*
* @param request http请求
* @param tagName 标签名称
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}"})
public String tag(HttpServletRequest request, @PathVariable("tagName") String tagName) {
return tag(request, tagName, 1);
}
/**
* 标签列表页(带页码)
*
* @param request http请求
* @param tagName 标签名称
* @param page 页码
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}/{page}"})
*
* @param request http请求
* @param tagName 标签名称
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}"})
public String tag(HttpServletRequest request, @PathVariable("tagName") String tagName) {
return tag(request, tagName, 1);
}
/**
* 标签列表页(带页码)
*
* @param request http请求
* @param tagName 标签名称
* @param page 页码
* @return java.lang.String
*/
@GetMapping({"/tag/{tagName}/{page}"})
public String tag(HttpServletRequest request, @PathVariable("tagName") String tagName, @PathVariable("page") Integer page) {
PageResult blogPageResult = blogService.getBlogsPageByTag(tagName, page);
request.setAttribute("blogPageResult", blogPageResult);
request.setAttribute("pageName", "标签");
request.setAttribute("pageUrl", "tag");
request.setAttribute("keyword", tagName);
}
if (blogTags.trim().length() > 150) {
return ResultGenerator.genFailResult("标签过长");
}
if (blogSummary.trim().length() > 375) {
return ResultGenerator.genFailResult("摘要过长");
}
if (StringUtils.isEmpty(blogContent)) {
return ResultGenerator.genFailResult("请输入文章内容");
}
if (blogTags.trim().length() > 100000) {
return ResultGenerator.genFailResult("文章内容过长");
}
Blog blog = new Blog();
blog.setBlogId(blogId);
blog.setBlogTitle(blogTitle);
blog.setBlogSummary(blogSummary);
blog.setBlogCategoryId(blogCategoryId);
blog.setBlogTags(blogTags);
blog.setBlogContent(blogContent);
blog.setBlogStatus(blogStatus);
blog.setEnableComment(enableComment);
String updateBlogResult = blogService.updateBlog(blog);
if ("success".equals(updateBlogResult)) {
return ResultGenerator.genSuccessResult("修改成功");
} else {
@ResponseBody
public Result comment(HttpServletRequest request, HttpSession session,
@RequestParam Long blogId, @RequestParam String verifyCode,
@RequestParam String commentator, @RequestParam String email,
@RequestParam String websiteUrl, @RequestParam String commentBody) {
if (StringUtils.isEmpty(verifyCode)) {
return ResultGenerator.genFailResult("验证码不能为空");
}
String kaptchaCode = session.getAttribute("verifyCode") + "";
if (StringUtils.isEmpty(kaptchaCode)) {
return ResultGenerator.genFailResult("非法请求");
}
if (!verifyCode.equals(kaptchaCode)) {
return ResultGenerator.genFailResult("验证码错误");
@RequestParam("blogStatus") Byte blogStatus,
@RequestParam("enableComment") Byte enableComment) {
if (StringUtils.isEmpty(blogTitle)) {
return ResultGenerator.genFailResult("请输入文章标题");
}
if (blogTitle.trim().length() > 150) {
return ResultGenerator.genFailResult("标题过长");
}
if (StringUtils.isEmpty(blogTags)) {
return ResultGenerator.genFailResult("请输入文章标签");
}
if (blogTags.trim().length() > 150) {
return ResultGenerator.genFailResult("标签过长");
}
if (blogSummary.trim().length() > 375) {
return ResultGenerator.genFailResult("摘要过长");
}
if (StringUtils.isEmpty(blogContent)) {
return ResultGenerator.genFailResult("请输入文章内容");
}