作者主页:夜未央5788
简介: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 8.0版本;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:freemarker+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中config.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
运行截图
相关代码
用户登录控制器
package com.qtummatrix.controller;
import com.qtummatrix.entity.User;
import com.qtummatrix.service.UserLoginService;
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 org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* create by Gongshiyong 2020-01-20 9:54
*/
@Controller
@RequestMapping("login")
public class UserLoginController {
private Map<String, Object> map = new HashMap<>();
@Autowired
private UserLoginService userLoginService;
@RequestMapping("login")
public ModelAndView toLoginPage() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("login");
return modelAndView;
}
/**
* 验证账号和密码是否正确
*
* @param userAccount
* @param userPassword
* @return
*/
@ResponseBody
@RequestMapping("verify")
public Map<String, Object> verify(String userAccount, String userPassword, HttpServletRequest request) {
List<User> userList = userLoginService.validateLogin(userAccount, userPassword);
if (userList.size() == 0) {
map.put("resultCode", "201");
map.put("resultMessage", "手机号或密码错误!");
} else {
if (userList.get(0).getIscheck() == 0) {
map.put("resultCode", "202");
map.put("resultMessage", "账号未通过审核,请联系管理员审核!");
} else {
map.put("resultCode", "200");
map.put("data", userList.get(0));
map.put("resultMessage", "登录成功!");
HttpSession session = request.getSession();
session.setAttribute("LOGIN_USER", userList.get(0));
}
}
return map;
}
/**
* 登录成功跳转到主页
*
* @return
*/
@RequestMapping("main")
public ModelAndView toMain() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("main");
return modelAndView;
}
}
用户列表控制器
package com.qtummatrix.controller;
import com.qtummatrix.entity.UserXO;
import com.qtummatrix.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
/**
* create by Gongshiyong 2020-01-21 15:44
*/
@Controller
@RequestMapping("userList")
public class UserListController {
@Autowired
private UserService userService;
private Map<String, Object> map = new HashMap<>();
/**
* 跳转到普通用户列表页面
*
* @return
*/
@GetMapping("toUserList")
public ModelAndView toUserList() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("userList");
return modelAndView;
}
/**
* 跳转到管理员列表页面
*
* @return
*/
@GetMapping("toAdminList")
public ModelAndView toAdminList() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("adminList");
return modelAndView;
}
/**
* 显示所有的普通用户信息
*
* @param pageNo
* @param pageSize
* @param stunumber
* @param phone
* @param classs
* @param realname
* @return
*/
@ResponseBody
@GetMapping("selectAllUserList")
public Object selectAllUserList(Integer pageNo, Integer pageSize, String stunumber, String phone, String classs,
String realname, Integer userId) {
return userService.selectAllUserList(pageNo, pageSize, stunumber, phone, classs, realname, userId);
}
/**
* 显示所有的管理员信息
*
* @param pageNo
* @param pageSize
* @param stunumber
* @param phone
* @param classs
* @param realname
* @return
*/
@ResponseBody
@GetMapping("selectAllAdminList")
public Object selectAllAdminList(Integer pageNo, Integer pageSize, String stunumber, String phone, String classs,
String realname, Integer userId) {
return userService.selectAllAdminList(pageNo, pageSize, stunumber, phone, classs, realname, userId);
}
/**
* 根据主键查询所有的用户信息
*
* @param id
* @return
*/
@ResponseBody
@GetMapping("selectAllUserListByPrimaryKey")
public Object selectAllUserListByPrimaryKey(Integer id) {
return userService.selectAllUserListByPrimaryKey(id);
}
/**
* 保存编辑后信息
*
* @param userXO
* @return
*/
@ResponseBody
@PutMapping("updateByPrimaryKeySelective")
public Object updateByPrimaryKeySelective(UserXO userXO) {
int i = userService.updateByPrimaryKeySelective(userXO);
if (i > 0) {
map.put("resultCode", "200");
map.put("resultMessage", "信息修改成功");
} else {
map.put("resuleCode", "201");
map.put("resultMessage", "信息修改失败");
}
return map;
}
/**
* 跳转添加用户页面
*
* @return
*/
@GetMapping("skipToUserAdd")
public ModelAndView skipToUserAdd() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("userAdd");
return modelAndView;
}
/**
* 跳转添加管理员页面
*
* @return
*/
@GetMapping("skipToAdminAdd")
public ModelAndView skipToAdminAdd() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("adminAdd");
return modelAndView;
}
/**
* 返回到用户信息页面
*
* @return
*/
@GetMapping("skipToUserList")
public ModelAndView skipToUserList() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("userList");
return modelAndView;
}
/**
* 返回到管理员信息页面
*
* @return
*/
@GetMapping("skipToAdminList")
public ModelAndView skipToAdminList() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("adminList");
return modelAndView;
}
/**
* 添加用户信息
*
* @param userXO
* @return
*/
@ResponseBody
@PostMapping("addUser")
public Object addUser(UserXO userXO) {
if (userXO.getRolename().equals("管理员")) {
userXO.setRolename("1");
userXO.setIssh(1);
}
int i = userService.insertSelective(userXO);
if (i > 0) {
map.put("resultCode", "200");
} else {
map.put("resultCode", "201");
}
return map;
}
/**
* 验证手机号是否存在
*
* @param phone
* @return
*/
@ResponseBody
@GetMapping("validatePhone")
public Object validatePhone(String phone) {
int i = userService.validatePhone(phone);
if (i == 1) {
map.put("resultCode", "200");
} else {
map.put("resultCode", "201");
}
return map;
}
/**
* 根据id删除用户信息
*
* @param id
* @return
*/
@ResponseBody
@DeleteMapping("deleteByPrimaryKey")
public Object deleteByPrimaryKey(Integer id) {
int i = userService.deleteByPrimaryKey(id);
if (i > 0) {
map.put("resultCode", "200");
} else {
map.put("resultCode", "201");
}
return map;
}
/**
* 修改密码
*
* @return
*/
@ResponseBody
@PutMapping("changePassword")
public Object changePassword(Integer id, String oldPassword, String password) {
int i = userService.changePassword(id, oldPassword, password);
if (i > 0) {
map.put("resultCode", "200");
map.put("resultMessage", "密码修改成功!");
} else {
map.put("resultCode", "201");
map.put("resultMessage", "原密码错误,修改失败!");
}
return map;
}
/**
* 管理员审核用户
*
* @param id
* @return
*/
@ResponseBody
@PutMapping("checkUser")
public Map checkUser(Integer id) {
int i = userService.checkUser(id);
if (i > 0) {
map.put("resultCode", "200");
} else {
map.put("resultCode", "201");
}
return map;
}
/**
* 管理员审核用户
*
* @param id
* @return
*/
@ResponseBody
@PutMapping("resetPassWord")
public Map resetPassWord(Integer id) {
int i = userService.resetPassWord(id);
if (i > 0) {
map.put("resultCode", "200");
} else {
map.put("resultCode", "201");
}
return map;
}
}
实验室预约Controller
package com.qtummatrix.controller;
import com.qtummatrix.service.LabAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
/**
* 实验室预约Controller
* create by Gongshiyong 2020-01-22 12:24
*/
@Controller
@RequestMapping("labAppointment")
public class LabAppointmentController {
@Autowired
private LabAppointmentService labAppointmentService;
private Map<String, Object> map = new HashMap<>();
/**
* 跳转到实验室预约页面
*
* @return
*/
@RequestMapping("toLaboratoryAppointment")
public ModelAndView toLaboratoryAppointment() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("laboratoryAppointment");
return modelAndView;
}
/**
* 查询实验室预约信息
*
* @param pageNo 页码
* @param pageSize 一页显示多少条数据
* @param name 实验室名称
* @param fzr 负责人
* @return
*/
@ResponseBody
@GetMapping("getAllLabList")
public Object getAllLabList(Integer pageNo, Integer pageSize, String name, String fzr, Integer isYy) {
return labAppointmentService.selectAllLabInfo(pageNo, pageSize, name, fzr, isYy);
}
/**
* 预约实验室
*
* @param id 实验室id
* @param userId 预约人id
* @return
*/
@ResponseBody
@PutMapping("appointment")
public Object appointment(Integer id, Integer userId) {
int i = labAppointmentService.appointment(id, userId);
if (i > 0) {
map.put("resultCode", "200");
map.put("resultMessage", "操作成功!");
} else if (i == -1) {
map.put("resultCode", "201");
map.put("resultMessage", "请预约人操作!");
}
return map;
}
}
如果也想学习本系统,下面领取。关注并回复:177ssm