基于javaweb+jsp的教材管理系统(java+SSM+jsp+mysql+maven)
一、项目简述
功能包括: 管理员可以增删改查教材、教材商、入库教材、用户(用 户包括学生和教师)可以对教材商、教材进行。xcel的导入 导出操作。教U阿以领取入库的教材,可以退还教材。学 生只能在对应的教师那里领取教材,并且可以退还教材、 查询自己已经领取的教材。并且对已领教材付款等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
@GetMapping("/seeworkdata")
public String seeWorkData() {
return "teacher/workapproval/seewdata";
}
//填写表格页面
@GetMapping("/term_debriefing")
public String termDebriefing() {
return "teacher/fillouttable/termdebriefing";
}
@GetMapping("/year_debriefing")
public String yearDebriefing() {
return "teacher/fillouttable/yeardebriefing";
}
@GetMapping("/annual_assessment")
public String annualAssessment() {
return "teacher/fillouttable/annualassessment";
}
@GetMapping("/work_load")
public String workLoad() {
return "teacher/fillouttable/workload";
}
@GetMapping("/technical_personnel")
public String technicalPersonnel() {
return "teacher/fillouttable/technicalpersonnel";
String saveFileName = savePath +File.separator + uploadFileName;
File dirs = new File(savePath);
//判断路径是否存在,如果不存在就创建一个
if (!dirs.exists()) {
dirs.mkdirs();
}
file.transferTo(new File(dirs, uploadFileName)); // 开始接受文件
SubjectWithBLOBs project = subject1;
project.setProjectname(projectName);
project.setIdProjecttype(idProjecttype);
project.setIdProjectsource(idProjectsource);
project.setFilepath(saveFileName);
project.setMarchspecialty(marchspecialty.trim());
project.setTeachernames(teachernames);
//修改后状态置 0
project.setSelectFlag(0);
project.setVerifyprojectFlag(0);
project.setReleaseFlag(0);
int i = subjectService.updateSubjectByid(project);
return Msg.success();
}
}
@GetMapping("/getSubjectById")
@ResponseBody
// exit 退出登录
@GetMapping("/exit")
public String exit(HttpSession httpSession) {
//将Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
response.addCookie(cookie);
return "login";
}
// login 在单独Controller
// updatePwd 更新密码
@GetMapping("/updatePwd")
public String updatePwd() {
return "admin/updatePwd";
}
@PostMapping("/updatePwd")
@ResponseBody
public Msg updatePwd(
@RequestBody Admin admin,
HttpSession httpSession) {
User user = (User) request.getAttribute("user");
adminService.updatePwdByUserName(
user.getUserName(),
admin.getPwd()
}
@ResponseBody
@GetMapping("/sources")
public Msg getSources() {
return Msg.success().add("sources", subjectService.selectSubjectSources());
}
@ResponseBody
@PostMapping("/source")
public Msg addSource(@RequestBody @Validated SubjectSource source) throws MyException {
return Msg.sqlChange((int) subjectService.insertSubjectSource(source.getSourcename()));
}
@ResponseBody
@DeleteMapping("/source")
public Msg delSource(@RequestBody SubjectSource source) throws MyException {
return Msg.sqlChange(subjectService.delSubjectSource(source.getId()));
}
@ResponseBody
@PutMapping("/source")
public Msg updateSource(@RequestBody @Validated SubjectSource source) {
return Msg.sqlChange(subjectService.updateSubjectSource(source));
Long flag = teacherService.selectAnnualAssessmentFlag(teacher.getId(), year);
if (flag == 1) {
int i = teacherService.updateAnnualAssessment(assessment);
} else {
int i = teacherService.insertAnnualAssessment(assessment);
}
return Msg.success();
}
//年度专业技术人员考核表
@PostMapping("/upload_technical_personnel")
@ResponseBody
public Msg fun16(String year, String mainAchievements, String attendance, String rewardsAndPunishments, HttpSession httpSession) {
@DeleteMapping("/student")
public Msg delStudent(
@RequestBody StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.delStudent(student, id_institute));
}
@ResponseBody
@PostMapping("/student")
public Msg addStudent(
@RequestBody @Validated(Add.class) StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.addStudent(student, id_institute));
}
@ResponseBody
@PutMapping("/student")
public Msg updateStudent(
@RequestBody @Validated({Update.class}) StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.updateStudent(student, id_institute));
}
public String showTechnicalPersonnel() {
return "teacher/showtable/technicalpersonnel";
}
@GetMapping("/show_workload")
public String showWorkLoad() {
return "teacher/showtable/workload";
}
@GetMapping("/exit")
public String exit(HttpServletResponse response) {
//将Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
response.addCookie(cookie);
return "redirect:/";
}
//打印页面
@GetMapping("/print_term_debriefing")
public String printYearDebriefing(Long year, String term, Model model) {
@ModelAttribute("id_institute")
public long getRoleInfo() {
User user = (User) request.getAttribute("user");
// LOGGER.info("USER:{}",user);
if (user != null) {
if (user.getRole().equals("admin")) {
Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
return institute.getId();
}
if (user.getRole().equals("sadmin")) {
return -1;
}
return 0;
@GetMapping("/exit")
public String exit(HttpServletResponse response) {
//将Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
response.addCookie(cookie);
return "redirect:/";
}
//打印页面
@GetMapping("/print_term_debriefing")
public String printYearDebriefing(Long year, String term, Model model) {
model.addAttribute("year", year);
model.addAttribute("term", term);
return "teacher/showtable/print/termdebriefing";
}
return Msg.success().add("sections", sectionService.getSections(id_institute));
}
@DeleteMapping("/section")
@ResponseBody
public Msg delSection(@RequestBody Section section) {
return Msg.sqlChange((int) sectionService.delSection(section));
}
@PutMapping("/section")
@ResponseBody
public Msg updateSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange((int) sectionService.updateSection(section, section.getSectionName(), id_institute));
}
@PostMapping("/section")
@ResponseBody
public Msg addSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) {
if (!targetFile.getParentFile().exists()) { //判断文件父目录是否存在
targetFile.getParentFile().mkdir();
}
file.transferTo(new File(targetFile, fileName)); // 开始接受文件
Workapprovaldata workapprovaldata = new Workapprovaldata();
workapprovaldata.setIdWorkapproval(idWork);
workapprovaldata.setNews(news);
workapprovaldata.setDatarar(saveFileName);
//flag == 0 公有 flag == 1私有
workapprovaldata.setFlag(flag);
teacherService.insertWordData(workapprovaldata);
return Msg.success();
List<Debriefing> list = teacherService.selectDebriefingTermByYear();
List<Long> temp = new ArrayList<>();
//去除重复的年份
for (Debriefing s : list) {
if (!temp.contains(s.getYear())) {
temp.add(s.getYear());
}
}
return Msg.success().add("year", temp);
}
//查询指定年份的学期述职信息
@GetMapping("/select_debriefing_term_info")
@ResponseBody
String end = sdf.format(workapproval.getEndDate());
String time = start + " - " + end;
model.addAttribute("workapproval", workapproval);
model.addAttribute("time", time);
return "teacher/workapproval/fillwdata";
}
//上传出差报告
@PostMapping("/fill_in_w")
@ResponseBody
public Msg fun7(@RequestParam("id_work") Long idWork, @RequestParam("news") String news, @RequestParam("flag") Integer flag,
@GetMapping("/wordload")
public String wordloadPage() {
return "teacher/table/workload";
}
@GetMapping("/wordloadData")
@ResponseBody
public Msg wordloadData(
@RequestParam("year") String year,
@RequestParam("trem") String trem
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
return Msg.success()
.add("teacher", teacher)
.add("workloadDTO", teacherService.getWorkload(teacher.getId(), year, trem));
}
//get学生选题的状态
@GetMapping("/SRS")
@ResponseBody
public Msg getSelectSubjected(
@ModelAttribute("id_institute") long id_institute
) {
System.out.println(subjectService.getSelectSubjected(null, id_institute));
return Msg.success().add("SRS", subjectService.getSelectSubjected(null, id_institute));
}
//get 选某个课题的所有学生
@GetMapping("/studentsBySubject")
@ResponseBody
public Msg getStuentBySubject(
@RequestParam("id") Long id,
@ModelAttribute("id_institute") long id_institute
) {
return subjectService.getStuentBySubject(id, id_institute);
}
// 教师管理 增删改查
@GetMapping("/TeacherManagement")
public String teacher() {
return "admin/BasicInfo/TeacherManagement";
@ResponseBody
@DeleteMapping("/teacher")
public Msg delTeacher(
@RequestBody TeacherWithBLOBs teacher,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) teacherService.delTeacher(teacher, id_institute));
}
@ResponseBody
@PostMapping("/teacher")
public Msg addTeacher(
@RequestBody @Validated(Add.class) TeacherWithBLOBs teacher,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) teacherService.addTeacher(teacher, id_institute));
}
@ResponseBody
@PutMapping("/teacher")
@DeleteMapping("/specialty")
public Msg delSpecialty(
@RequestBody Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.delSpecialty(specialty, id_institute));
}
@ResponseBody
@PutMapping("/specialty")
public Msg putSpecialty(
@RequestBody @Validated({Update.class}) Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.putSpecialty(specialty, id_institute));
}
@ResponseBody
@PostMapping("/specialty")
public Msg postSpecialty(
@RequestBody @Validated({Add.class}) Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.postSpecialty(specialty, id_institute));
return "teacher/showtable/yeardebriefing";
}
@GetMapping("/show_term_debriefing")
public String showTermDebriefing() {
return "teacher/showtable/termdebriefing";
}
@GetMapping("/show_annual_assessment")
public String showAnnualAssessment() {
return "teacher/showtable/annualassessment";
}
@GetMapping("/show_technical_personnel")
public String showTechnicalPersonnel() {
return "teacher/showtable/technicalpersonnel";
}
@GetMapping("/show_workload")
public String showWorkLoad() {
return "teacher/showtable/workload";
}
@GetMapping("/exit")
public String exit(HttpServletResponse response) {
//将Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
}
file.transferTo(new File(targetFile, fileName)); // 开始接受文件
Workapprovaldata workapprovaldata = new Workapprovaldata();
workapprovaldata.setIdWorkapproval(idWork);
workapprovaldata.setNews(news);
workapprovaldata.setDatarar(saveFileName);
//flag == 0 公有 flag == 1私有
workapprovaldata.setFlag(flag);
teacherService.insertWordData(workapprovaldata);
return Msg.success();
}
//查看出差报告
@GetMapping("/select_work_data")
@PostMapping("/specialty")
public Msg postSpecialty(
@RequestBody @Validated({Add.class}) Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.postSpecialty(specialty, id_institute));
}
// 班级
@GetMapping("/ClassManagement")
public String Class() {
return "admin/Department/ClassManagement";
// //获取管理员的 学院id
// public static Long getIdInstitute(ModelMap modelMap) {
file.mkdirs();
}
String fileName = file.getName();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
String encodeFilename = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
headers.setContentDispositionFormData("attachment", encodeFilename);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),
headers, HttpStatus.CREATED);
}
return null;
}
//学期述职
@PostMapping("/upload_term_debriefing")
@ResponseBody
public Msg fun9(String year, String term, String teachingTask, String scientificResearch,
String otherWork, String winAward, String summary, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingWithBLOBs debriefingWithBLOBs = new DebriefingWithBLOBs();
debriefingWithBLOBs.setIdTeacher(teacher.getId());
debriefingWithBLOBs.setYear(Long.parseLong(year));
subject.setMarchspecialty(marchspecialty);
subject.setTeachernames(teachernames);
//修改后状态置 0
subject.setSelectFlag(0);
subject.setVerifyprojectFlag(0);
subject.setReleaseFlag(0);
subjectService.updateSubjectByid(subject);
return Msg.success();
} else {
//获取课题
SubjectWithBLOBs subject1 = subjectService.getSubjectByID(id);
//获取课题路径
String oldPath = subject1.getFilepath();
File oldFile = new File(oldPath);
//如果文件存在则删除
if (oldFile.exists()) {
//删除成功
if (oldFile.delete()) {
} else {
return Msg.fail();
}
}
ServletContext servletContext = request.getSession().getServletContext();
project.setIdTeacher(teacher.getId());
project.setFilepath(saveFileName);
project.setMarchspecialty(marchspecialty.trim());
project.setTeachernames(teachernames);
project.setSelectcount(0);
project.setSelectFlag(0);
project.setVerifyprojectFlag(0);
project.setReleaseFlag(0);
int i = teacherService.insert_project(project);
return Msg.success();
}
//查看自己的课题发布记录
@GetMapping("/cxmyProject")
public String fun21(ModelMap modelMap, HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
@GetMapping("/SectionManagement")
public String section() {
return "admin/Department/SectionManagement";
}
@GetMapping("/sections")
@ResponseBody
public Msg getSections(@ModelAttribute("id_institute") long id_institute) {
return Msg.success().add("sections", sectionService.getSections(id_institute));
}
@DeleteMapping("/section")
@ResponseBody
public Msg delSection(@RequestBody Section section) {
return Msg.sqlChange((int) sectionService.delSection(section));
}
@PutMapping("/section")
@ResponseBody
public Msg updateSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange((int) sectionService.updateSection(section, section.getSectionName(), id_institute));
}
@PostMapping("/section")
@ResponseBody
public Msg addSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) {
if (oldFile.delete()) {
} else {
return Msg.fail();
}
}
ServletContext servletContext = request.getSession().getServletContext();
String uploadFileName = file.getOriginalFilename(); // 获取上传文件的原名
uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);
File path = new File(ResourceUtils.getURL("target").getPath());
// String savePath = path.getAbsolutePath() + "\\classes\\static\\model\\" + teacher.getId();
// String saveFileName = savePath + "\\" + uploadFileName;
String savePath =
path.getAbsolutePath() + File.separator+"classes+"+File.separator+"static"
+File.separator+"model"+File.separator + teacher.getId();
String saveFileName = savePath +File.separator + uploadFileName;
File dirs = new File(savePath);
//判断路径是否存在,如果不存在就创建一个
List<WorkapprovalWithBLOBs> list = teacherService.selectWorkSuccess(teacher.getId());
return Msg.success().add("workinfo", list);
}
//查询申请失败教师出差申请
@GetMapping("/select_work_failed")
@ResponseBody
public Msg fun3(HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<WorkapprovalWithBLOBs> list = teacherService.selectWorkFailed(teacher.getId());
return Msg.success().add("workinfo", list);
if (list.isEmpty()) {
return Msg.fail();
} else {
return Msg.success().add("year", list);
}
}
//查询度专业技术人员考核表信息
@GetMapping("/select_technicalpersonnel_year_info")
@ResponseBody
public Msg fun19(Long year, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = teacherService.selectTechnicalPersonnelInfo(teacher.getId(), year);
return Msg.success().add("technicalPersonnel", technicalPersonnelWithBLOBs);
}
// 毕业设计内容
// 加载上传课题页面
@GetMapping("/upload_topic_page")
public String uploadTopic(ModelMap modelMap, HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<Projecttype> projecttypes = teacherService.select_allProjecttype();
List<Projectsource> projectsources = teacherService.select_allProjectsource();
List<Specialty> specialties = teacherService.select_allSpecialty(teacher.getIdSection());
modelMap.addAttribute("projecttypes", projecttypes);
modelMap.addAttribute("projecttypes", projecttypes);
modelMap.addAttribute("projectsources", projectsources);
modelMap.addAttribute("specialties", specialties);
return "teacher/graduation/upload";
}
// 上传课题
@PostMapping("/up_project")
@ResponseBody
public Msg fun20(String projectName, Long idProjecttype, Long idProjectsource, String marchspecialty, String teachernames, @RequestParam("file") MultipartFile file, HttpServletRequest request, HttpSession httpSession) throws IOException {
if (file == null) {
return Msg.fail().add("msg","文件上传失败");
}
if(teacherService.selectProjectByName(projectName).size()>0){
System.out.println("上传失败");
return Msg.fail().add("msg","课题名已存在");
}
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
ServletContext servletContext = request.getSession().getServletContext();
String uploadFileName = file.getOriginalFilename(); // 获取上传文件的原名
System.out.println(uploadFileName);
uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);
System.out.println(uploadFileName);
File path = new File(ResourceUtils.getURL("target").getPath());
String savePath =
适用
课程设计,大作业,毕业设计,项目练习,学习演示等