基于javaweb+mysql的springboot基于遗传算法学校排课系统(java+springboot+maven+mybatis+vue+mysql+oss)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot基于遗传算法学校排课系统(java+springboot+maven+mybatis+vue+mysql+oss)
一、项目简述本系统功能包括: 排课管理,课程管理,讲师管理,班级管理,学生管理,教学资料,学习文档,在线测试,教材列表,教学设计,帮助中心等等功能。
二、项目运行 环境配置:
Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等。
private ClassInfoService classInfoService;
@Autowired
private StudentService studentService;
@Autowired
private ClassInfoDao classInfoDao;
/**
* 分页查询所有班级
* @param page
* @param limit
* @return
*/
// @GetMapping("/queryclassinfobypage/{page}")
// public ServerResponse queryClassInfo(@PathVariable(value = "page") Integer page,
// @RequestParam(defaultValue = "10") Integer limit) {
// System.out.println("*******************************************");
// Page<ClassInfo> pages = new Page<>(page, limit);
// QueryWrapper<ClassInfo> wrapper = new QueryWrapper<ClassInfo>().orderByDesc("remark");
// IPage<ClassInfo> iPage = classInfoService.page(pages, wrapper);
// return ServerResponse.ofSuccess(iPage);
// }
/**
* 根据年级查询所有班级
* @param grade
* @return
*/
@GetMapping("/class-grade/{grade}")
public ServerResponse queryClass(@PathVariable("grade") String grade) {
QueryWrapper<ClassInfo> wrapper = new QueryWrapper<ClassInfo>().eq("remark", grade);
List<ClassInfo> classInfoList = classInfoService.list(wrapper);
return ServerResponse.ofSuccess(classInfoList);
}
/**
* 根据班级查询学生
* @param page
* @param classNo
* @param limit
* @return
*/
@GetMapping("/student-class/{page}/{classNo}")
public ServerResponse queryStudentByClass(@PathVariable("page") Integer page,
@PathVariable("classNo") String classNo,
@RequestParam(defaultValue = "10") Integer limit) {
QueryWrapper<Student> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("student_no");
@Autowired
private ClassInfoService classInfoService;
@Autowired
private ClassTaskService classTaskService;
@Autowired
private TeachbuildInfoService teachbuildInfoService;
@Autowired
private DocService docService;
@Autowired
private ExerciseService exerciseService;
@Autowired
private ClassroomService classroomService;
@Autowired
private StudentDao studentDao;
@Autowired
private OnlineCourseService onlineCourseService;
@Autowired
private TeacherDao teacherDao;
@GetMapping("/systemdata")
public ServerResponse systemData() {
Map<String, Object> map = new HashMap<>();
// 讲师人数
int teachers = teacherService.count();
// 学生人数
int students = studentService.count();
// 教材数量
int courses = courseInfoService.count();
// 班级数量
int classes = classInfoService.count();
// 教学楼数量
int teachbuilds = teachbuildInfoService.count();
// 教室数量
int classrooms = classroomService.count();
// 当前课程任务数量
int classtasks = classTaskService.count();
// 学习文档数
int docs = docService.count();
// 题库数量
int exercises = exerciseService.count();
// 网课数量
int onlineCourse = onlineCourseService.count();
/**
* 查询班级信息带详细信息
* @return
*/
@GetMapping("/queryclassinfo/{page}")
public ServerResponse queryClassInfos(@PathVariable("page") Integer page, @RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "") String gradeNo) {
System.out.println("gradeNo = " + gradeNo);
Map<String, Object> map = new HashMap();
List<ClassInfoVO> classInfoVOS = null;
if (gradeNo.equals("")) {
classInfoVOS = classInfoDao.queryClassInfos((page - 1) * limit, limit);
int total = classInfoDao.count2();
map.put("records", classInfoVOS);
map.put("total", total);
} else {
classInfoVOS = classInfoDao.queryClassInfo((page - 1) * limit, limit, gradeNo);
int total = classInfoDao.count1(gradeNo);
map.put("records", classInfoVOS);
map.put("total", total);
}
return ServerResponse.ofSuccess(map);
}
// TODO 编辑班级
// TODO 删除班级
/**
* 添加班级
* @param classAddVO
* @return
*/
@PostMapping("/addclassinfo")
public ServerResponse addClass(@RequestBody ClassAddVO classAddVO) {
System.out.println(classAddVO);
ClassInfo c = new ClassInfo();
c.setRemark(classAddVO.getGradeNo());
c.setClassNo(classAddVO.getClassNo());
c.setClassName(classAddVO.getClassName());
c.setTeacher(classAddVO.getId());
c.setNum(classAddVO.getNum());
boolean b = classInfoService.save(c);
if (b) {
return ServerResponse.ofSuccess("添加班级成功");
}
return ServerResponse.ofError("添加班级失败");
}
/**
* 查询每个班级的学生人数000000000000000000000000000000000000000000000000000000000000000000000000000000出大问题
* @return
*/
return ServerResponse.ofSuccess(teacherService.list());
}
}
/**
* 班级信息
*/
@RestController
public class ClassInfoController {
@Autowired
private ClassInfoService classInfoService;
@Autowired
private StudentService studentService;
@Autowired
private ClassInfoDao classInfoDao;
/**
* 分页查询所有班级
* @param page
* @param limit
* @return
*/
// @GetMapping("/queryclassinfobypage/{page}")
// public ServerResponse queryClassInfo(@PathVariable(value = "page") Integer page,
return ServerResponse.ofSuccess(classroomService.getById(id));
}
/**
* 更新教室
* @param classroom
* @return
*/
@PostMapping("/modify")
public ServerResponse modifyClassroom(@RequestBody Classroom classroom) {
return classroomService.updateById(classroom) ? ServerResponse.ofSuccess("更新成功") : ServerResponse.ofError("更新失败");
}
}
/**
* 网课名称,每一个网课下面有1到多个视频
*/
@RestController
@RequestMapping("/onlinecourse")
public class OnlineCourseController {
@Autowired
private OnlineCourseService ocs;
}
return ServerResponse.ofSuccess(map);
}
// TODO 编辑班级
// TODO 删除班级
/**
* 添加班级
* @param classAddVO
* @return
*/
@PostMapping("/addclassinfo")
public ServerResponse addClass(@RequestBody ClassAddVO classAddVO) {
System.out.println(classAddVO);
ClassInfo c = new ClassInfo();
c.setRemark(classAddVO.getGradeNo());
c.setClassNo(classAddVO.getClassNo());
c.setClassName(classAddVO.getClassName());
c.setTeacher(classAddVO.getId());
c.setNum(classAddVO.getNum());
boolean b = classInfoService.save(c);
if (b) {
return ServerResponse.ofSuccess("添加班级成功");
}
return ServerResponse.ofError("添加班级失败");
}
/**
* 查询每个班级的学生人数000000000000000000000000000000000000000000000000000000000000000000000000000000出大问题
* @return
*/
// @GetMapping("/studentnums")
// public ServerResponse queryStudentNumByClass() {
// // 先获得所有的班级编号
// QueryWrapper<ClassInfo> wrapper = new QueryWrapper();
// QueryWrapper wrapper2 = new QueryWrapper();
//
// int nums = 0;
// List<ClassInfo> classList = classInfoService.list();
// // 循环查每个班级的人数
// for (ClassInfo classInfo : classList) {
// wrapper2.eq("class_no", classInfo.getClassNo());
/**
*/
@RestController
public class LocationInfoController {
@Autowired
private LocationInfoService lis;
@Autowired
private LocationInfoDao lid;
/**
* 新增教学区域
* @return
*/
@PostMapping("/setteacharea")
public ServerResponse setTeachArea(@RequestBody() LocationSetVO l) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("teachbuild_no", l.getTeachBuildNo());
wrapper.eq("grade_no", l.getGradeNo());
LocationInfo locationInfo = new LocationInfo();
if (lis.getOne(wrapper) != null) {
return ServerResponse.ofError("该教学区域已经设置过了!");
}
locationInfo.setTeachbuildNo(l.getTeachBuildNo());
locationInfo.setGradeNo(l.getGradeNo());
boolean b = lis.save(locationInfo);
if (b) {
return ServerResponse.ofSuccess("设置教学区域成功");
}
return ServerResponse.ofError("设置教学区域失败");
}
/**
* 查询所有的教学区域安排信息
* @return
*/
@GetMapping("/locations/{page}")
public ServerResponse queryLocationInfo(@PathVariable("page") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
Map<String, Object> map = new HashMap<>();
return ServerResponse.ofSuccess("删除网课成功");
}
return ServerResponse.ofError("删除网课失败");
}
/**
* 自动获取网课编号
* @return
*/
private String getCourseNo() {
QueryWrapper wrapper = new QueryWrapper();
wrapper.select("online_no").orderByDesc("online_no");
List<OnlineCourse> list = ocs.list(wrapper);
String no = String.valueOf(Integer.parseInt(list.get(0).getOnlineNo() + 1));
return no;
}
}
/**
* @Descripe: 文件上传,读取文件
*/
@RestController
public class UploadController {
private Logger log = LoggerFactory.getLogger(UploadController.class);
/**
* 排课算法接口,传入学期开始去查对应学期的开课任务,进行排课,排完课程后添加到course_plan表
*
* @param semester
* @return
*/
@PostMapping("/arrange/{semester}")
public ServerResponse arrange(@PathVariable("semester") String semester) {
return classTaskService.classScheduling(semester);
}
}
/**
* description: 教材信息
*/
@RestController
@RequestMapping("/courseinfo")
public class CourseInfoController {
@Autowired
private CourseInfoService cis;
/**
* 分页查询所有的教材信息
* @param page
* @param limit
* @return
*/
@PathVariable("semester") String semester,
@RequestParam(defaultValue = "10") Integer limit) {
Page<ClassTask> pages = new Page<>(page, limit);
QueryWrapper<ClassTask> wrapper = new QueryWrapper<ClassTask>().eq("semester", semester);
IPage<ClassTask> ipage = classTaskService.page(pages, wrapper);
if (ipage != null) {
return ServerResponse.ofSuccess(ipage);
}
return ServerResponse.ofError("查询开课任务失败!");
}
/**
* 手动添加课程任务
*
* @param c
* @return
*/
@PostMapping("/addclasstask")
public ServerResponse addClassTask(@RequestBody() ClassTaskDTO c) {
System.out.println(c);
ClassTask classTask = new ClassTask();
classTask.setSemester(c.getSemester());
classTask.setGradeNo(c.getGradeNo());
classTask.setClassNo(c.getClassNo());
classTask.setCourseNo(c.getCourseNo());
classTask.setCourseName(c.getCourseName());
classTask.setTeacherNo(c.getTeacherNo());
classTask.setRealname(c.getRealname());
classTask.setCourseAttr(c.getCourseAttr());
classTask.setStudentNum(c.getStudentNum());
classTask.setWeeksNumber(c.getWeeksNumber());
classTask.setWeeksSum(c.getWeeksSum());
classTask.setIsFix(c.getIsFix());
classTask.setClassTime(c.getClassTime());
boolean b = classTaskService.save(classTask);
if (b) {
return ServerResponse.ofSuccess("添加课程任务成功");
}
return ServerResponse.ofError("添加课程任务失败");
}
/**
* 删除开课任务
@PostMapping("/uploaddocs")
public ServerResponse uploadDocs(MultipartFile file) {
return docService.uploadDocs(file);
}
/**
* 添加文档的相关描述信息
* @param docsVO
* @return
*/
@PostMapping("/adddocs")
public ServerResponse addDocs(@RequestBody DocsVO docsVO) {
return docService.addDcos(docsVO);
}
/**
* 下载文档
* @param id
* @return
*/
@GetMapping(value = "/downloaddocs", consumes = MediaType.ALL_VALUE)
public ServerResponse downloadDocs(Integer id) {
return docService.downloadDocs(id);
}
/**
* 分页查询所有的文档
* @param page
* @param limit
* @return
*/
@GetMapping("/docs/{page}")
public ServerResponse allDocs(@PathVariable("page") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
Page<Doc> pages = new Page<>(page, limit);
QueryWrapper<Doc> wrapper = new QueryWrapper<Doc>().orderByDesc("create_time");
IPage<Doc> iPage = docService.page(pages, wrapper);
return ServerResponse.ofSuccess(iPage);
}
/**
* 根据班级查询文档,用于学生端
* @param page
* @param toClassNo
* @param limit
* @return
*/
@GetMapping("/docs-class/{page}/{toClassNo}")
public ServerResponse getDocsByClass(@PathVariable("page") Integer page, @PathVariable("toClassNo") String toClassNo,
@RequestParam(defaultValue = "10") Integer limit) {
/**
*/
@RestController
public class DocController {
@Autowired
private DocService docService;
/**
* 上传DOC文档,只负责上传并返回文件的url
* @param file
* @return
*/
@PostMapping("/uploaddocs")
public ServerResponse uploadDocs(MultipartFile file) {
return docService.uploadDocs(file);
}
/**
* 添加文档的相关描述信息
* @param docsVO
* @return
*/
@PostMapping("/adddocs")
public ServerResponse addDocs(@RequestBody DocsVO docsVO) {
return docService.addDcos(docsVO);
}
/**
* 下载文档
* @param id
* @return
*/
@GetMapping(value = "/downloaddocs", consumes = MediaType.ALL_VALUE)
return ServerResponse.ofSuccess(no);
}
}
/**
*/
@RestController
public class ExerciseController {
@Autowired
private ExerciseService es;
/**
* 根据类别查询题目
* @param id
* @param page
* @param limit
* @return
*/
@GetMapping("/exercise/{categoryid}/{page}")
public ServerResponse queryExercise(@PathVariable("categoryid") Integer id,
@PathVariable("page") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
QueryWrapper wrapper = new QueryWrapper();
Page pages = new Page(page, limit);
wrapper.orderByDesc("update_time");
wrapper.eq("category_id", id);
IPage<Exercise> iPage = es.page(pages, wrapper);
return ServerResponse.ofSuccess(iPage);
* @param id 学生id
* @param classNo 班级编号
* @return
*/
@PostMapping("/join/{id}/{classNo}")
public ServerResponse joinClass(@PathVariable("id") Integer id, @PathVariable("classNo") String classNo) {
// TODO 学生加入年级,学生查看本班的文档(文档控制器中),查看自己所在的班级课表
Student student = studentService.getById(id);
student.setClassNo(classNo);
boolean b = studentService.saveOrUpdate(student);
if (b) {
return ServerResponse.ofSuccess("加入班级成功");
}
return ServerResponse.ofError("加入班级失败");
}
/**
* 学生登录
* @param studentLoginRequest
* @return
*/
@PostMapping("/login")
public ServerResponse studentLogin(@RequestBody StudentLoginRequest studentLoginRequest) {
Map<String, Object> map = new HashMap<>();
// 先判断是否有该学号,该学生
QueryWrapper<Student> wrapper = new QueryWrapper<Student>().eq("student_no", studentLoginRequest.getUsername());
// 查询是否有该学生
Student student2 = studentService.getOne(wrapper);
if (student2 == null) {
return ServerResponse.ofError("学生账号不存在!");
}else if (student2.getStatus() != 0) {
// 否则进行下一步验证账号的的状态
return ServerResponse.ofError("该学生账号异常,请联系管理员");
}
// 调用登录
Student student = studentService.studentLogin(studentLoginRequest.getUsername(), studentLoginRequest.getPassword());
if (student != null) {
//允许登录,返回token
String token = tokenService.getToken(student);
map.put("student", student);
map.put("token", token);
return ServerResponse.ofSuccess(map);
}
return ServerResponse.ofSuccess("密码错误!");
}
/**
* 学生注册
* @param stu
* @return
*/
/**
*/
@RestController
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@Autowired
private TokenService tokenService;
/**
* 上传讲师证件
* @param id
* @param file
* @return
*/
@PostMapping("/upload/{id}")
public ServerResponse uploadLicense(@PathVariable("id") Integer id, MultipartFile file) {
Map<String, Object> map = AliyunUtil.upload(file, "license");
String license = (String) map.get("url");
Teacher t = teacherService.getById(id);
t.setLicense(license);
boolean b = teacherService.updateById(t);
if (b) {
return ServerResponse.ofSuccess("上传证件成功");
}
return ServerResponse.ofError("上传证件失败");
}
/**
* 讲师登录
* @param userLoginRequest
* @return
*/
@PostMapping("/login")
public ServerResponse teacherLogin(@RequestBody UserLoginRequest userLoginRequest) {
Map<String, Object> map = new HashMap<>();
QueryWrapper<Teacher> wrapper = new QueryWrapper<>();
wrapper.eq("teacher_no", userLoginRequest.getUsername());
// 先查询是否有该账号
if (ipage != null) {
return ServerResponse.ofSuccess(ipage);
}
return ServerResponse.ofError("查询开课任务失败!");
}
/**
* 手动添加课程任务
*
* @param c
* @return
*/
@PostMapping("/addclasstask")
public ServerResponse addClassTask(@RequestBody() ClassTaskDTO c) {
System.out.println(c);
ClassTask classTask = new ClassTask();
classTask.setSemester(c.getSemester());
classTask.setGradeNo(c.getGradeNo());
classTask.setClassNo(c.getClassNo());
classTask.setCourseNo(c.getCourseNo());
classTask.setCourseName(c.getCourseName());
classTask.setTeacherNo(c.getTeacherNo());
classTask.setRealname(c.getRealname());
classTask.setCourseAttr(c.getCourseAttr());
classTask.setStudentNum(c.getStudentNum());
classTask.setWeeksNumber(c.getWeeksNumber());
classTask.setWeeksSum(c.getWeeksSum());
classTask.setIsFix(c.getIsFix());
classTask.setClassTime(c.getClassTime());
boolean b = classTaskService.save(classTask);
if (b) {
return ServerResponse.ofSuccess("添加课程任务成功");
}
return ServerResponse.ofError("添加课程任务失败");
}
/**
public ServerResponse getTeacherNo() {
List<Teacher> teacherList = teacherService.list(new QueryWrapper<Teacher>().select().orderByDesc("teacher_no"));
// 返回最大编号的讲师编号再+1给新添加的讲师
return ServerResponse.ofSuccess(teacherList.get(0).getTeacherNo());
}
/**
* 管理员添加讲师,默认密码是123456
* @param t
* @return
*/
@PostMapping("/add")
public ServerResponse addTeacher(@RequestBody TeacherAddRequest t) {
Teacher teacher = new Teacher();
teacher.setTeacherNo(t.getTeacherNo());
teacher.setUsername(t.getUsername());
teacher.setEmail(t.getEmail());
// 每一个新增的讲师密码默认是123456
teacher.setPassword("123456");
teacher.setRealname(t.getRealname());
teacher.setJobtitle(t.getJobtitle());
teacher.setTeach(t.getTeach());
teacher.setTelephone(t.getTelephone());
teacher.setAddress(t.getAddress());
teacher.setAge(t.getAge());
boolean b = teacherService.save(teacher);
if (b) {
return ServerResponse.ofSuccess("添加讲师成功!");
}
return ServerResponse.ofError("添加讲师失败!");
}
/**
* 根据ID封禁、解封讲师账号,状态为0时正常,1时封禁
* @param id
* @return
*/
@GetMapping("/lock/{id}")
public ServerResponse lockTeacher(@PathVariable("id") Integer id) {
// 先查出来再修改,
Teacher teacher = teacherService.getById(id);
// 修改
if (teacher.getStatus() == 0) {
teacher.setStatus(1);
} else {