1、项目介绍
基于springboot的诗词论坛管理系统、唐诗论坛管理系统、论坛管理系统,分为普通用户和管理员。
用户有登录、注册、浏览帖子、发布帖子、评论帖子、关注帖子、点赞帖子、收藏帖子、诗文学习、个人中心、我的发帖、我的点赞、我的收藏、我的关注。
管理员功能有:用户管理、管理员管理、分类管理、帖子管理、诗文管理、数据统计。
2、技术架构
编程语言:Java
后端框架:SpringBoot
前端框架:HTML+LayUI+Js+Css
数据库:MySQL
Maven项目:是
运行环境:JDK8+MySQL5.6+Idea+Maven3.5
3、演示视频
B站地址:
基于springboot的诗词论坛管理系统、唐诗论坛管理系统、论坛管理系统,适合毕设、课程设计、大作业、大实验、实训
4、功能截图
4.1、登录
4.2、注册
4.3、首页
4.4、帖子详情
4.5、帖子搜索
4.6、帖子大全
4.7、点赞、关注、收藏
4.8、评论
4.9、诗文学习
4.10、个人中心
4.11、我的发帖
4.12、我的评论
4.13、我的点赞
4.14、我的收藏
4.15、我的关注
4.16、管理员-用户管理
4.17、管理员-管理员管理
4.18、管理员-分类管理
4.19、管理员-帖子管理
4.20、管理员-诗文管理
4.21、管理员-数据统计
5、代码示例
package com.xbb.poems.controller;
import com.xbb.poems.common.RespResult;
import com.xbb.poems.constant.PathConstant;
import com.xbb.poems.util.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@RestController
public class UploadFileController {
private static final int IMG_SIZE_MAX = 40 * 1024 * 1024; // 图片文件大小限制
/**
* 图片文件上传
*/
@RequestMapping(value = "/uploadImgFile", produces = "application/json;charset=UTF-8")
public RespResult imgFileUpload(@RequestParam("file") MultipartFile multipartFile) {
RespResult respResult = new RespResult();
if (multipartFile != null) {
String suffix = FileUtils.fileSuffix(multipartFile.getOriginalFilename()); // 文件名后缀
String tmpFileName = FileUtils.createTmpFileName(suffix); // 生成保证不重复的临时文件名
if (multipartFile.getSize() > IMG_SIZE_MAX) {
respResult.error("上传失败:文件限制20MB");
return respResult;
}
File tmpFile = new File(PathConstant.FILE_STORAGE_ROOT, tmpFileName);
try {
multipartFile.transferTo(tmpFile); // 写入项目存储位置
Map<String, Object> data = new HashMap<>();
data.put("title", multipartFile.getOriginalFilename());
data.put("src", "/images/" + tmpFileName);
respResult.success(data);
} catch (IOException e) {
respResult.setErrorMessage("上传失败:" + e.getMessage());
e.printStackTrace();
}
}
return respResult;
}
}
package com.xbb.poems.controller;
import com.xbb.poems.common.RespResult;
import com.xbb.poems.constant.SessionConstant;
import com.xbb.poems.entity.*;
import com.xbb.poems.mapper.ArticleMapper;
import com.xbb.poems.mapper.CategoryMapper;
import com.xbb.poems.mapper.PoemsMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.*;
@Controller
@RequestMapping("/poems")
public class PoemsController {
private String prefix = "/poems/";
@Resource
private PoemsMapper poemsMapper;
@Resource
private ArticleMapper articleMapper;
@Resource
private CategoryMapper categoryMapper;
// 诗文管理
@RequestMapping("/manage.html")
public String manageHtml() {
return prefix + "manage";
}
// 诗文列表
@RequestMapping("/list.html")
public String listHtml(Model model) {
int count = poemsMapper.selectCount();
List<Category> categoryList = categoryMapper.selectAll();
// 按收藏量排行
List<Article> collectActivityList = articleMapper.selectListByCollectCount(10);
// 按阅读量排行
List<Article> readArticleList = articleMapper.selectListByReadCount(10);
// 按点赞量排行
List<Article> likeArticleList = articleMapper.selectListByLikeCount(10);
model.addAttribute("categoryList", categoryList);
model.addAttribute("collectActivityList", collectActivityList);
model.addAttribute("readArticleList", readArticleList);
model.addAttribute("likeArticleList", likeArticleList);
model.addAttribute("count", count);
return prefix + "list";
}
// 分页数据
@ResponseBody
@RequestMapping("/data")
public RespResult data(@RequestParam("page") int page,
@RequestParam("limit") int limit,
@RequestParam(value = "name", required = false, defaultValue = "") String name) {
List<Poems> poemsList = poemsMapper.selectListByPaging(
(page - 1) * 10,
limit,
name
);
int count = poemsMapper.selectCountByPaging(name);
for (Poems poems : poemsList) {
poems.setConList(Arrays.asList(poems.getContent().split(",")));
}
RespResult respResult = new RespResult();
respResult.success(poemsList, count);
return respResult;
}
// 添加
@RequestMapping("/add.html")
public String addHtml() {
return prefix + "add";
}
@ResponseBody
@RequestMapping("/add")
public RespResult add(@RequestBody Poems poems) {
poems.setContent(poems.getContent().replace("\n", ","));
poemsMapper.insertSelective(poems);
return new RespResult();
}
// 编辑
@RequestMapping("/edit.html")
public String editHtml(@RequestParam("id") int id, Model model) {
Poems poems = poemsMapper.selectByPrimaryKey(id);
model.addAttribute("poems", poems);
return prefix + "edit";
}
@ResponseBody
@RequestMapping("/edit")
public RespResult edit(@RequestBody Poems poems) {
poemsMapper.updateByPrimaryKeySelective(poems);
return new RespResult();
}
// 删除
@ResponseBody
@RequestMapping("/delete")
public RespResult delete(@RequestBody int id) {
poemsMapper.deleteByPrimaryKey(id);
return new RespResult();
}
}