Java项目-SSM实现完整的BBS论坛

如果是管理员角色可以进入后台进行管理操作,主要包括友情链接添加,板块管理,用户管理,内部连接管理,网站设置等功能

部分核心实现代码:

package cc.javaee.bbs.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 cc.javaee.bbs.model.Bankuai;

import cc.javaee.bbs.model.JifenGroup;

import cc.javaee.bbs.model.PageBean;

import cc.javaee.bbs.model.User;

import cc.javaee.bbs.service.BankuaiService;

import cc.javaee.bbs.service.JifenGroupService;

import cc.javaee.bbs.tool.Pinyin4j;

import cc.javaee.bbs.tool.PublicStatic;

import cc.javaee.bbs.tool.Tool;

import cc.javaee.bbs.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 page) {

Bankuai bankuaitmp=new Bankuai();

bankuaitmp.setParentId(0);

List 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 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 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 list = bankuaiService.select(bankuai);

if(list.size()>0){

getpinyin=getpinyin+Tool.getRandom();

}

return getpinyin;

}

}

package cc.javaee.bbs.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 cc.javaee.bbs.model.Tiezi;

import cc.javaee.bbs.model.User;

import cc.javaee.bbs.service.TieziService;

import cc.javaee.bbs.tool.PublicStatic;

import cc.javaee.bbs.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()+“将帖子全局置顶”+“”);

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()+“将帖子取消全局置顶”+“”);

tieziService.update(tiezi);

map.put(“flag”, “1”);

return map;

}

}

package cc.javaee.bbs.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 cc.javaee.bbs.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 cc.javaee.bbs.model.Info;

import cc.javaee.bbs.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 cc.javaee.bbs.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 cc.javaee.bbs.model.Bankuai;

import cc.javaee.bbs.model.InnerLink;

import cc.javaee.bbs.model.JifenGroup;

import cc.javaee.bbs.model.PageBean;

import cc.javaee.bbs.model.User;

import cc.javaee.bbs.service.BankuaiService;

import cc.javaee.bbs.service.InnerLinkService;

import cc.javaee.bbs.service.JifenGroupService;

import cc.javaee.bbs.tool.Pinyin4j;

import cc.javaee.bbs.tool.PublicStatic;

import cc.javaee.bbs.tool.Tool;

import cc.javaee.bbs.tool.thread.IndexThread;

/*

  • 后台内部链接

*/

@Controller

@RequestMapping(“/admin/innerlink”)

public class AdminInnerLinkController {

@Autowired

BankuaiService bankuaiService;

@Autowired

JifenGroupService jifenGroupService;

@Autowired

InnerLinkService innerLinkService;

private static Logger log = Logger.getLogger(AdminInnerLinkController.class);

//后台页面查询

@RequestMapping(“index.do”)

public String findAllWhere(HttpServletRequest request, Model model,InnerLink innerLink,PageBean page) {

page = innerLinkService.findpage(innerLink,page);

model.addAttribute(“page”, page);

return “jsp/admin/innerlink/index”;

}

//跳转到修改页面

@RequestMapping(“toupdateoradd.do”)

public String toupdateoradd(Integer id, Model model) {

if(id!=null){

InnerLink innerLink=innerLinkService.findbyid(id);

model.addAttribute(“innerLink”, innerLink);

}

return “jsp/admin/innerlink/updateoradd”;

}

//修改或者新增

@RequestMapping(“updateoradd.do”)

public String updateoradd(HttpServletRequest request,InnerLink innerLink) {

User user=(User)request.getSession().getAttribute(PublicStatic.USER);

innerLink.setCreateuserid(user.getId());

innerLink.setIsuse(“0”);

innerLink.setType(“0”);

innerLink.setCreatetime(Tool.getyyyyMMddHHmmss());

String innerlinkhtml = innerLink.getInnerlink();

if(innerlinkhtml!=null&&innerlinkhtml.length()>0){

if(!innerlinkhtml.startsWith(“http://”)||!innerlinkhtml.startsWith(“http://”)){

innerlinkhtml=“http://”+innerlinkhtml;

innerLink.setInnerlink(innerlinkhtml);

}

}

if(innerLink.getId()!=null){

innerLinkService.update(innerLink);

}else{

innerLinkService.insert(innerLink);

}

return "redirect:index.do ";

}

//删除

@ResponseBody

@RequestMapping(“del.do”)

public String del(int id) {

String result=innerLinkService.delete(id);

return result;

}

//删除

@ResponseBody

@RequestMapping(“updateuse.do”)

public String updateuse(int id,String use) {

InnerLink innerLink=new InnerLink();

innerLink.setId(id);

innerLink.setIsuse(use);

innerLink.setCreatetime(Tool.getyyyyMMddHHmmss());

innerLinkService.update(innerLink);

new IndexThread().start();

return “1”;

}

}

最后

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Java开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!

如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
se);

innerLink.setCreatetime(Tool.getyyyyMMddHHmmss());

innerLinkService.update(innerLink);

new IndexThread().start();

return “1”;

}

}

最后

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

[外链图片转存中…(img-XCc7wZmL-1715781931265)]

[外链图片转存中…(img-vDlQs5CL-1715781931265)]

[外链图片转存中…(img-u4xGFedy-1715781931265)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Java开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!

如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值