(免费分享)基于springboot博客系统
创始人
2024-02-03 16:42:26

源码获取:关注文末gongzhonghao,输入015领取下载链接

开发工具:IDEA,数据库mysql

技术:springboot+mybatis-plus+redis

系统分用户前台和管理后台

前台截图:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
后台截图:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

package com.puboot.module.admin.controller;import cn.hutool.core.collection.CollUtil;
import com.puboot.common.util.CoreConst;
import com.puboot.common.util.ResultUtil;
import com.puboot.module.admin.model.BizArticle;
import com.puboot.module.admin.model.BizCategory;
import com.puboot.module.admin.service.BizArticleService;
import com.puboot.module.admin.service.BizCategoryService;
import com.puboot.module.admin.vo.base.ResponseVo;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.util.ListUtils;import java.util.Date;
import java.util.List;/*** 后台类目管理*/
@Controller
@RequestMapping("category")
@AllArgsConstructor
public class CategoryController {private final BizCategoryService categoryService;private final BizArticleService articleService;@PostMapping("list")@ResponseBodypublic List loadCategory(boolean isFistLevel) {BizCategory bizCategory = new BizCategory();bizCategory.setStatus(CoreConst.STATUS_VALID);if (isFistLevel) {bizCategory.setPid(CoreConst.TOP_MENU_ID);}return categoryService.selectCategories(bizCategory);}@GetMapping("/add")public String add() {return CoreConst.ADMIN_PREFIX + "category/form";}@PostMapping("/add")@ResponseBody@CacheEvict(value = "category", allEntries = true)public ResponseVo add(BizCategory bizCategory) {if (!CoreConst.TOP_MENU_ID.equals(bizCategory.getPid())) {List bizArticles = articleService.selectByCategoryId(bizCategory.getPid());if (!ListUtils.isEmpty(bizArticles)) {return ResultUtil.error("添加失败,父级分类下存在文章");}}Date date = new Date();bizCategory.setCreateTime(date);bizCategory.setUpdateTime(date);bizCategory.setStatus(CoreConst.STATUS_VALID);boolean i = categoryService.save(bizCategory);if (i) {return ResultUtil.success("新增分类成功");} else {return ResultUtil.error("新增分类失败");}}@GetMapping("/edit")public String edit(Model model, Integer id) {BizCategory bizCategory = categoryService.selectById(id);model.addAttribute("category", bizCategory);return CoreConst.ADMIN_PREFIX + "category/form";}@PostMapping("/edit")@ResponseBody@CacheEvict(value = "category", allEntries = true)public ResponseVo edit(BizCategory bizCategory) {bizCategory.setUpdateTime(new Date());boolean i = categoryService.updateById(bizCategory);if (i) {return ResultUtil.success("编辑分类成功");} else {return ResultUtil.error("编辑分类失败");}}@PostMapping("/delete")@ResponseBodypublic ResponseVo delete(Integer id) {if (CollUtil.isNotEmpty(categoryService.selectByPid(id))) {return ResultUtil.error("该分类下存在子分类!");}return deleteBatch(new Integer[]{id});}@PostMapping("/batch/delete")@ResponseBodypublic ResponseVo deleteBatch(@RequestParam("ids[]") Integer[] ids) {int i = categoryService.deleteBatch(ids);if (i > 0) {return ResultUtil.success("删除分类成功");} else {return ResultUtil.error("删除分类失败");}}}

package com.puboot.module.admin.controller;

import com.puboot.module.admin.service.BizCategoryService;
import com.puboot.module.admin.service.SysConfigService;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**

  • 统一错误跳转页面,如403,404,500

*/
@Controller
@RequestMapping(“/error”)
@AllArgsConstructor
public class ErrorController {

private final SysConfigService sysConfigService;
private final BizCategoryService bizCategoryService;/*** shiro无权限时进入** @param request* @param response* @param model* @return*/
@RequestMapping("/403")
public String noPermission(HttpServletRequest request, HttpServletResponse response, Model model) {response.setStatus(HttpStatus.FORBIDDEN.value());return "error/403";
}@RequestMapping("/404")
public String notFund(HttpServletRequest request, HttpServletResponse response, Model model) {return "error/404";
}@RequestMapping("/500")
public String sysError(HttpServletRequest request, HttpServletResponse response, Model model) {return "error/500";
}

}

相关内容

热门资讯

埃菲尔铁塔在哪 中国仿建埃菲尔... 2019年4月26日,广西南宁市,街头惊现一座巨型山寨版埃菲尔铁塔,高约20米,白色塔身,造型逼真,...
苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...
应用未安装解决办法 平板应用未... ---IT小技术,每天Get一个小技能!一、前言描述苹果IPad2居然不能安装怎么办?与此IPad不...
脚上的穴位图 脚面经络图对应的... 人体穴位作用图解大全更清晰直观的标注了各个人体穴位的作用,包括头部穴位图、胸部穴位图、背部穴位图、胳...
长白山自助游攻略 吉林长白山游... 昨天介绍了西坡的景点详细请看链接:一个人的旅行,据说能看到长白山天池全凭运气,您的运气如何?今日介绍...
世界上最漂亮的人 世界上最漂亮... 此前在某网上,选出了全球265万颜值姣好的女性。从这些数量庞大的女性群体中,人们投票选出了心目中最美...
demo什么意思 demo版本... 618快到了,各位的小金库大概也在准备开闸放水了吧。没有小金库的,也该向老婆撒娇卖萌服个软了,一切只...
猫咪吃了塑料袋怎么办 猫咪误食... 你知道吗?塑料袋放久了会长猫哦!要说猫咪对塑料袋的喜爱程度完完全全可以媲美纸箱家里只要一有塑料袋的响...
埃菲尔铁塔在哪 中国仿建埃菲尔... 2019年4月26日,广西南宁市,街头惊现一座巨型山寨版埃菲尔铁塔,高约20米,白色塔身,造型逼真,...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...
苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
应用未安装解决办法 平板应用未... ---IT小技术,每天Get一个小技能!一、前言描述苹果IPad2居然不能安装怎么办?与此IPad不...