作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本系统分为前后台,前台主要功能为:
用户注册登陆、浏览帖子、发布帖子、个人信息管理、消息通知管理,积分管理,
后台管理功能有:
友情链接管理、板块管理、主题管理、用户管理、网站设置等等。本系统实现的功能非常丰富,可自由切换电脑版和手机版,访问时自动识别设备,也可按照ip来设置访问权限,已经达到了正式上线的系统水平,非常值得学习参考。本项目包含完整的源码、数据库文件。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
管理员账号/密码:admin/123456
用户账号/密码: userloop/123456
环境需要
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+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需要的jar包;
3. 将项目中beans.xml配置文件中的数据库配置改为自己的配置,主要用户名、密码;
4. 配置tomcat,然后运行运行项目,输入http://localhost:8080/ 登录
运行截图
前台界面
后台界面
相关代码
AdminBankuaiController
package com.yuanlrc.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yuanlrc.model.Bankuai;
import com.yuanlrc.model.JifenGroup;
import com.yuanlrc.model.PageBean;
import com.yuanlrc.model.User;
import com.yuanlrc.service.BankuaiService;
import com.yuanlrc.service.JifenGroupService;
import com.yuanlrc.tool.Pinyin4j;
import com.yuanlrc.tool.PublicStatic;
import com.yuanlrc.tool.Tool;
import com.yuanlrc.tool.thread.IndexThread;
/*
* 后台板块查询
*
*/
@Controller
@RequestMapping("/admin/bankuai")
public class AdminBankuaiController {
@Autowired
BankuaiService bankuaiService;
@Autowired
JifenGroupService jifenGroupService;
private static Logger log = Logger.getLogger(AdminBankuaiController.class);
//后台页面查询
@RequestMapping("index.do")
public String findAllWhere(HttpServletRequest request, Model model,Bankuai bankuai,PageBean<Bankuai> page) {
Bankuai bankuaitmp=new Bankuai();
bankuaitmp.setParentId(0);
List<Bankuai> list = bankuaiService.select(bankuaitmp);
page = bankuaiService.findpage(bankuai,page);
model.addAttribute("list", list);
model.addAttribute("bankuai", bankuai);
model.addAttribute("page", page);
return "jsp/admin/bankuai/index";
}
//跳转到修改页面
@RequestMapping("toupdateoradd.do")
public String toupdateoradd(Bankuai bankuai, Model model) {
if(bankuai.getId()!=null){
bankuai=bankuaiService.findbyid(bankuai);
}
model.addAttribute("bankuai", bankuai);
List<Bankuai> parentList = bankuaiService.findbyparentId(new Bankuai());
//如果是父板块,删除自己
for (int i=0;i< parentList.size() ;i++) {
Bankuai bankuai2=parentList.get(i);
if(bankuai2.getId()==bankuai.getId()){
parentList.remove(bankuai2);
}
}
model.addAttribute("parentList", parentList);
List<JifenGroup> jifengouplist = jifenGroupService.find(new JifenGroup());
model.addAttribute("jifengouplist", jifengouplist);
return "jsp/admin/bankuai/updateoradd";
}
//修改或者新增
@RequestMapping("updateoradd.do")
public String updateoradd(HttpServletRequest request,Bankuai bankuai) {
User user=(User)request.getSession().getAttribute(PublicStatic.USER);
bankuai.setCreateUserid(user.getId());
String img = bankuai.getImg();
if(img!=null&&img.length()==0){
bankuai.setImg("bankuai.jpg");
}
if(bankuai.getId()!=null){
bankuaiService.update(bankuai);
}else{
bankuaiService.insert(bankuai);
}
new IndexThread().start();
return "redirect:index.do ";
}
//删除
@ResponseBody
@RequestMapping("del.do")
public String del(int id) {
String result=bankuaiService.delete(id);
return result;
}
//删除
@ResponseBody
@RequestMapping("getpinyin.do")
public String getpinyin(String name) {
String getpinyin = Pinyin4j.getpinyin(name);
Bankuai bankuai=new Bankuai();
bankuai.setYuming(getpinyin);
List<Bankuai> list = bankuaiService.select(bankuai);
if(list.size()>0){
getpinyin=getpinyin+Tool.getRandom();
}
return getpinyin;
}
}
后台公共使用
package com.yuanlrc.controller.admin;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yuanlrc.model.Tiezi;
import com.yuanlrc.model.User;
import com.yuanlrc.service.TieziService;
import com.yuanlrc.tool.PublicStatic;
import com.yuanlrc.tool.Tool;
/*
* 后台公共使用
*
*/
@Controller
@RequestMapping("/admin/common")
public class AdminCommonController {
@Autowired
TieziService tieziService;
private static Logger log = Logger.getLogger(AdminCommonController.class);
//全局置顶
@ResponseBody
@RequestMapping("updateallzhiding.do")
public Map<String, String> updateallzhiding(HttpServletRequest request,int id) {
Map<String, String> map=new HashMap<String, String>();
Tiezi tiezi=new Tiezi();
tiezi.setId(id);
tiezi.setZhiding(PublicStatic.ALLZHIDING);
User user=(User) request.getSession().getAttribute(PublicStatic.USER);
tiezi.setLastupdate(""+user.getGroupname()+"\""+user.getLoginname()+"\"于"+Tool.getyyyyMMddHHmmss()+"将帖子全局置顶"+"</br>");
tieziService.update(tiezi);
map.put("flag", "1");
return map;
}
//取消全局置顶
@ResponseBody
@RequestMapping("updateallqxzhiding.do")
public Map<String, String> updateallqxzhiding(HttpServletRequest request,int id) {
Map<String, String> map=new HashMap<String, String>();
Tiezi tiezi=new Tiezi();
tiezi.setId(id);
tiezi.setZhiding("");
User user=(User) request.getSession().getAttribute(PublicStatic.USER);
tiezi.setLastupdate(""+user.getGroupname()+"\""+user.getLoginname()+"\"于"+Tool.getyyyyMMddHHmmss()+"将帖子取消全局置顶"+"</br>");
tieziService.update(tiezi);
map.put("flag", "1");
return map;
}
}
跳转后台首页
package com.yuanlrc.controller.admin;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
/*
*
* 跳转后台首页
*
*/
@Controller
@RequestMapping("/admin")
public class AdminIndexController {
private static Logger log = Logger.getLogger(AdminIndexController.class);
//后台页面查询
@RequestMapping("index.do")
public String findAllWhere(HttpServletRequest request, Model model) {
return "jsp/admin/index";
}
}
管理员信息
package com.yuanlrc.controller.admin;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yuanlrc.model.Info;
import com.yuanlrc.service.InfoService;
@Controller
@RequestMapping("/admin/info")
public class AdminInfoController {
@Autowired
InfoService infoService;
private static Logger log = Logger.getLogger(AdminInfoController.class);
//页面查询
@RequestMapping("index.do")
public String findAllWhere(HttpServletRequest request, Model model) {
Info info = infoService.find();
model.addAttribute("info", info);
return "jsp/admin/info";
}
//修改
@RequestMapping("update.do")
public String updateoradd(HttpServletRequest request,Info info) {
info.setId(1);
infoService.update(info);
info = infoService.find();
request.getSession().getServletContext().setAttribute("bbsinfo", info);
return "redirect:/admin/info/index.do ";
}
}
后台主题管理
package com.yuanlrc.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yuanlrc.model.Bankuai;
import com.yuanlrc.model.PageBean;
import com.yuanlrc.model.Zhuti;
import com.yuanlrc.service.ZhutiService;
/*
* 后台主题管理
*
*/
@Controller
@RequestMapping("/admin/zhuti")
public class AdminZhutiController {
@Autowired
ZhutiService zhutiService;
private static Logger log = Logger.getLogger(AdminZhutiController.class);
//后台页面查询
@RequestMapping("index.do")
public String findAllWhere(HttpServletRequest request, Model model,Zhuti zhuti,PageBean<Bankuai> page) {
List<Zhuti> list = zhutiService.find(zhuti);
model.addAttribute("list", list);
model.addAttribute("bankuaiId", zhuti.getBankuaiId());
return "jsp/admin/zhuti/index";
}
//跳转到修改页面
@RequestMapping("toupdateoradd.do")
public String toupdateoradd(Zhuti zhuti, Model model) {
if(zhuti.getId()!=null){
zhuti=zhutiService.findbyid(zhuti);
}
model.addAttribute("zhuti", zhuti);
return "jsp/admin/zhuti/updateoradd";
}
//修改或者新增
@RequestMapping("updateoradd.do")
public String updateoradd(Zhuti zhuti) {
if(zhuti.getId()!=null){
zhutiService.update(zhuti);
}else{
zhutiService.insert(zhuti);
}
return "redirect:index.do?bankuaiId="+zhuti.getBankuaiId();
}
//删除
@ResponseBody
@RequestMapping("del.do")
public String del(int id) {
String result=zhutiService.delete(id);
return result;
}
}
后台用户管理页面
package com.yuanlrc.controller.admin;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yuanlrc.model.PageBean;
import com.yuanlrc.model.User;
import com.yuanlrc.service.GroupService;
import com.yuanlrc.service.JifenGroupService;
import com.yuanlrc.service.UserService;
import com.yuanlrc.tool.PublicStatic;
import com.yuanlrc.tool.Tool;
/*
* 后台用户管理页面
*
*/
@Controller
@RequestMapping("/admin/user")
public class AdminUserContriller {
@Autowired
UserService userService;
@Autowired
GroupService groupService;
@Autowired
JifenGroupService jifenGroupService;
//跳转首页
@RequestMapping("index.do")
public String add(HttpServletRequest request, Model model,User user,PageBean<User> page) {
page = userService.findpage(user,page);
model.addAttribute("page", page);
model.addAttribute("quser", user);
return "jsp/admin/user/index";
}
//更新
@RequestMapping("update.do")
public String update(HttpServletRequest request, Model model,User user) {
User sessionuser=(User)request.getSession().getAttribute(PublicStatic.USER);
user.setId(sessionuser.getId());
userService.update(user);
return "redirect:/user/index.do";
}
//删除
@ResponseBody
@RequestMapping("del.do")
public String del(HttpServletRequest request, Model model,User user) {
return userService.delete(user.getId());
}
//重置密码
@ResponseBody
@RequestMapping("updatepwd.do")
public String updatepwd(HttpServletRequest request, Model model,User user) {
user.setPwd(Tool.MD5(pwd));
userService.update(user);
return "1";
}
//重置密码
@ResponseBody
@RequestMapping("updateflag.do")
public String updateflag(HttpServletRequest request, Model model,User user) {
userService.update(user);
return "1";
}
//设置管理员
@ResponseBody
@RequestMapping("updategroup.do")
public String updategroup(HttpServletRequest request, Model model,User user,int groupid) {
boolean b = groupService.updategroupbyuser(user.getId(), groupid);
if(b){
return "1";
}else{
return "0";
}
}
//删除用户帖子 留言 回帖 图片等信息信息
@ResponseBody
@RequestMapping("deluserallinfo.do")
public String deluserallinfo(HttpServletRequest request, Model model,User user) {
boolean b = userService.deluserallinfo(user.getId());
if(b){
return "1";
}else{
return "0";
}
}
@RequestMapping("tooptions.do")
public String tooptions(HttpServletRequest request, Model model,User user){
user = userService.findbyid(user);
model.addAttribute("user", user);
return "jsp/admin/user/option";
}
/**
* 设置用户vip等级
* @param request
* @param model
* @param user
* @return
*/
@RequestMapping(value="set_vip.do",method=RequestMethod.GET)
public String setVip(Model model,User user){
user = userService.findbyid(user);
model.addAttribute("user", user);
model.addAttribute("jifenGroupList", jifenGroupService.find(null));
return "jsp/admin/user/set_vip";
}
/**
* 设置用户vip等级表单提交
* @param userId
* @param jifen
* @return
*/
@RequestMapping(value="set_vip.do",method=RequestMethod.POST)
public String setVip(Integer userId, String vipLevel){
User user = new User();
user.setId(userId);
user = userService.findbyid(user);
user.setVipLevel(vipLevel);
userService.update(user);
return "redirect:index.do";
}
}
如果也想学习本系统,下面领取。关注并回复:049ssm