文章目录
选课管理系统
一、项目演示
选课管理系统
二、项目介绍
基于springboot+vue的前后端分离选课管理系统
系统角色:管理员、教师、学生
1、管理员:首页、院系管理、专业管理、班级管理、课程管理、选课管理、学生管理、教师管理、管理员管理
2、教师:首页、授课查询、教师课衷、成绩录入
3、学生:首页、选课、已选课程管理、课表查询、成绩查询、信息维护
语言:java
前端技术:Vue、ElementUI
后端技术:SpringBoot、Mybatis-Plus
数据库:MySQL
三、系统部分功能截图
四、部分代码展示
java
package com.rabbiter.cm.dao;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.cm.dao.mapper.CourseMapper;
import com.rabbiter.cm.model.bo.CourseItemBO;
import com.rabbiter.cm.model.bo.StudentCourseSelectItemBO;
import com.rabbiter.cm.model.entity.CourseEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class CourseDAO extends BaseDAO {
public static final int PAGE_SIZE = 20;
private final CourseMapper mapper;
public CourseDAO(CourseMapper mapper) {
this.mapper = mapper;
}
public int insert(CourseEntity entity) {
return mapper.insert(entity);
}
public int delete(Integer id) {
return mapper.deleteById(id);
}
public CourseEntity get(Integer id) {
return mapper.selectById(id);
}
public int update(CourseEntity entity) {
return mapper.updateById(entity);
}
public int count(String departmentName, String teacherName, String name) {
return mapper.count(departmentName, teacherName, name);
}
public List<CourseItemBO> getPage(Integer index, String departmentName, String teacherName, String name) {
Page<CourseItemBO> page = new Page<>(index, PAGE_SIZE);
return mapper.getPage(page, departmentName, teacherName, name).getRecords();
}
public Integer countByTeacherId(Integer teacherId) {
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CourseEntity::getTeacherId, teacherId);
return mapper.selectCount(wrapper);
}
public List<CourseEntity> listName() {
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CourseEntity::getId, CourseEntity::getName);
return mapper.selectList(wrapper);
}
public int increaseSelectedCount(Integer courseId) {
CourseEntity course = mapper.selectById(courseId);
course.setSelectedCount(course.getSelectedCount() + 1);
return mapper.updateById(course);
}
public int decreaseSelectedCount(Integer courseId) {
CourseEntity course = mapper.selectById(courseId);
course.setSelectedCount(course.getSelectedCount() - 1);
return mapper.updateById(course);
}
public Integer countStudentCanSelect(Integer studentId, Integer departmentId, Integer grade, String courseName, String teacherName) {
return mapper.countStudentCanSelect(studentId, departmentId, grade, courseName, teacherName);
}
public List<StudentCourseSelectItemBO> getStudentCanSelectPage(Integer index, Integer departmentId, Integer studentId, Integer grade, String courseName, String teacherName) {
Page<StudentCourseSelectItemBO> page = new Page<>(index, PAGE_SIZE);
return mapper.getStudentCanSelectPage(page, departmentId, studentId, grade, courseName, teacherName).getRecords();
}
public Integer getDepartmentIdById(Integer courseId) {
return mapper.getDepartmentIdById(courseId);
}
}
java
package com.rabbiter.cm.dao;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.cm.dao.mapper.StudentCourseMapper;
import com.rabbiter.cm.model.entity.StudentCourseEntity;
import com.rabbiter.cm.model.vo.response.table.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class StudentCourseDAO extends BaseDAO {
public static final int PAGE_SIZE = 20;
private final StudentCourseMapper mapper;
public StudentCourseDAO(StudentCourseMapper mapper) {
this.mapper = mapper;
}
public int insert(StudentCourseEntity entity) {
return mapper.insert(entity);
}
public int delete(Integer id) {
return mapper.deleteById(id);
}
public StudentCourseEntity get(Integer id) {
return mapper.selectById(id);
}
public int update(StudentCourseEntity entity) {
return mapper.updateById(entity);
}
public int count(String className, String courseName, String studentName) {
return mapper.count(className, courseName, studentName);
}
public List<StudentCourseItemVO> getPage(Integer index, String className, String courseName, String studentName) {
Page<StudentCourseItemVO> page = new Page<>(index, PAGE_SIZE);
return mapper.getPage(page, className, courseName, studentName).getRecords();
}
public int countByCourseId(Integer courseId) {
LambdaQueryWrapper<StudentCourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StudentCourseEntity::getCourseId, courseId);
return mapper.selectCount(wrapper);
}
public int countByStudentId(Integer studentId) {
LambdaQueryWrapper<StudentCourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StudentCourseEntity::getStudentId, studentId);
return mapper.selectCount(wrapper);
}
public StudentCourseEntity getByCourseIdAndStudentId(Integer courseId, Integer studentId) {
LambdaQueryWrapper<StudentCourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.select(StudentCourseEntity::getId)
.eq(StudentCourseEntity::getCourseId, courseId)
.eq(StudentCourseEntity::getStudentId, studentId);
return mapper.selectOne(wrapper);
}
public List<StudentCourseSelectedItemVO> listStudentCourseSelected(Integer studentId) {
return mapper.listStudentCourseSelected(studentId);
}
public List<StudentExamItemVO> listStudentExam(Integer studentId) {
return mapper.listStudentExam(studentId);
}
public Integer countStudentCourseSelectedByTimePart(Integer studentId, String timePart) {
return mapper.countStudentCourseSelectedByTimePart(studentId, timePart);
}
public List<TimetableItemVO> listStudentTimetable(Integer studentId) {
return mapper.listStudentTimetable(studentId);
}
public Integer countTeacherGrade(Integer teacherId, String courseName, String studentName) {
return mapper.countTeacherGrade(teacherId, courseName, studentName);
}
public List<TeacherGradeItemVO> getTeacherGradePage(Integer index, Integer teacherId, String courseName, String studentName) {
Page<TeacherGradeItemVO> page = new Page<>(index, PAGE_SIZE);
return mapper.getTeacherGradePage(page, teacherId, courseName, studentName).getRecords();
}
}
java
package com.rabbiter.cm.service.admin;
import com.rabbiter.cm.manager.admin.StudentCourseManager;
import com.rabbiter.cm.service.BaseService;
import com.rabbiter.cm.model.entity.CourseEntity;
import com.rabbiter.cm.model.entity.StudentCourseEntity;
import com.rabbiter.cm.model.vo.response.ResultVO;
import org.springframework.stereotype.Service;
@Service
public class StudentCourseService extends BaseService {
private final StudentCourseManager manager;
public StudentCourseService(StudentCourseManager manager) {
this.manager = manager;
}
public ResultVO getPageCount(String className, String courseName, String studentName) {
return result(manager.getPageCount(className, courseName, studentName));
}
public ResultVO getPage(Integer index, String className, String courseName, String studentName) {
return result(manager.getPage(index, className, courseName, studentName));
}
public ResultVO get(Integer id) {
StudentCourseEntity entity = manager.get(id);
if (entity == null) {
return failedResult("学生选课Id: " + id + "不存在!");
}
return result(entity);
}
public ResultVO update(StudentCourseEntity entity) {
StudentCourseEntity originEntity = manager.get(entity.getId());
if (originEntity == null) {
return failedResult("学生选课Id: " + entity.getId() + "不存在!");
}
if (!originEntity.getCourseId().equals(entity.getCourseId())) {
return failedResult("课程Id被篡改");
}
if (!originEntity.getStudentId().equals(entity.getStudentId())) {
return failedResult("学生Id被篡改");
}
manager.update(entity);
return result("更新成功");
}
public ResultVO delete(Integer id) {
StudentCourseEntity entity = manager.get(id);
if (entity == null) {
return failedResult("学生选课Id: " + id + "不存在!");
}
manager.delete(entity);
return result("删除成功");
}
public ResultVO create(StudentCourseEntity entity) {
if (manager.get(entity.getId()) != null) {
return failedResult("学生选课Id: " + entity.getId() + "已存在!");
}
if (manager.getStudentById(entity.getStudentId()) == null) {
return failedResult("所属学生Id: " + entity.getStudentId() + "不存在!");
}
if (manager.getByCourseIdAndStudentId(entity.getCourseId(), entity.getStudentId()) != null) {
return failedResult("学生已经选修此课程");
}
CourseEntity course = manager.getCourseById(entity.getCourseId());
if (course == null) {
return failedResult("所属课程Id: " + entity.getCourseId() + "不存在!");
}
if (course.getSelectedCount() >= course.getMaxSize()) {
return failedResult("课容量已满");
}
if (!manager.inSameDepartment(entity.getCourseId(), entity.getStudentId())) {
return failedResult("课程与学生不在同一教学系");
}
if (!course.getGrade().equals(manager.getStudentGradeById(entity.getStudentId()))) {
return failedResult("课程与学生不在同一年级");
}
manager.create(entity);
return result("添加成功");
}
}
五、底部获取项目(9.9¥)
有问题,或者需要协助调试运行项目的也可以