文章目录
- 教材管理系统
- 一、项目演示
- 二、项目介绍
- 三、系统部分功能截图
- 四、部分代码展示
- 五、底部获取项目源码(9.9¥)
教材管理系统
一、项目演示
基于SSM的教材管理系统
二、项目介绍
有三个角色
1、管理员
功能模块:用户管理、教材录入、供应商录入、教材入库、所有付款记录、教材热度分析
管理员可以增删改查教材、教材商、入库教材、用户(用户包括学生和教师)可以对教材商、教材进行excel的导入导出操作
2、教师
功能模块:教师领取教材、教师可以领取入库的教材,可以退还教材
3、学生
功能模块:学生领取教材、学生的教材、学生付款记录、学生只能在对应的教师那里领取教材,并且可以退还教材、查询自己已经领取的教材,并且对已领教材付款。
语言:java
框架:Spring、SpringMVC、Mybatis、layui、jquery、bootstrap
数据库:MySQL
三、系统部分功能截图
四、部分代码展示
package com.dev.books.controller;import com.alibaba.fastjson.JSON;
import com.dev.books.pojo.Profession;
import com.dev.books.pojo.User;
import com.dev.books.service.UserService;
import com.dev.books.util.Layui;
import com.dev.books.util.RandNum;
import com.wordnik.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller
public class UserController {@AutowiredUserService userService;private final Logger log = LoggerFactory.getLogger(UserController.class);@ResponseBody@RequestMapping(value = "/userLogin")@ApiOperation(value = "根据用户名获取用户对象", httpMethod = "GET", response = User.class, notes = "根据用户名获取用户对象")public String userLogin(String account, String password, HttpServletRequest request ){HttpSession session = request.getSession(true);//新建session对象User user = userService.findOneUser(account,password);session.setAttribute("user",user);if(user!=null){return "success";}return "fail";}@ResponseBody@RequestMapping(value = "/getAllUser",produces="application/json;charset=UTF-8")public String getAllUser(@RequestParam("limit") String limit, @RequestParam("page") String page){//System.out.println("bjshbd");//int error = 1/0;int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);int pageSize = Integer.parseInt(limit);List<User>list = userService.findAllUsersByPage(start,pageSize);List<User>allData = userService.findAllUsers();System.out.println(list);Layui l = Layui.data(allData.size(), list);String result = JSON.toJSONString(l);System.out.println(result);return result;}@ResponseBody@RequestMapping(value = "/getUserInfo",produces="application/json;charset=UTF-8",method =RequestMethod.POST )public String getUserInfo(@RequestParam("limit") String limit, @RequestParam("page") String page,@RequestParam("key[college_data]") String college_data,@RequestParam("key[profession_data]") String profession_data,@RequestParam("key[grade_data]") String grade_data,@RequestParam("key[cclass_data]") String cclass_data){System.out.println("profession_data:"+profession_data);List<User>list = userService.findUserByCondictions(college_data,profession_data,grade_data,cclass_data);Layui l = Layui.data(list.size(), list);return JSON.toJSONString(l);}@ResponseBody@RequestMapping(value = "/updateUserInfo" )public String updateUserInfo(@RequestBody Map map,HttpServletRequest request){HttpSession session = request.getSession(true);//新建session对象User user = (User) session.getAttribute("user"); //将对应数据存入session中String id = user.getId();map.put("id",id);int n = userService.updateUserInfo(map);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/updateUserPwd" )public String updateUserPwd(@RequestBody Map map,HttpServletRequest request){HttpSession session = request.getSession(true);//新建session对象User user = (User) session.getAttribute("user"); //将对应数据存入session中String id = user.getId();System.out.println(map);String password = map.get("password").toString();System.out.println("password:"+password);int n = userService.updateUserPwd(password,id);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/findUserById" ,produces="application/json;charset=UTF-8")public String findUserById(HttpServletRequest request){HttpSession session = request.getSession(true);//新建session对象User user = (User) session.getAttribute("user"); //将对应数据存入session中String id = user.getId();User u = userService.findUserById(id);List<User> list = new ArrayList<>();list.add(u);Layui l = Layui.data(list.size(), list);return JSON.toJSONString(l);}/*删除学生,教师信息*/@ResponseBody@RequestMapping("/deleteUser")public String deleteUser(@RequestParam("id")String id){User user = userService.findUserById(id);int n = 0;if(user.getIdentification().equals("学生")){userService.deleteUser(id);n = userService.deleteStuUserInfo(id);if(n>0){return "success";}else {return "failure";}}else if(user.getIdentification().equals("教师")){userService.deleteUser(id);userService.deleteStuUserInfo(id);n = userService.deleteTeacherUserInfo(id);if(n>0){return "success";}else {return "failure";}}return "failure";}/*增加学生信息*/@ResponseBody@RequestMapping("/insertUser")public String insertUser(){return "";}@ResponseBody@RequestMapping(value = "/findAllTeacher",produces="application/json;charset=UTF-8")public String findAllTeacher(){List<User> users = userService.findAllTeacher();Layui l = Layui.data(users.size(), users);return JSON.toJSONString(l);}@ResponseBody@RequestMapping(value = "/insertStuUser",produces="application/json;charset=UTF-8")public String insertStuUser(@RequestBody Map map){Map userMap = new HashMap();Map userInfoMap = new HashMap();String id = RandNum.getGUID();userMap.put("id",id);userMap.put("identification","学生");userMap.put("name",map.get("name"));userMap.put("password",map.get("password"));userMap.put("phone",map.get("phone"));userMap.put("email",map.get("email"));userInfoMap.put("user_id",id);userInfoMap.put("col_id",map.get("col_id"));userInfoMap.put("prof_id",map.get("prof_id"));userInfoMap.put("gra_id",map.get("gra_id"));userInfoMap.put("ccl_id",map.get("ccl_id"));userInfoMap.put("t_id",map.get("t_id"));userService.insertUser(userMap);int n = userService.insertStuUserInfo(userInfoMap);if(n>0){return "success";}else {return "failure";}}@ResponseBody@RequestMapping(value = "/insertTeaUser",produces="application/json;charset=UTF-8")public String insertTeaUser(@RequestBody Map map){Map userMap = new HashMap();Map teacherInfoMap = new HashMap();String id = RandNum.getGUID();userMap.put("id",id);userMap.put("identification","教师");userMap.put("name",map.get("name"));userMap.put("password",map.get("password"));userMap.put("phone",map.get("phone"));userMap.put("email",map.get("email"));teacherInfoMap.put("user_id",id);teacherInfoMap.put("col_id",map.get("col_id"));teacherInfoMap.put("prof_id",map.get("prof_id"));teacherInfoMap.put("gra_id",map.get("gra_id"));teacherInfoMap.put("ccl_id",map.get("ccl_id"));userService.insertUser(userMap);int n = userService.insertStuUserInfo(teacherInfoMap);if(n>0){return "success";}else {return "failure";}}}
package com.dev.books.controller;import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
import com.alibaba.fastjson.JSON;
import com.dev.books.pojo.Book;
import com.dev.books.pojo.Supplier;
import com.dev.books.service.BookService;
import com.dev.books.service.SupplierService;
import com.dev.books.util.Layui;
import com.dev.books.util.POIUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller
public class BookController {@AutowiredBookService bookService;/*将表格中的数据插入到*/@ResponseBody@RequestMapping("/book/insertData")public Object supplierImportExcel(@RequestParam("file") MultipartFile file){int n= 0;//long s = file.getSize();Map<String,Object> map = new HashMap<>();Map<String, Object> result = new HashMap<String, Object>();List<Book> book = POIUtil.importExcel(file,Book.class);System.out.println(book);//List <Supplier> supplier2 = supplierService.findAllSupplier();//supplier1.addAll(supplier2);for(int i=0;i<book.size();i++){map.put("id",book.get(i).getId());map.put("book_name",book.get(i).getBook_name());map.put("book_kind",book.get(i).getBook_kind());map.put("book_price",book.get(i).getBook_price());map.put("qs_name",book.get(i).getQs_name());n = bookService.addBook(map);}System.out.println("map:"+map);if(n>0){result.put("code", 0);result.put("message", "success");result.put("data", file.getOriginalFilename());}else{result.put("code", -1);result.put("message", "failure");result.put("data", file.getOriginalFilename());}return result;}@ResponseBody@RequestMapping(value = "/book/getAllBookByPage",produces="application/json;charset=UTF-8")public String getAllBookByPage(@RequestParam("limit") String limit, @RequestParam("page") String page){int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);int pageSize = Integer.parseInt(limit);List <Supplier> books = bookService.findAllBookByPages(start,pageSize);List <Supplier> allData = bookService.findAllBook();Layui l = Layui.data(allData.size(), books);return JSON.toJSONString(l);}@ResponseBody@RequestMapping(value = "/book/getAllBook",produces="application/json;charset=UTF-8")public String getAllBook(){List <Supplier> allData = bookService.findAllBook();Layui l = Layui.data(allData.size(), allData);return JSON.toJSONString(l);}@ResponseBody@RequestMapping(value = "/book/findAllBookKind",produces="application/json;charset=UTF-8")public String findAllBookKind(){List <String> allKinds = bookService.findAllBookKind();return JSON.toJSONString(allKinds);}@RequestMapping("/book/exportData")public String exportData(HttpServletResponse response){List <Supplier> books = bookService.findAllBook();POIUtil.exportExcel(books,Book.class,"书籍基本信息","",response);return NormalExcelConstants.EASYPOI_EXCEL_VIEW;//需要配置新的视图解析器并设置优先级和扫描}@ResponseBody@RequestMapping(value = "/updateBookById")public String updateBookById(@RequestBody Map map){int n = bookService.updateBookById(map);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/deleteBookById")public String deleteBookById(@RequestParam("book_id")String book_id){int n = bookService.deleteBookById(book_id);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/findAllBookByBookName",produces="application/json;charset=UTF-8")public String findAllBookByBookName(@RequestParam("key[book_name]")String book_name){List<Supplier> books = bookService.findAllBookByBookName(book_name);Layui l = Layui.data(books.size(), books);return JSON.toJSONString(l);}@ResponseBody@RequestMapping(value = "/findBookNameByQsName",produces="application/json;charset=UTF-8")public String findBookNameByQsName(@RequestParam("qs_name")String qs_name){List<String> book_names = bookService.findBookNameByQsName(qs_name);return JSON.toJSONString(book_names);}
}
package com.dev.books.controller;import com.alibaba.fastjson.JSON;
import com.dev.books.pojo.StoreIn;
import com.dev.books.pojo.StoreOut;
import com.dev.books.service.StoreInService;
import com.dev.books.util.Layui;
import com.dev.books.util.RandNum;
import org.apache.commons.logging.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;@Controller
public class StoreInController {@AutowiredStoreInService storeInService;@ResponseBody@RequestMapping(value = "/getAllStoreInByPage",produces="application/json;charset=UTF-8")public String getAllStoreInByPage(@RequestParam("limit") String limit, @RequestParam("page") String page){int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);int pageSize = Integer.parseInt(limit);List<StoreIn> storeIns = storeInService.findAllStoreInByPage(start,pageSize);List<StoreIn> allData = storeInService.findAllStoreIn();Layui l = Layui.data(allData.size(), storeIns);String result = JSON.toJSONString(l);System.out.println("result:"+result);return result;}@ResponseBody@RequestMapping(value = "/getAllStoreInBookName",produces="application/json;charset=UTF-8")public String getAllStoreInBookName(){List<StoreIn> allData = storeInService.findAllStoreIn();List<String> list = new ArrayList<>();for (int i=0;i<allData.size();i++){list.add(allData.get(i).getBook_name());}Layui l = Layui.data(allData.size(), list);String result = JSON.toJSONString(l);System.out.println("result:"+result);return result;}@ResponseBody@RequestMapping(value = "/insertStoreIn")public String insertStoreIn(/*@RequestParam("store_info")String store_info,@RequestParam("book_count")String book_count,@RequestParam("book_name")String book_name*/@RequestBody Map dataMap){System.out.println(dataMap);String store_info =dataMap.get("store_info").toString();String book_count = dataMap.get("book_count").toString();String book_name =dataMap.get("book_name").toString();String qs_name = dataMap.get("qs_name").toString();String id = RandNum.getGUID();Date date = new Date();StoreIn storeIn = new StoreIn(id,date,store_info,Integer.parseInt(book_count),book_name,qs_name,Integer.parseInt(book_count));/*使用fastjson把类转换成json,有两个好处,1.需要map类型传参数2.fastjson能够格式化时间类型*/String storeInJson = JSON.toJSONString(storeIn);Map map = JSON.parseObject(storeInJson, Map.class);System.out.println(map);int n = storeInService.insertStoreIn(map);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/getStoreInById")public String getStoreInById(@RequestParam("id")String id){StoreIn storeIn = storeInService.findStoreInById(id);String book_id = storeIn.getBook_id();return book_id;}@ResponseBody@RequestMapping(value = "/deleteStoreIn")public String deleteStoreIn(@RequestParam("id")String id){int n = storeInService.deleteStoreIn(id);if(n>0){return "success";}return "failure";}@ResponseBody@RequestMapping(value = "/findStoreInPercent",produces="application/json;charset=UTF-8")public String findStoreInPercent(@RequestParam("book_type")String book_type){List<StoreIn> storeIns = storeInService.findStoreInPercent(book_type);Map<String, List<StoreIn>> map = new HashMap<String, List<StoreIn>>();for (StoreIn storeIn : storeIns) {if (map.get(storeIn.getBook_name()) == null) {List<StoreIn> data = new ArrayList<StoreIn>();data.add(storeIn);map.put(storeIn.getBook_name(), data);} else {//定位到和之前键相同的list,然后扩充listList<StoreIn> data = map.get(storeIn.getBook_name());data.add(storeIn);}}System.out.println(map);int book_count = 0;int book_init = 0;double persent = 0.0;List<StoreIn> so = new ArrayList<>();for (Map.Entry<String, List<StoreIn>> a : map.entrySet()) {List<StoreIn> sto = a.getValue();for(int i=0;i<sto.size();i++) {book_count += sto.get(i).getBook_count();book_init += sto.get(i).getBook_init();System.out.println("book_count:"+book_count);System.out.println("book_init:"+book_init);Double p = (book_init-book_count) *1.0/ book_init;BigDecimal bd = new BigDecimal(p);persent = bd.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();System.out.println(persent);}so.add(new StoreIn(a.getKey(),persent));book_count = 0;book_init = 0;}System.out.println("list表总计:"+so);String jsonString = JSON.toJSONString(so);return jsonString;}
}
五、底部获取项目源码(9.9¥)
有问题,或者需要协助调试运行项目的也可以