作者主页:源码空间站2022
简介:Java领域优质创作者、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.数据库:MySql 5.7、8.0版本均可;
6.是否maven项目:否;
技术栈
JSP+CSS+JavaScript+jquery+servlet+mysql
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目;
3. 将项目中src/prop/database.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
管理员账号/密码:admin/123456
社团管理员账号/密码:user/123456
用户账号/密码:user/123456
运行截图
设计文稿
用户角色
管理员角色
相关代码
活动管理控制器
@Controller
@RequestMapping(value = "/Activity")
public class ActivityController {
@Autowired
private ActivityService activityService;
// 1根据id查询
@RequestMapping("/findActivityById")
public @ResponseBody Activity findActivityById(Model model, String AC_id) {
System.out.println("用户传过来的id值:" + AC_id);
int id = Integer.parseInt(AC_id);
Activity activity = activityService.findActivityById(id);
System.out.println("查到的值:"+activity.getAC_theme());
return activity;
}
// 2查询所有未审核活动信息(分页)
@RequestMapping("/findAllActivity")
public String findAllActivity(Model model, String type, Integer pageNo,
Integer pageSize) {
System.out.println("===========查询所有未审核活动信息==============");
System.out.println("传到type的值:" + type);
PagedResult<Activity> pagedResult = (PagedResult<Activity>) activityService
.findAllActivity(pageNo, pageSize);
model.addAttribute("pagedResult", pagedResult);
List<Activity> activityList = pagedResult.getDataList();
System.out.println("当前页码:" + pageNo);
System.out.println("总页数:" + pageSize);
System.out.println(pagedResult.getPages());
model.addAttribute("activityList", activityList);
return "jsp/sonpage/activity/activityson/findActivity";
}
// 3模糊查询未审核活动信息
@RequestMapping("/findLikeNameActivity")
public String findLikeNameActivity(String AC_id, String AC_theme,
Model model, String type) {
System.out.println("===========模糊查询未审核活动信息============");
System.out.println("AC_id:" + AC_id);
System.out.println("AC_theme:" + AC_theme);
//String AC_id=ac_id;
//String AC_theme=ac_theme;
Map map = new HashMap();
map.put("AC_id", AC_id);
map.put("AC_theme", AC_theme);
List<Activity> activityList = activityService.findLikeNameActivity(map);
model.addAttribute("activityList", activityList);
if (type.equals("show")) {
if (("").equals(AC_id) && ("").equals(AC_theme)) {
System.out.println("========输入为空跳转查询所有的方法=========");
return "forward:findAllActivity.action?type";
}
return "jsp/sonpage/activity/activityson/findActivity";
}
return "jsp/sonpage/activity/activityson/findActivity";
}
// 4添加活动信息
@RequestMapping("/addActivity")
public String addActivity(HttpServletRequest request, Activity activity) {
System.out.println("=========添加活动信息==========");
activityService.addActivity(activity);
// 查询所有物品
List<Goods> goodsList = activityService.findAllGoods();
request.getSession().setAttribute("goodsList", goodsList);
// 将刚添加的活动id保存,供添加活动物品时使用
request.getSession().setAttribute("AC_id", activity.getAC_id());
// 跳转到添加物品
return "redirect:../jsp/sonpage/activity/activityson/addActivityGoods.jsp";
}
// 5删除活动信息
@RequestMapping("/delActivity")
public String delActivity(int AC_id) {
System.out.println("============根据id删除活动信息============");
System.out.println("页面传值:" + AC_id);
activityService.delActivity(AC_id);
return "forward:findAllCActivity.action?type=show1";
}
// 6修改活动信息
@RequestMapping("/updateActivity")
public String updateActivity(Activity activity){
System.out.println("===========updateActivity==============");
System.out.println("活动编号:"+activity.getAC_theme());
activityService.updateActivity(activity);
return "forward:findAllCActivity.action?type=show";
}
// 7查询所有已审核活动信息(分页)
@RequestMapping("/findAllCActivity")
public String findAllCActivity(Model model, String type, Integer pageNo,
Integer pageSize) {
System.out.println("===========查询所有已审核活动信息==============");
System.out.println("传到type的值:" + type);
PagedResult<Activity> pagedResult = (PagedResult<Activity>) activityService
.findAllCActivity(pageNo, pageSize);
model.addAttribute("pagedResult", pagedResult);
List<Activity> activityList = pagedResult.getDataList();
System.out.println("当前页码:" + pageNo);
System.out.println("总页数:" + pageSize);
System.out.println(pagedResult.getPages());
model.addAttribute("activityList", activityList);
if (type.equals("show1")) {
return "jsp/sonpage/activity/activityson/delActivity";
}
if (type.equals("show")) {
return "jsp/sonpage/activity/activityson/findCActivity";
}
return "jsp/sonpage/activity/activityson/findCActivity";
}
// 8模糊查询已审核活动信息
@RequestMapping("/findLikeNameCActivity")
public String findLikeNameCActivity(String AC_id, String AC_theme,
Model model, String type) {
System.out.println("===========模糊查询已审核活动信息============");
//String AC_id=id;
//String AC_theme=theme;
System.out.println("AC_id:" + AC_id);
System.out.println("AC_theme:" + AC_theme);
Map map = new HashMap();
map.put("AC_id", AC_id);
map.put("AC_theme", AC_theme);
List<Activity> activityList = activityService
.findLikeNameCActivity(map);
model.addAttribute("activityList", activityList);
if (type.equals("show")) {
if (("").equals(AC_id) && ("").equals(AC_theme)) {
return "forward:findAllCActivity.action?type";
}
return "jsp/sonpage/activity/activityson/findCActivity";
}
if (type.equals("show1")) {
if (("").equals(AC_id) && ("").equals(AC_theme)) {
return "forward:findAllCActivity.action?type";
}
return "jsp/sonpage/activity/activityson/delActivity";
}
return "";
}
// 8批量删除已审批活动信息
@RequestMapping("/delItem")
public @ResponseBody boolean delItem(Model model, String ids) {
System.out.println("==========批量删除已审批活动信息==========");
System.out.println("ids:" + ids);
// 用数组接收获取的选中集合
String[] str = ids.split("_");
for (int i = 0; i < str.length; i++) {
int id = Integer.parseInt(str[i]);
activityService.delActivity(id);
System.out.println("删除的方法执行了");
}
// return "forward:findAllMember.action?type=show2";
return true;
}
//审批(同意)
@RequestMapping("/updateActivityById")
public @ResponseBody boolean updateActivityById(String id){
System.out.println("===========updateActivityById==============");
int AC_id=Integer.parseInt(id);
activityService.updateActivityById(AC_id);
return true;
}
//审批(不同意)
@RequestMapping("/updateActivityNById")
public @ResponseBody boolean updateActivityNById(String id,String AC_remark){
System.out.println("===========updateActivityNById==============");
int AC_id=Integer.parseInt(id);
activityService.updateActivityNById(AC_remark,AC_id);
return true;
}
//首页显示
@RequestMapping("/show")
public String show(HttpServletRequest request,Model model){
System.out.println("===========show==============");
List<Activity> activityList=activityService.findshow();
request.getSession().setAttribute("activityList", activityList);
return "redirect:../jsp/sonpage/index.jsp";
}
// 添加活动物品
@RequestMapping("/addActivityGoods")
@ResponseBody
public boolean addActivityGoods(HttpServletRequest request, String strnums, String strids) {
System.out.println("数量:" + strnums);
System.out.println("ID:" + strids);
String[] arrNums = strnums.split(",");
String[] arrIds = strids.split(",");
if (arrNums.length < 1 || arrIds.length < 1) {
return false;
} else {
// 获取活动ID
System.out.println(request.getSession().getAttribute("AC_id"));
Integer AC_id = (Integer) request.getSession().getAttribute("AC_id");
boolean result = activityService.addActivityGoods(AC_id, arrNums, arrIds);
return result;
}
}
}
管理端控制器
@Controller
@RequestMapping(value = "/Manager")
public class ManagerController {
@Autowired
private ManagerService managerService;
// 1根据id查询
@RequestMapping("/findManagerById")
public @ResponseBody Manager findManagerById(Model model,String ma_id){
System.out.println("===============findManagerById=================");
System.out.println("MA_id:"+ma_id);
int id=Integer.parseInt(ma_id);
Manager manager=managerService.findManagerById(id);
System.out.println("manager:"+manager.getMA_name());
model.addAttribute("manager", manager);
return manager;
}
// 2查询所有(分页显示)
@RequestMapping("/findAllManager")
public String findAllManager(Model model, String type, Integer pageNo,
Integer pageSize) {
System.out.println("===========findAllManager==============");
System.out.println("传到type的值:" + type);
PagedResult<Manager> pagedResult = (PagedResult<Manager>) managerService
.findAllManager(pageNo, pageSize);
model.addAttribute("pagedResult", pagedResult);
List<Manager> managerList = pagedResult.getDataList();
System.out.println("当前页码:" + pageNo);
System.out.println("总页数:" + pageSize);
System.out.println(pagedResult.getPages());
model.addAttribute("managerList", managerList);
if (type.equals("show1")) {
return "jsp/sonpage/manager/managerson/findManager";
}
if (type.equals("show2")) {
return "jsp/sonpage/manager/managerson/delManager";
}
return "";
}
// 3模糊查询
@RequestMapping("/findLikeNameManager")
public String findLikeNameManager(String ma_id, String ma_name,
Model model, String type) {
System.out.println("===========模糊查询系统管理员信息============");
//String ma_id=id;
//String ma_name=name;
System.out.println("ma_id:" + ma_id);
System.out.println("ma_name:" + ma_name);
System.out.println("type:" + type);
Map map = new HashMap();
map.put("ma_id", ma_id);
map.put("ma_name", ma_name);
List<Manager> managerList = managerService.findLikeNameManager(map);
model.addAttribute("managerList", managerList);
if (type.equals("show1")) {
System.out.println("===========从查询管理员信息页面===========");
if (("").equals(ma_id) && ("").equals(ma_name)) {
System.out.println("1没有传值");
System.out.println("===========findAllManager==============");
System.out.println("传到type的值:" + type);
PagedResult<Manager> pagedResult = (PagedResult<Manager>) managerService
.findAllManager(0, 5);
model.addAttribute("pagedResult", pagedResult);
managerList = pagedResult.getDataList();
System.out.println("当前页码:" + 1);
System.out.println("总页数:" + 5);
System.out.println(pagedResult.getPages());
model.addAttribute("managerList", managerList);
return "jsp/sonpage/manager/managerson/findManager";
}
System.out
.println("===================跳回查询页面======================");
return "jsp/sonpage/manager/managerson/findManager";
}
if (type.equals("show2")) {
System.out.println("===========从删除管理员信息页面===========");
if (("").equals(ma_id) && ("").equals(ma_name)) {
System.out.println("2没有传值");
System.out.println("1没有传值");
System.out.println("===========findAllManager==============");
System.out.println("传到type的值:" + type);
PagedResult<Manager> pagedResult = (PagedResult<Manager>) managerService
.findAllManager(0, 5);
model.addAttribute("pagedResult", pagedResult);
managerList = pagedResult.getDataList();
System.out.println("当前页码:" + 1);
System.out.println("总页数:" + 5);
System.out.println(pagedResult.getPages());
model.addAttribute("managerList", managerList);
return "jsp/sonpage/manager/managerson/findManager";
}
System.out
.println("===================跳回删除页面======================");
return "jsp/sonpage/manager/managerson/delManager";
}
return "";
}
// 4添加系统管理员
@RequestMapping("/addManager")
public String addManager(Manager manager) {
System.out.println("=========添加系统管理员=========");
System.out.println("姓名:" + manager.getMA_name());
managerService.addManager(manager);
return "jsp/sonpage/manager/managerson/addManager";
}
// 5删除系统管理员
@RequestMapping("/delManager")
public String delManager(String MA_id) {
System.out.println("===========删除系统管理员===========");
System.out.println("MA_id:" + MA_id);
int id = Integer.parseInt(MA_id);
managerService.delManager(id);
return "forward:findAllManager.action?type=show2";
}
// 6修改系统管理员
@RequestMapping("/updateManager")
public String updateManager(Manager manager) {
System.out.println("=========修改系统管理员=========");
System.out.println("名字:"+manager.getMA_name());
managerService.updateManager(manager);
return "forward:findAllManager.action?type=show1";
}
// 8批量删除管理员信息
@RequestMapping("/delItem")
public @ResponseBody boolean delItem(Model model, String ids) {
System.out.println("==========批量删除已审批活动信息==========");
System.out.println("ids:" + ids);
// 用数组接收获取的选中集合
String[] str = ids.split("_");
for (int i = 0; i < str.length; i++) {
int id = Integer.parseInt(str[i]);
managerService.delManager(id);
System.out.println("删除的方法执行了");
}
// return "forward:findAllMember.action?type=show2";
return true;
}
//9登陆(根据学号查找)
@RequestMapping("/findManagerByNum")
public @ResponseBody boolean findManagerByNum(HttpSession session,String num,String pwd){
System.out.println("===============findManagerByNum=================");
System.out.println("num:"+num);
Subject subject = SecurityUtils.getSubject();
subject.getSession().setAttribute("userType", "Manager");
// 保存至令牌环中,供MyRealm做验证
UsernamePasswordToken token = new UsernamePasswordToken(num, pwd);
// 保存用户类型供MyRealm获取
try {
// 跳转到MyRealm 做登录用户名和密码验证
subject.login(token);
session.setAttribute("num", num);
session.setAttribute("role", "2");
System.out.println("ManagerController-->>findManagerByNum-->>登录成功");
return true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
System.out.println("ManagerController-->>findManagerByNum-->>登录失败");
return false;
}
// Manager manager=managerService.findManagerByNum(num);
// System.out.println("manager:"+manager.getMA_pwd());
// String MA_pwd=manager.getMA_pwd();
// session.setAttribute("num", num);
// session.setAttribute("role", "2");
// if(MA_pwd.equals(pwd)){
// System.out.println("返回值是真");
// return true;
// }else{
// return false;
// }
}
// 登出
@RequestMapping("/logout")
public String logout(Model model) {
try {
Subject subject = SecurityUtils.getSubject();
System.out.println("==========>>>>>>>>logout>>>>>>======"+subject.getPrincipal().toString());
subject.logout();
System.out.println("****************logout成功*************");
} catch (Exception e) {
}
return "/jsp/sonpage/login";
}
//9修改密码
@RequestMapping("/updateManagerPwd")
public @ResponseBody boolean updateManagerPwd(Model model,String num,String oldPwd,String newPwd){
System.out.println("===============updateManagerPwd=================");
System.out.println("旧密码:"+oldPwd);
System.out.println("新密码:"+newPwd);
String MA_pwd=newPwd;
String MA_num=num;
Manager manager=managerService.findManagerByNum(num);
String pwd=manager.getMA_pwd();
if(pwd.equals(oldPwd)){
managerService.updateManagerPwd(MA_pwd,MA_num);
return true;
}else{
return false;
}
}
}
会员管理控制器
@Controller
@RequestMapping(value="/Member")
public class MemberCotroller {
@Autowired
private MemberService memberService;
//1根据id查询会员信息
@RequestMapping("/findMemberById")
public @ResponseBody Member findMemberById(Model model,String m_id){
System.out.println("===============findMemberById=================");
System.out.println("m_id:"+m_id);
int id=Integer.parseInt(m_id);
Member member=memberService.findMemberById(id);
System.out.println("member:"+member.getM_name());
//model.addAttribute("member", member);
return member;
}
//2查询所有会员信息
@RequestMapping("/findAllMember")
public String findAllMember(Model model,String type,Integer pageNo,Integer pageSize){
System.out.println("===========findAllMember==============");
System.out.println("传到type的值:"+type);
PagedResult<Member> pagedResult= memberService.findAllMember(pageNo, pageSize);
model.addAttribute("pagedResult", pagedResult);
List<Member> memberList=pagedResult.getDataList();
System.out.println("当前页码:"+pageNo);
System.out.println("条数:"+pageSize);
System.out.println("总页面数目:"+pagedResult.getPages());
model.addAttribute("memberList", memberList);
if(type.equals("show1")){
return "jsp/sonpage/member/memberson/findMember";
}
if(type.equals("show2")){
return "jsp/sonpage/member/memberson/delMember";
}
return "";
}
//3根据名字模糊查询
@RequestMapping(value ="/findLikeNameMember")
public String findLikeNameMember(String m_id, String m_name, Model model,String type){
System.out.println("===========模糊查询会员信息============");
System.out.println("m_id:"+m_id);
System.out.println("m_name:"+m_name);
System.out.println("type:"+type);
//String m_id=id;
//String m_name=name;
Map map = new HashMap();
map.put("m_id", m_id);
map.put("m_name", m_name);
List<Member> memberList=memberService.findLikeNameMember(map);
model.addAttribute("memberList", memberList);
if (type.equals("show1")) {
System.out.println("===========从查询会员信息页面===========");
if(("").equals(m_id) && ("").equals(m_name)){
System.out.println("1没有传值");
return "jsp/sonpage/member/memberson/findMember";
}
System.out.println("===================跳回查询页面======================");
return "jsp/sonpage/member/memberson/findMember";
}
if (type.equals("show2")) {
System.out.println("===========从删除会员信息品页面===========");
if(("").equals(m_id) && ("").equals(m_name)){
System.out.println("2没有传值");
return "forward:findAllMember.action?type?type=show";
}
System.out.println("===================跳回删除页面======================");
return "jsp/sonpage/member/memberson/delMember";
}
return "";
}
//4添加会员
@RequestMapping("/addMember")
public String addMember(Member member,String type){
System.out.println("===============addMember=================");
if(member.getM_id() != 0) {
Member temp = memberService.findMemberByNum(member.getM_id()+"");
temp.setC_id(member.getC_id());
if(!StringUtils.isEmpty(member.getM_qq())) {
temp.setM_qq(member.getM_qq());
}
if(!StringUtils.isEmpty(member.getM_tel())) {
temp.setM_tel(member.getM_tel());
}
memberService.updateMember(temp);
}else{
memberService.addMember(member);
}
if(type.equals("show3")){
return "forward:/Community/findAllCommunity.action?type";
}else if(type.equals("show")){
return "jsp/sonpage/member/memberson/addMember";
}else if(type.equals("show1")){
return "jsp/sonpage/regist";
}
return "";
}
//4添加会员
@RequestMapping("/addMember1")
public @ResponseBody boolean addMember1(String m_num,String m_pwd,String m_name,String m_sex,String m_class){
System.out.println("===============addMember=================");
Member member=new Member();
member.setM_num(m_num);
member.setM_pwd(m_pwd);
member.setM_name(m_name);
member.setM_sex(m_sex);
member.setM_class(m_class);
member.setC_id(1);
member.setR_id(1);
memberService.addMember(member);
return true;
}
//5根据id删除会员
@RequestMapping("/delMember")
public String delMember(String m_id,String type){
System.out.println("=============delMember==================");
System.out.println("m_id:"+m_id);
System.out.println("type:"+type);
int id=Integer.parseInt(m_id);
memberService.delMember(id);
return "redirect:findAllMember.action?type=show2";
}
//6修改会员信息
@RequestMapping("/updateMember")
public String updateMember(Member member){
System.out.println("==========修改会员信息==========");
memberService.updateMember(member);
return "redirect:findAllMember.action?type=show1";
}
//7批量删除
@RequestMapping("/delItem")
public @ResponseBody boolean delItem(Model model, String ids) {
System.out.println("==========批量删除会员==========");
System.out.println("ids:"+ids);
// 用数组接收获取的选中集合
String[] str = ids.split("_");
for (int i = 0; i < str.length; i++) {
int id = Integer.parseInt(str[i]);
memberService.delMember(id);
System.out.println("删除的方法执行了");
}
//return "forward:findAllMember.action?type=show2";
return true;
}
//8登陆(根据学号查找)
@RequestMapping("/findMemberByNum")
public @ResponseBody boolean findMemberByNum(HttpSession session,String num,String pwd){
System.out.println("===============findMemberByNum=================");
System.out.println("num:"+num);
Subject subject = SecurityUtils.getSubject();
subject.getSession().setAttribute("userType", "Member");
// 保存至令牌环中,供MyRealm做验证
UsernamePasswordToken token = new UsernamePasswordToken(num, pwd);
// 保存用户类型供MyRealm获取
try {
// 跳转到MyRealm 做登录用户名和密码验证
subject.login(token);
session.setAttribute("num", num);
session.setAttribute("role", "3");
System.out.println("MemberCotroller-->>findMemberByNum-->>登录成功");
return true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
System.out.println("MemberCotroller-->>findMemberByNum-->>登录失败");
return false;
}
// Member member=memberService.findMemberByNum(num);
// System.out.println("manager:"+member.getM_pwd());
// String m_pwd=member.getM_pwd();
// session.setAttribute("num", num);
// session.setAttribute("role", "3");
// if(m_pwd.equals(pwd)){
// System.out.println("返回值是真");
// return true;
// }else{
// return false;
// }
}
//9修改密码
@RequestMapping("/updateMemberPwd")
public @ResponseBody boolean updateMemberPwd(Model model,String num,String oldPwd,String newPwd){
System.out.println("===============updateManagerPwd=================");
System.out.println("旧密码:"+oldPwd);
System.out.println("新密码:"+newPwd);
String M_pwd=newPwd;
String M_num=num;
Member manager=memberService.findMemberByNum(num);
String pwd=manager.getM_pwd();
if(pwd.equals(oldPwd)){
memberService.updateMemberPwd(M_pwd,M_num);
return true;
}else{
return false;
}
}
}
如果也想学习本系统,下面领取。关注并回复:096jsp