作者主页:源码空间站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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
技术栈
1. 后端:Spring SpringMVC MyBatis
2. 前端:JSP+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入localhost:8080/xxx 登录
运行截图
相关代码
ClassController
package com.se.controller;
import com.se.pojo.Order;
import com.se.pojo.User;
import com.se.server.ClassLeaderServer;
import com.se.server.ManagerServer;
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.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author DeepBlue
* @date 2019/11/5 16:15
*/
@Controller
@RequestMapping("/class")
public class ClassController {
@Autowired
private ClassLeaderServer classLeaderServer = null;
@Autowired
private ManagerServer managerServer=null;
@RequestMapping("/index")
public String showPage() {
return "class/classIndex";
}
@RequestMapping("/welcome")
public String welcome(HttpServletRequest request) {
return "managers/welcome";
}
@RequestMapping("/changeinfo")
public String changeinfo() {
return "class/changeinfo";
}
//已经发放列表
@RequestMapping("/grantlist")
public String grantList(HttpServletRequest request) {
User user = (User) request.getSession().getAttribute("session");
List<Order> orders = classLeaderServer.selectAllPassOrder(user.getUsername());
request.setAttribute("books", orders);
return "teacher/grantlist";
}
//班长信息修改
@RequestMapping("/classleaderinfo")
public String changeClassLeaderInfo(HttpServletRequest request, @RequestParam(required = false) String username
, @RequestParam(required = false) String classid, @RequestParam(required = false) String department,
@RequestParam(required = false) String email,
@RequestParam(required = false) Integer po) {
User user = (User) request.getSession().getAttribute("session");
request.setAttribute("username", user.getUsername());
if (po != null && po == 1) {
managerServer.updateClassLeaderInfo(user.getUsername(), classid, department, email);
request.setAttribute("message", "更新完成!");
}
return "class/changeinfo";
}
}
LoginController
package com.se.controller;
import com.se.pojo.User;
import com.se.server.LoginServer;
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.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author DeepBlue
* @date 2019/11/2 17:34
*/
@Controller
public class LoginController {
@Autowired
private LoginServer loginServer = null;
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView showPage(ModelAndView mv) {
mv.setViewName("login");
return mv;
}
@RequestMapping(value = "/log", method = RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response) throws IOException {
request.setCharacterEncoding("UTF-8");
String username = request.getParameterValues("username")[0];
String identity = request.getParameterValues("identity")[0];
String password = request.getParameterValues("password")[0];
User user = new User( identity,username, password);
boolean flag = loginServer.checkData(user);
if (flag) {
boolean flag2 = loginServer.checkLogin(user);
if (flag2) {
switch (user.getIdentity()) {
case "管理员":
request.getSession().setAttribute("session", user);
response.sendRedirect("./managers/index");
break;
case "老师":
request.getSession().setAttribute("session", user);
response.sendRedirect("./teacher/index");
break;
case "班长":
request.getSession().setAttribute("session", user);
response.sendRedirect("./class/index");
}
} else {
request.setAttribute("error", "用户名密码校验错误,请重新输入!");
return "login";
}
} else {
request.setAttribute("error", "信息校验错误,请检查是否注册以及字段值是否填写!");
}
return "login";
}
}
ManagerController
package com.se.controller;
import com.se.pojo.*;
import com.se.server.ManagerServer;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.lang.Class;
import java.util.List;
/**
* @author DeepBlue
* @date 2019/11/3 21:17
*/
@Controller
@RequestMapping("/managers")
public class ManagerController {
@Autowired
private ManagerServer managerServer = null;
//管理员主页
@RequestMapping("/index")
public String showPage(HttpServletRequest request) {
return "managers/managerIndex";
}
//订单首页
@RequestMapping("/order-list")
public String show1(HttpServletRequest request) {
List<Order> orders = managerServer.selectAllOrder();
request.setAttribute("orders", orders);
return "managers/order-list";
}
//教师列表
@RequestMapping("/teacherlist")
public String show2(HttpServletRequest request) {
List<Teacher> teachers = managerServer.getAllTeacher();
request.setAttribute("teachers", teachers);
return "managers/teacherlist";
}
//班长列表
@RequestMapping("/class-list")
public String classLeaderList(HttpServletRequest request) {
List<ClassLeader> classLeaders = managerServer.getAllClassLeader();
request.setAttribute("classLeader", classLeaders);
return "managers/classlist";
}
//改密码
@RequestMapping(value = "/changepassword", method = RequestMethod.POST)
public String changePassword(HttpServletRequest request) throws UnsupportedEncodingException {
request.setCharacterEncoding("UTF-8");
String oldpassword = request.getParameterValues("oldpass")[0];
String newPass = request.getParameterValues("newpass")[0];
String newPass1 = request.getParameterValues("repass")[0];
String username = request.getParameterValues("username")[0];
String kind = request.getParameterValues("kind")[0];
boolean flag = managerServer.checkDataAndUpdate(username, oldpassword, newPass, newPass1, kind);
if (flag)
request.setAttribute("message", "修改成功");
else
request.setAttribute("message", "修改失败,请检查");
return "managers/member-password";
}
//修改资料
@RequestMapping("member-edit")
public String editPage(HttpServletRequest request) {
return "managers/member-edit";
}
//修改老师密码
@RequestMapping("member-password")
public String editPasswordPage(HttpServletRequest request, @RequestParam String username) {
request.setAttribute("username", username);
return "managers/member-password";
}
//删除用户
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public void delete(HttpServletRequest request, @RequestParam String id, @RequestParam String kind) {
if (id != null) {
managerServer.delete(id, kind);
}
}
//修改班长密码
@RequestMapping(value = "member-password2")
public String editPasswordPage2(HttpServletRequest request, @RequestParam String username) {
request.setAttribute("username", username);
return "managers/member-password2";
}
@RequestMapping("/welcome")
public String show3(HttpServletRequest request) {
return "managers/welcome";
}
//审批订单
@RequestMapping("/approval")
public void approval(HttpServletRequest request, @RequestParam int id, @RequestParam int state, @RequestParam int num) {
managerServer.approval(id, state);
if (state == 1) {
managerServer.deduction(id, num);
}
}
//待发放列表
@RequestMapping("/wait-list")
public String waitPage(HttpServletRequest request) {
List<GrantBooks> grantBooks = managerServer.getBooks();
request.setAttribute("grant", grantBooks);
return "managers/wait-list";
}
//获取图书列表
@RequestMapping("/books")
public String books(HttpServletRequest request) {
List<Book> books = managerServer.books();
request.setAttribute("books", books);
return "managers/books";
}
//增加图书库存
@RequestMapping(value = "/addbook")
public String addBook(HttpServletRequest request, String place, String time) {
if (place != null && time != null) {
}
return "managers/addbook";
}
//改变图书数量的POST提交
@RequestMapping("/changebooknum")
public String changeBookNum(HttpServletRequest request,
@RequestParam int id, @RequestParam int num) {
managerServer.changeBookNum(id, num);
return "managers/changebooknum";
}
//获取修改图书页面
@RequestMapping("/getchangenumPage")
public String getChangePage(HttpServletRequest request, int id) {
request.setAttribute("id", id);
return "managers/changebooknum";
}
//增加新图书
@RequestMapping("/addnewbook")
public String addNewBook(@RequestParam(value = "bookname", required = false) String bookName,
@RequestParam(value = "booknum", required = false) Integer bookNum,
@RequestParam(value = "press", required = false) String press,
@RequestParam(value = "price", required = false) Double price) {
if (bookName != null) {
managerServer.addNewBook(bookName, bookNum, press, price);
}
return "managers/addnewbook";
}
//班长信息修改
@RequestMapping("/classleaderinfo")
public String changeClassLeaderInfo(HttpServletRequest request, @RequestParam(required = false) String username
, @RequestParam(required = false) String classid, @RequestParam(required = false) String department,
@RequestParam(required = false) String email,
@RequestParam(required = false) Integer po) {
if (classid != null) {
request.setAttribute("username", username);
request.setAttribute("classid", classid);
request.setAttribute("department", department);
request.setAttribute("email", email);
}
if (po != null && po == 1) {
managerServer.updateClassLeaderInfo(username, classid, department, email);
request.setAttribute("message", "更新完成!");
}
return "managers/classleaderinfo";
}
//发放图书
@RequestMapping("/sendbook")
public String sendBook(HttpServletRequest request, @RequestParam Integer id, @RequestParam(required = false) String time, @RequestParam(required = false) String place) {
if (id != null) {
request.setAttribute("id", id);
}
if (time != null) {
managerServer.sendBook(id, time, place);
request.setAttribute("message", "ok");
}
return "managers/sendbook";
}
//已经发放列表
@RequestMapping("/grantlist")
public String grantList(HttpServletRequest request) {
List<Order> orders = managerServer.selectAllPassOrder();
request.setAttribute("books", orders);
return "managers/grantlist";
}
//教师信息修改
@RequestMapping("/teacherinfo")
public String changeTeacherInfo(HttpServletRequest request, @RequestParam(required = false) String username
, @RequestParam(required = false) String classid, @RequestParam(required = false) String department, @RequestParam(required = false) Integer po,
@RequestParam(required = false) String email) {
if (classid != null) {
request.setAttribute("username", username);
request.setAttribute("classid", classid);
request.setAttribute("department", department);
request.setAttribute("email", email);
}
if (po != null && po == 1) {
managerServer.updateTeacherInfo(username, department, email);
String[] cs = classid.split("\\,");
System.out.println(cs);
int userId=managerServer.selectTeacherId(username);
managerServer.deleteClass(userId);
for (int i = 0; i < cs.length; i++) {
managerServer.updateClasses(userId,cs[i]);
}
request.setAttribute("message", "更新完成!");
}
return "managers/teacherinfo";
}
}
如果也想学习本系统,下面领取。关注并回复:042ssm