Java项目:美食论坛系统(java+SSM+JSP+jQuery+LayUI+mysql)

pastclouds 2022-05-14 14:59:42 阅读数:892

java系统项目论坛美食

源码获取:博客首页 "资源" 里下载!

项目介绍

该项目主要分为前台与后台;
前台主要功能包括:
登录、注册;首页、我发表的贴子、意见建议;版块列表、帖子查看、发贴回贴等;
普通用户登录后,主要功能有:
我的主页、用户中心、基本设置、版主申请、我的关注、屏蔽用户、我的私信等;
后台主要功能包括:
会员管理:禁言、封号、删除等;
站内资讯:添加、编辑、删除等;
友情链接:添加、编辑、删除等;
版块管理:添加修改删除分类、撤销版主等;
帖子管理:迁移、精华、置顶、删除等;
版主审核:通过、拒绝等;
意见建议:回复、删除;
敏感字符:添加、编辑、删除敏感字符;
举报信息:查看被举报人、举报人、举报原因等;


环境需要

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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 
6.数据库:MySql 5.7版本;


技术栈

1. 后端:Spring SpringMVC MyBatis
2. 前端:JSP+jQuery+LayUI


使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/cateforumssm 登录

 

 

 

 

 

 

 

 

 

用户管理控制器:

/**
* 用户控制器
*
*/
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {
@Resource
private UserService userService;
@Value("${MD5Salt}")
private String salt; // md5加密盐
/**
* 根据ID查找用户
* @param userId
* @return
*/
@RequestMapping("/findById")
public Map<String, Object> findById(Integer userId) {
Map<String, Object> resultMap = new HashMap<String, Object>();
User user = userService.findById(userId);
resultMap.put("errorNo", 0);
resultMap.put("data", user);
return resultMap;
}
/**
* 分页查询用户
* @param user
* @param registrationDates
* @param page
* @param limit
* @return
*/
@RequestMapping("/list")
public Map<String, Object> list(User user,
@RequestParam(value = "latelyLoginTimes", required = false) String latelyLoginTimes,
@RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
String s_bregistrationDate = null; // 开始时间
String s_eregistrationDate = null; // 结束时间
if (StringUtil.isNotEmpty(latelyLoginTimes)) {
String[] strs = latelyLoginTimes.split(" - "); // 拆分时间段
s_bregistrationDate = strs[0];
s_eregistrationDate = strs[1];
}
List<User> userList = userService.list(user, s_bregistrationDate, s_eregistrationDate, page - 1, pageSize);
Long total = userService.getCount(user, s_bregistrationDate, s_eregistrationDate);
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("errorNo", 0);
resultMap.put("data", userList);
resultMap.put("total", total);
return resultMap;
}
@RequestMapping("/delete")
public Map<String, Object> delete(Integer userId) {
Map<String, Object> resultMap = new HashMap<String, Object>();
userService.delete(userId);
resultMap.put("errorNo", 0);
return resultMap;
}
/**
* 取消关注
* @param request
* @param userId
* @return
*/
@RequestMapping("/removeFocusUser")
public ModelAndView removeFocusUser(HttpServletRequest request, String userId) {
ModelAndView mav = new ModelAndView();
User user = (User) request.getSession().getAttribute("user");// 当前登录用户
String userIds = user.getUserIds();
List<String> tempList = Arrays.asList(userIds.split(","));
List<String> lineIdList = new ArrayList<>(tempList);
lineIdList.remove(userId);
String ret = StringUtils.join(lineIdList, ",");
user.setUserIds(ret);
userService.save(user);
mav.setViewName("redirect:/viewFocusUser");
return mav;
}
/**
* 关注用户
* @param request
* @param userId
* @return
*/
@RequestMapping("/addFocusUser")
public ModelAndView addFocusUser(HttpServletRequest request, String userId) {
ModelAndView mav = new ModelAndView();
User user = (User) request.getSession().getAttribute("user");// 当前登录用户
String userIds = user.getUserIds();
List<String> tempList = Arrays.asList(userIds.split(","));
List<String> lineIdList = new ArrayList<>(tempList);
lineIdList.add(userId);
String ret = StringUtils.join(lineIdList, ",");
user.setUserIds(ret);
userService.save(user);
mav.setViewName("redirect:/viewFocusUser");
return mav;
}
@RequestMapping("/addFocusUser/{userId}")
public ModelAndView addFocusUser(@PathVariable(value = "userId", required = false) Integer userId,
HttpSession session) {
ModelAndView mav = new ModelAndView();
User user = (User) session.getAttribute("user");// 当前登录用户
String userIds = user.getUserIds();
List<String> tempList = new ArrayList<>();
if (userIds != null) {
tempList = Arrays.asList(userIds.split(","));
}
List<String> lineIdList = new ArrayList<>(tempList);
lineIdList.add(userId.toString());
String ret = StringUtils.join(lineIdList, ",");
user.setUserIds(ret);
userService.save(user);
mav.setViewName("redirect:/viewFocusUser");
return mav;
}
/**
* 取消收藏
* @param request
* @param userId
* @return
*/
@RequestMapping("/removeCollection")
public ModelAndView removeCollection(HttpServletRequest request, String artId) {
ModelAndView mav = new ModelAndView();
User user = (User) request.getSession().getAttribute("user");// 当前登录用户
String artIds = user.getArticleIds();
List<String> tempList = Arrays.asList(artIds.split(","));
List<String> lineIdList = new ArrayList<>(tempList);
lineIdList.remove(artId);
String ret = StringUtils.join(lineIdList, ",");
user.setArticleIds(ret);
userService.save(user);
mav.setViewName("redirect:/viewCollection");
return mav;
}
/**
* 收藏
* @param request
* @param userId
* @return
*/
@RequestMapping("/addCollection")
public ModelAndView addCollection(HttpServletRequest request, String artId) {
ModelAndView mav = new ModelAndView();
User user = (User) request.getSession().getAttribute("user");// 当前登录用户
String artIds = user.getArticleIds();
List<String> tempList = Arrays.asList(artIds.split(","));
List<String> lineIdList = new ArrayList<>(tempList);
lineIdList.add(artId);
String ret = StringUtils.join(lineIdList, ",");
user.setArticleIds(ret);
userService.save(user);
mav.setViewName("redirect:/viewCollection");
return mav;
}
}

回复管理控制层: 

/**
* 回复Controller层
*
*/
@RestController
@RequestMapping("/admin/reply")
public class ReplyAdminController {
@Resource
private ReplyService replyService;
/**
* 分页查询回复
* @param reply
* @param page
* @param limit
* @return
*/
@RequestMapping("/list")
public Map<String, Object> list(Reply reply,@RequestParam(value="page",required=false)Integer page,@RequestParam(value="pageSize",required=false)Integer pageSize){
Map<String, Object> resultMap=new HashMap<String, Object>();
List<Reply> replyList=replyService.list(reply,page-1, pageSize);
Long total=replyService.getCount();
resultMap.put("errorNo", 0);
resultMap.put("data", replyList);
resultMap.put("total", total);
return resultMap;
}
/**
* 删除回复
* @param ids
* @return
*/
@RequestMapping("/delete")
public Map<String, Object> delete(@RequestParam(value="replyId")String ids){
String []idsStr=ids.split(",");
Map<String, Object> resultMap=new HashMap<String, Object>();
for(int i=0;i<idsStr.length;i++) {
replyService.delete(Integer.parseInt(idsStr[i]));
}
resultMap.put("errorNo", 0);
resultMap.put("data", 1);
return resultMap;
}
}

博主管理控制层:

/**
* 博主控制器
*
*/
@RestController
@RequestMapping("/admin/blogger")
public class BloggerAdminController {
@Resource
private BloggerService bloggerService;
@Resource
private StartupRunner startupRunner;
/**
* 查找博主
* @param bloggerId
* @return
*/
@RequestMapping("/find")
public Map<String, Object> find() {
Map<String, Object> resultMap=new HashMap<String, Object>();
resultMap.put("errorNo", 0);
resultMap.put("data", bloggerService.find());
return resultMap;
}
/**
* 添加或者修改博主
* @param blogger
* @return
*/
@RequestMapping("/save")
public Map<String, Object> save(Blogger blogger){
Map<String, Object> resultMap=new HashMap<String, Object>();
bloggerService.save(blogger);
resultMap.put("errorNo", 0);
resultMap.put("data", 1);
startupRunner.loadData();
return resultMap;
}
}

源码获取:博客首页 "资源" 里下载! 

版权声明:本文为[pastclouds]所创,转载请带上原文链接,感谢。 https://blog.csdn.net/yuyecsdn/article/details/124767031