学生学籍管理系统使用了B/S架构,编程语言为Java语言,项目的框架为SSM框架,Layui前端框架完成前后端的交互;数据库为MySQL5.0。
部分代码展示
@Controller
@RequestMapping("/student")
public class StudentController {
private static final String LIST = "student/list";
private static final String ADD = "student/add";
private static final String UPDATE = "student/update";
@Autowired
private StudentService studentService;
@Autowired
private SubjectService subjectService;
@Autowired
private ClazzService clazzService;
@GetMapping("/add")
public String create(ModelMap modelMap){
List<Subject> subjects = subjectService.query(null);
modelMap.addAttribute("subjects",subjects);
return ADD;
}
@PostMapping("/create")
@ResponseBody
public Map<String,Object> create(@RequestBody Student student, HttpServletRequest request){
// student.setStatus(Student.StatusType.type_1);
// int result = studentService.create(student);
// if(result<=0 ){
// return MapControll.getInstance().error().getMap();
// }
// return MapControll.getInstance().success().getMap();
String s = student.getStuNo();
String p= student.getStuPwd();
System.out.println("====================================="+s);
Integer s1 = studentService.querystuNo(s);
String regex="\\d{10}";
Pattern pattern = Pattern.compile(regex);
boolean matches = pattern.matcher(s).matches();
if(matches==false){
return MapControll.getInstance().error("学号格式不对").getMap();
}
if(p.length()>=12){
return MapControll.getInstance().error("密码长度过长").getMap();
}
if(p.length()<6){
return MapControll.getInstance().error("密码长度过短").getMap();
}
if (s1==null) {
student.setStatus(Student.StatusType.type_1);
int result = studentService.create(student);
if (result <= 0) {
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}else {
System.out.println("==============================学号重复");//2022.3.3:学号重复BUG已解决。lbs
return MapControll.getInstance().error("学号重复,请重新注册").getMap();
}
}
@PostMapping("/delete/{id}")
@ResponseBody
public Map<String,Object> delete(@PathVariable("id") Integer id){
int result = studentService.delete(id);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@PostMapping("/delete")
@ResponseBody
public Map<String,Object> delete(String ids){
int result = studentService.delete(ids);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@PostMapping("/update")
@ResponseBody
public Map<String,Object> update(@RequestBody Student student){
int result = studentService.update(student);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@GetMapping("/detail/{id}")
public String detail(@PathVariable("id") Integer id, ModelMap modelMap){
Student student = studentService.detail(id);
List<Subject> subjects = subjectService.query(null);
modelMap.addAttribute("student",student);
modelMap.addAttribute("subjects",subjects);
return UPDATE;
}
@PostMapping("/query")
@ResponseBody
public Map<String,Object> query(@RequestBody Student student ){
List<Student> list = studentService.query(student);
List<Subject> subjects = subjectService.query(null);
List<Clazz> clazzes = clazzService.query(null);
//设置关联关系
list.forEach(entity->{
subjects.forEach(subject -> {
if(subject.getId() == entity.getSubjectId()){
entity.setSubject(subject);
}
});
clazzes.forEach(clazz -> {
if(clazz.getId() == entity.getClazzId()){
entity.setClazz(clazz);
}
});
});
Integer count = studentService.count(student);
return MapControll.getInstance().success().page(list,count).getMap();
}
@GetMapping("/list")
public String list(){
return LIST;
}
@GetMapping("/info")
public String info(HttpSession session,ModelMap modelMap){
//获取Student
Student param = (Student) session.getAttribute("user");
Student student = studentService.detail(param.getId());
modelMap.put("student",student);
return "student/info";
}
@GetMapping("/teacher_student")
public String teacher_student(HttpSession session,ModelMap modelMap){
Teacher teacher = (Teacher) session.getAttribute("user");
List<Clazz> clazzes = clazzService.query(null);
List<Subject> subjects = subjectService.query(null);
modelMap.addAttribute("clazzes",clazzes);
modelMap.addAttribute("subjects",subjects);
modelMap.addAttribute("teacherId",teacher.getId());
return "student/teacher_student";
}
@PostMapping("/teacher_student")
@ResponseBody
public Map<String,Object> teacher_student(Integer teacherId,Integer clazzId,Integer subjectId){
List<Student> students = studentService.queryStudentByTeacher(teacherId, clazzId, subjectId);
List<Subject> subjects = subjectService.query(null);
List<Clazz> clazzes = clazzService.query(null);
//设置关联关系
students.forEach(entity->{
subjects.forEach(subject -> {
if(subject.getId() == entity.getSubjectId()){
entity.setSubject(subject);
}
});
clazzes.forEach(clazz -> {
if(clazz.getId() == entity.getClazzId()){
entity.setClazz(clazz);
}
});
});
return MapControll.getInstance().success().add("data",students).getMap();
}
```java
package com.yanzhen.controller;
@Controller
@RequestMapping("/teacher")
public class TeacherController {
private static final String LIST = "teacher/list";
private static final String ADD = "teacher/add";
private static final String UPDATE = "teacher/update";
@Autowired
private TeacherService teacherService;
@Autowired
private SubjectService subjectService;
@Autowired
private ClazzService clazzService;
@GetMapping("/add")
public String create(ModelMap modelMap){
return ADD;
}
@PostMapping("/create")
@ResponseBody
public Map<String,Object> create(@RequestBody Teacher teacher){
int result = teacherService.create(teacher);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@PostMapping("/delete/{id}")
@ResponseBody
public Map<String,Object> delete(@PathVariable("id") Integer id){
int result = teacherService.delete(id);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@PostMapping("/delete")
@ResponseBody
public Map<String,Object> delete(String ids){
int result = teacherService.delete(ids);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@PostMapping("/update")
@ResponseBody
public Map<String,Object> update(@RequestBody Teacher teacher){
int result = teacherService.update(teacher);
if(result<=0){
return MapControll.getInstance().error().getMap();
}
return MapControll.getInstance().success().getMap();
}
@GetMapping("/detail/{id}")
public String detail(@PathVariable("id") Integer id, ModelMap modelMap){
Teacher teacher = teacherService.detail(id);
modelMap.addAttribute("teacher",teacher);
return UPDATE;
}
@PostMapping("/query")
@ResponseBody
public Map<String,Object> query(@RequestBody Teacher teacher){
List<Teacher> list = teacherService.query(teacher);
Integer count = teacherService.count(teacher);
return MapControll.getInstance().success().page(list,count).getMap();
}
@GetMapping("/list")
public String list(){
return LIST;
}
}
}
---------------------------------源码教程放到下方了,自取-------------------------------
添加链接描述
https://download.csdn.net/download/u013574207/85414640