作者主页:源码空间站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版本;
6.是否Maven项目:否;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ssm_xymh_sys/ 登录
注:Tomcat中配置项目路径必须为ssm_xymh_sys,否则会有异常
运行截图
前台用户角色
后台管理员角色
相关代码
登录控制器
package com.my.xymh.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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.my.xymh.base.BaseController;
import com.my.xymh.entity.Action;
import com.my.xymh.entity.Manage;
import com.my.xymh.entity.News;
import com.my.xymh.entity.Notice;
import com.my.xymh.entity.RoleAction;
import com.my.xymh.entity.SchoolInfo;
import com.my.xymh.entity.SchoolJob;
import com.my.xymh.entity.User;
import com.my.xymh.entity.WebCount;
import com.my.xymh.entity.Xl;
import com.my.xymh.service.ActionService;
import com.my.xymh.service.ManageService;
import com.my.xymh.service.NewsService;
import com.my.xymh.service.NoticeService;
import com.my.xymh.service.SchoolInfoService;
import com.my.xymh.service.SchoolJobService;
import com.my.xymh.service.UserService;
import com.my.xymh.service.WebCountService;
import com.my.xymh.service.XlService;
import com.my.xymh.utils.Pager;
import com.my.xymh.utils.UserUtils;
/**
* 登陆相关
* @author
*
*/
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController{
@Autowired
private WebCountService webCountService;
@Autowired
private ManageService manageService;
@Autowired
private UserService userService;
@Autowired
private ActionService actionService;
@Autowired
private NewsService newsService;
@Autowired
private NoticeService noticeService;
@Autowired
private SchoolInfoService schoolInfoService;
@Autowired
private SchoolJobService schoolJobService;
@Autowired
private XlService xlService;
/**
* 跳转登陆
* @return
*/
@RequestMapping(value = "/login.do")
public String login(){
return "login/login";
}
/**
* 用户首页
* @return
*/
@RequestMapping(value = "/index.do")
public String index(Model model){
// @Autowired
// private NewsService newsService;
// @Autowired
// private NoticeService noticeService;
// @Autowired
// private SchoolInfoService schoolInfoService;
// @Autowired
// private SchoolJobService schoolJobService;
//5张图片
List<SchoolInfo> phs = schoolInfoService.listAll();
//9个新闻
List<News> news = newsService.listAll();
//5个公告
List<Notice> notices = noticeService.listAll();
//9个招聘
List<SchoolJob> sjs = schoolJobService.listAll();
//5个校历
List<Xl> xls = xlService.listAll();
model.addAttribute("phs", phs);
model.addAttribute("news", news);
model.addAttribute("notices", notices);
model.addAttribute("sjs", sjs);
model.addAttribute("xls", xls);
WebCount load = webCountService.load(1);
load.setCountAll(load.getCountAll()+1);
webCountService.update(load);
model.addAttribute("count", load.getCountAll()+1);
return "login/index";
}
@RequestMapping(value = "/welcome.do")
public String welcome(){
return "login/welcome";
}
@RequestMapping(value = "/toLogin.do")
public String findByObj(String userName,String passWord,Integer type, Model model, HttpServletRequest request, HttpServletResponse response,HttpSession session) {
if(type == null){
return "login/login";
}
//type == 管理员 2 社团 3 教师 4用户
session.removeAttribute("isManage");
session.removeAttribute("user");
session.removeAttribute("userId");
//private Integer type;// 1老师 2 社团3.用户
if(type == 1){
Manage manage = new Manage();
manage.setUserName(userName);
manage.setPassWord(passWord);
Manage man = manageService.loadBySqlId("login", manage);
if(!isEmpty(man)){
request.getSession().setAttribute("isManage", 1);
return "login/mIndex";
}else{
return "login/login";
}
}else if(type == 2){
User user = new User();
user.setUserName(userName);
user.setPassWord(passWord);
user.setType(type);
User use = userService.loadBySqlId("login",user);
if(!isEmpty(use)){
roleAct(model, use);
request.getSession().setAttribute("user", use);
request.getSession().setAttribute("userId", use.getId());
return "login/mIndex";
}else{
return "login/login";
}
}else if(type == 3){
User user = new User();
user.setUserName(userName);
user.setPassWord(passWord);
user.setType(1);
User use = userService.loadBySqlId("login",user);
if(!isEmpty(use)){
roleAct(model, use);
request.getSession().setAttribute("user", use);
request.getSession().setAttribute("userId", use.getId());
return "login/mIndex";
}else{
return "login/login";
}
}else{
//5张图片
List<SchoolInfo> phs = schoolInfoService.listAll();
//9个新闻
List<News> news = newsService.listAll();
//5个公告
List<Notice> notices = noticeService.listAll();
//9个招聘
List<SchoolJob> sjs = schoolJobService.listAll();
//5个校历
List<Xl> xls = xlService.listAll();
model.addAttribute("phs", phs);
model.addAttribute("news", news);
model.addAttribute("notices", notices);
model.addAttribute("sjs", sjs);
model.addAttribute("xls", xls);
User user = new User();
user.setUserName(userName);
user.setPassWord(passWord);
user.setType(3);
User use = userService.loadBySqlId("login",user);
if(!isEmpty(use)){
request.getSession().setAttribute("user", use);
request.getSession().setAttribute("userId", use.getId());
}
}
return "login/index";
}
private void roleAct(Model model, User user) {
if(!isEmpty(user.getRole())){
List<Action> actions = new ArrayList<Action>();
List<RoleAction> roleActions = user.getRole().getRoleActions();
if(!isEmpty(roleActions)){
for (RoleAction ra: roleActions) {
actions.add(actionService.load(ra.getActionId()));
}
}
model.addAttribute("actions", actions);
}
}
/**
* 退出
* @param session
* @return
*/
@RequestMapping(value = "/tuichu.do")
public String tuichu(HttpSession session){
session.invalidate();
return "login/login";
}
@RequestMapping(value = "/utu.do")
public String utu(HttpSession session){
session.invalidate();
return "redirect:/login/index.do";
}
}
如果也想学习本系统,下面领取。关注并回复:138ssm