源码获取:关注文末gongzhonghao,输入015领取下载链接
开发工具:IDEA,数据库mysql
技术:springboot+mybatis-plus+redis
系统分用户前台和管理后台
前台截图:

后台截图:
- package com.puboot.module.admin.controller;
-
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.puboot.common.util.CoreConst;
- import com.puboot.module.admin.model.BizCategory;
- import com.puboot.module.admin.model.User;
- import com.puboot.module.admin.service.BizCategoryService;
- import com.puboot.module.admin.service.BizStatisticService;
- import com.puboot.module.admin.service.PermissionService;
- import com.puboot.module.admin.service.SysConfigService;
- import lombok.AllArgsConstructor;
- import org.apache.shiro.SecurityUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
-
- import java.util.List;
- import java.util.Map;
-
- /**
- * 后台管理页面跳转控制器
- *
- * @version V1.0
- */
- @Controller
- @AllArgsConstructor
- public class AdminRenderController {
-
-
- private final BizCategoryService categoryService;
- private final SysConfigService sysConfigService;
- private final PermissionService permissionService;
- private final BizStatisticService statisticService;
-
- /**
- * 后台首页
- */
- @RequestMapping("/admin")
- public String index(Model model) {
- model.addAttribute("menuTree", permissionService.selectMenuTreeByUserId(((User) SecurityUtils.getSubject().getPrincipal()).getUserId()));
- return CoreConst.ADMIN_PREFIX + "index/index";
- }
-
- /**
- * 工作台
- */
- @GetMapping("/workdest")
- public String workdest(Model model) {
- model.addAttribute("statistic", statisticService.indexStatistic());
- return CoreConst.ADMIN_PREFIX + "index/dashboard";
- }
-
- /**
- * 用户列表入口
- */
- @GetMapping("/users")
- public String userList() {
- return CoreConst.ADMIN_PREFIX + "user/list";
- }
-
- /**
- * 角色列表入口
- */
- @GetMapping("/roles")
- public String roleList() {
- return CoreConst.ADMIN_PREFIX + "role/list";
- }
-
- /**
- * 权限列表入口
- */
- @GetMapping("/permissions")
- public String permissionList() {
- return CoreConst.ADMIN_PREFIX + "permission/list";
- }
-
- /**
- * 在线用户入口
- */
- @GetMapping("/online/users")
- public String onlineUsers() {
- return CoreConst.ADMIN_PREFIX + "onlineUsers/list";
- }
-
- /**
- * 网站基本信息
- *
- * @param model
- */
- @GetMapping("/siteinfo")
- public String siteinfo(Model model) {
- Map
map = sysConfigService.selectAll(); - model.addAttribute("siteinfo", map);
- return CoreConst.ADMIN_PREFIX + "site/siteinfo";
- }
-
- /**
- * 友情链接
- */
- @GetMapping("/links")
- public String links() {
- return CoreConst.ADMIN_PREFIX + "link/list";
- }
-
- /**
- * 分类
- */
- @GetMapping("/categories")
- public String categories() {
- return CoreConst.ADMIN_PREFIX + "category/list";
- }
-
- /**
- * 标签
- */
- @GetMapping("/tags")
- public String tags() {
- return CoreConst.ADMIN_PREFIX + "tag/list";
- }
-
- /**
- * 文章
- *
- * @param model
- */
- @GetMapping("/articles")
- public String articles(Model model) {
- List
categories = categoryService.list(Wrappers.lambdaQuery().eq(BizCategory::getStatus, CoreConst.STATUS_VALID)); - model.addAttribute("categories", categories);
- return CoreConst.ADMIN_PREFIX + "article/list";
- }
-
- /**
- * 评论
- */
- @GetMapping("/comments")
- public String comments() {
- return CoreConst.ADMIN_PREFIX + "comment/list";
- }
-
- /**
- * 主题
- */
- @GetMapping("themes")
- public String themes() {
- return CoreConst.ADMIN_PREFIX + "theme/list";
- }
-
- }
package com.puboot.module.admin.controller; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; import com.puboot.common.util.CoreConst; import com.puboot.common.util.Pagination; import com.puboot.common.util.PushArticleUtil; import com.puboot.common.util.ResultUtil; import com.puboot.enums.SysConfigKey; import com.puboot.module.admin.model.BizArticle; import com.puboot.module.admin.model.BizCategory; import com.puboot.module.admin.model.BizTags; import com.puboot.module.admin.model.User; import com.puboot.module.admin.service.*; import com.puboot.module.admin.vo.ArticleConditionVo; import com.puboot.module.admin.vo.BaiduPushResVo; import com.puboot.module.admin.vo.base.PageResultVo; import com.puboot.module.admin.vo.base.ResponseVo; import lombok.AllArgsConstructor; import org.apache.shiro.SecurityUtils; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** * 后台文章管理 * * @version V1.0 */ @Controller @RequestMapping("article") @AllArgsConstructor public class ArticleController { private final BizArticleService articleService; private final BizArticleTagsService articleTagsService; private final BizCategoryService categoryService; private final BizTagsService tagsService; private final SysConfigService configService; @PostMapping("list") @ResponseBody public PageResultVo loadArticle(ArticleConditionVo articleConditionVo, Integer pageNumber, Integer pageSize) { articleConditionVo.setSliderFlag(true); IPagepage = new Pagination<>(pageNumber, pageSize); List articleList = articleService.findByCondition(page, articleConditionVo); return ResultUtil.table(articleList, page.getTotal()); } /*文章*/ @GetMapping("/add") public String addArticle(Model model) { BizCategory bizCategory = new BizCategory(); bizCategory.setStatus(CoreConst.STATUS_VALID); List bizCategories = categoryService.selectCategories(bizCategory); List tags = tagsService.list(); model.addAttribute("categories", bizCategories); model.addAttribute("tags", tags); BizArticle bizArticle = new BizArticle().setTags(new ArrayList<>()).setOriginal(1).setSlider(0).setTop(0).setRecommended(0).setComment(1); model.addAttribute("article", bizArticle); return CoreConst.ADMIN_PREFIX + "article/publish"; } @PostMapping("/add") @ResponseBody @Transactional @CacheEvict(value = "article", allEntries = true) public ResponseVo add(BizArticle bizArticle, Integer[] tag) { try { User user = (User) SecurityUtils.getSubject().getPrincipal(); bizArticle.setUserId(user.getUserId()); bizArticle.setAuthor(user.getNickname()); BizArticle article = articleService.insertArticle(bizArticle); articleTagsService.insertList(tag, article.getId()); return ResultUtil.success("保存文章成功"); } catch (Exception e) { return ResultUtil.error("保存文章失败"); } } @GetMapping("/edit") public String edit(Model model, Integer id) { BizArticle bizArticle = articleService.selectById(id); model.addAttribute("article", bizArticle); BizCategory bizCategory = new BizCategory(); bizCategory.setStatus(CoreConst.STATUS_VALID); List bizCategories = categoryService.selectCategories(bizCategory); model.addAttribute("categories", bizCategories); List sysTags = tagsService.list(); /*方便前端处理回显*/ List aTags = new ArrayList<>(); List sTags = new ArrayList<>(); boolean flag; for (BizTags sysTag : sysTags) { flag = false; for (BizTags articleTag : bizArticle.getTags()) { if (articleTag.getId().equals(sysTag.getId())) { BizTags tempTags = new BizTags(); tempTags.setId(sysTag.getId()); tempTags.setName(sysTag.getName()); aTags.add(tempTags); sTags.add(tempTags); flag = true; break; } } if (!flag) { sTags.add(sysTag); } } bizArticle.setTags(aTags); model.addAttribute("tags", sTags); return CoreConst.ADMIN_PREFIX + "article/publish"; } @PostMapping("/edit") @ResponseBody @CacheEvict(value = "article", allEntries = true) public ResponseVo edit(BizArticle article, Integer[] tag) { articleService.updateById(article); articleTagsService.removeByArticleId(article.getId()); articleTagsService.insertList(tag, article.getId()); return ResultUtil.success("编辑文章成功"); } @PostMapping("/delete") @ResponseBody public ResponseVo delete(Integer id) { return deleteBatch(new Integer[]{id}); } @PostMapping("/batch/delete") @ResponseBody public ResponseVo deleteBatch(@RequestParam("ids[]") Integer[] ids) { int i = articleService.deleteBatch(ids); if (i > 0) { return ResultUtil.success("删除文章成功"); } else { return ResultUtil.error("删除文章失败"); } } @PostMapping("/batch/push") @ResponseBody public ResponseVo pushBatch(@RequestParam("urls[]") String[] urls) { try { String url = configService.selectAll().get(SysConfigKey.BAIDU_PUSH_URL.getValue()); BaiduPushResVo baiduPushResVo = JSON.parseObject(PushArticleUtil.postBaidu(url, urls), BaiduPushResVo.class); if (baiduPushResVo.getNotSameSite() == null && baiduPushResVo.getNotValid() == null) { return ResultUtil.success("推送文章成功"); } else { return ResultUtil.error("推送文章失败", baiduPushResVo); } } catch (Exception e) { return ResultUtil.error("推送文章失败,请检查百度推送接口!"); } } }