基于javaweb+mysql的springboot在线考试系统(单选,多选,判断,填空,简答题)(java+springboot+ssm+mysql+html+maven)

基于javaweb+mysql的springboot在线考试系统(单选,多选,判断,填空,简答题)(java+springboot+ssm+mysql+html+maven)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

有三种角色:老师、学生、管理员

基于javaweb+mysql的SpringBoot在线考试系统(单选,多选,判断,填空,简答题)(java+springboot+ssm+mysql+html+maven)

功能:

学生信息 班级 专业 学号 姓名 在线考试 成绩查询 个人信息 密码修改 教师管理 教师编号 姓名 所教科目 题库管理 单选题 多选题 填空题 判断题,简答题(人工阅卷) 试卷管理 新建试卷 在试库中选择试题 试卷设置 发布试卷 考试管理 发布考试计划 学生考试 自动阅卷 人工阅卷 个人信息 密码修改 管理员 学生管理 教师管理 管理员管理 院系管理 班级管理 个人信息 密码修改。

public class StudentExamRecordController {

    @Resource(name = "studentExamRecordService")
    private IStudentExamRecordService studentExamRecordService;

    /**学生 查询考试信息列表*/
    @RequestMapping(value = "/studentexamrecord/qryExamPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> qryExamPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        param.put("student_id", SessionContext.get("student_id"));
        param.put("now_time", DateUtils.parseDateToStr(new Date(), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS));
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        param.put("state",list);
        return studentExamRecordService.qryPage(param, pageNo, pageSize);
    }

    /**学生 查询考试成绩列表*/
    @RequestMapping(value = "/studentexamrecord/qryScorePage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> qryScorePage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        param.put("student_id", SessionContext.get("student_id"));
        List<Integer> list = new ArrayList<>();
        list.add(4);
        list.add(5);
        param.put("state",list);
        return studentExamRecordService.qryPage(param, pageNo, pageSize);
    }

    /**学生 打开试卷*/
    @RequestMapping(value = "/studentexamrecord/openexam", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> openexam(HttpRequest request) {
        return studentExamRecordService.openexam(request.getInteger("exam_id"), request.getString("student_id"));
    }

    /**学生 更新考试用时时间*/
    @RequestMapping(value = "/studentexamrecord/updateTime", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> updateTime(HttpRequest request) {
        return studentExamRecordService.updateTime(request.getInteger("exam_id"), request.getString("student_id"));
     */
    @RequestMapping(value = "/admin/academicsmanage/{url_id}")
    public String academicsmanage(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "admin/academicsmanage/academicsmanage";
    }

}

/**
 * 学生 相关界面
 */
@Controller
public class StudentHtmlController {

    @Resource(name = "studentService")
    private IStudentService studentService;

    /**
     * 学生界面 student/student.html
     */
    @RequestMapping(value = "/student/student/{url_id}")
    public String student(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "student/student";
    }

    /**
     * 学生界面 首页
     */
    @RequestMapping(value = "/student/index/{url_id}")
    public String index(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {

@RestController
public class ImageController {

    @Resource(name = "imageService")
    private IImageService imageService;

    /**
     * 根据图片标识查询图片
     */
    @RequestMapping(value = "/image/image/{image_id}.png", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public void qryImage(@PathVariable(value = "image_id") String imageId, HttpServletResponse response) {
        try {
            ServletOutputStream out = response.getOutputStream();
            response.setContentType("image/png");
            if ("default_image".equals(imageId)) {
                out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.default_image)));
            } else if ("student_image".equals(imageId)) {
                out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.student_image)));
            } else if ("teacher_image".equals(imageId)) {
                out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.teacher_image)));
            } else if ("admin_image".equals(imageId)) {
                out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.admin_image)));
            } else {
                Image image = imageService.qryByImageId(imageId);

                if (image != null) {
                    if (image.getImage() != null) {
                        out.write(image.getImage());
                    } else {
                        out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.student_image)));
                    }
                } else {
                    out.write(Objects.requireNonNull(ImageUtil.stringToBytes(Image.default_image)));
                }
            }
     * 教师界面 teacher/teacher.html
     */
    @RequestMapping(value = "/teacher/teacher/{url_id}")
    public String teacher(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/teacher";
    }

    /**
     * 教师 首页
     */
    @RequestMapping(value = "/teacher/index/{url_id}")
    public String index(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/index";
    }

    /**
     * 教师 题库管理
     */
    @RequestMapping(value = "/teacher/questionmanage/{url_id}")
    public String questionmanage(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/questionmanage/questionmanage";
    }

    /**
     * 教师 试卷管理
     */
    @RequestMapping(value = "/teacher/testpapermanage/{url_id}")
    public String testpapermanage(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/testpapermanage/testpapermanage";
    }

    /**
     * 教师 试卷编辑
     */
    @RequestMapping(value = "/teacher/testpaperedit/{url_id}/{test_paper_id}")
    public String examplanmanage(@PathVariable(value = "url_id") String urlId, @PathVariable(value = "test_paper_id") String testPaperId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {

    /**
     * 管理员 更新教师属性
     */
    @RequestMapping(value = "/teacher/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> update(HttpRequest request) {
        Teacher teacher = new Teacher();
        teacher.setTeacherId(request.getString("teacher_id"));
        teacher.setName(request.getString("teacher_name"));
        teacher.setPwd(request.getString("teacher_id"));
        teacher.setSex(request.getInteger("sex"));
        teacher.setUpdateTime(new Date());
        return teacherService.update(teacher, ImageUtil.stringToBytes(request.getString("teacher_image")));
    }

    /**
     * 管理员 删除教师
     */
    @RequestMapping(value = "/teacher/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> del(HttpRequest request) {
        List<String> teacherIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("teacher_id_list");
        for (int i = 0; i < array.size(); i++) {
            teacherIdList.add(array.getString(i));
        }
        return teacherService.del(teacherIdList);
    }

    /**
     * 管理员 查询所有任教老师
     */
    @RequestMapping(value = "/teacher/qryAllList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Teacher> qryAllList() {
        return teacherService.qryAllList();
    }
}
    /**
     * 分页查询试卷信息
     */
    @RequestMapping(value = "/testpaper/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public ListResult<TestPaper> qryPage(HttpRequest request) {
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        String testPaperName = request.getString("test_paper_name");
        String academicsId = request.getString("academics_id");
        return testPaperService.qryPage(testPaperName, academicsId, pageNo, pageSize);
    }

    /**
     * 教师 更新新试卷
     */
    @RequestMapping(value = "/testpaper/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<TestPaper> insert(HttpRequest request) {
        return testPaperService.insert(request.getString("test_paper_name"), request.getString("academics_id"));
    }

    /**
     * 教师 删除试卷
     */
    @RequestMapping(value = "/testpaper/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<TestPaper> del(HttpRequest request) {
        List<Integer> testPaperIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("test_paper_id_list");
        for (int i = 0; i < array.size(); i++) {
            testPaperIdList.add(array.getInteger(i));
        }
        return testPaperService.del(testPaperIdList);
    }

    /**
     * 教师 更新状态
     */
    @RequestMapping(value = "/testpaper/updateState", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<TestPaper> updateState(HttpRequest request) {
        return testPaperService.updateState(request.getInteger("test_paper_id"), request.getInteger("state"));
    }

    /**
     * 教师 试卷编辑
     */
    @RequestMapping(value = "/testpaper/edit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    private IQuestionService questionService;

    /**
     * 教师 查询试题列表
     */
    @RequestMapping(value = "/question/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public ListResult<Question> qryPage(HttpRequest request) {
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        Integer questionType = request.getInteger("question_type");
        String academicsId = request.getString("academics_id");
        String questionTitle = request.getString("question_title");
        Integer difficultyLevel = request.getInteger("difficulty_level");
        return questionService.qryPage(questionType, academicsId, questionTitle, difficultyLevel, pageNo, pageSize);
    }

    /**
     * 教师 添加试题
     */
    @RequestMapping(value = "/question/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<Question> insert(HttpRequest request) {
        Question question = new Question();
        question.setQuestionType(request.getInteger("question_type"));
        question.setAcademicsId(request.getString("academics_id"));
        question.setQuestionTitle(request.getString("question_title"));
        question.setQuestionTitleHtml(request.getString("question_title_html"));
        question.setQuestionAnswer(request.getString("question_answer"));
        question.setQuestionAnalysis(request.getString("question_analysis"));
        question.setDifficultyLevel(request.getInteger("difficulty_level"));
        question.setUpdateTime(new Date());
        return questionService.insert(question);
    }

    /**
     * 教师 更新试题
     */
    @RequestMapping(value = "/question/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<Question> update(HttpRequest request) {
        Question question = new Question();
        question.setQuestionId(request.getLong("question_id"));
        question.setQuestionType(request.getInteger("question_type"));
        question.setAcademicsId(request.getString("academics_id"));
        question.setQuestionTitle(request.getString("question_title"));
        question.setQuestionTitleHtml(request.getString("question_title_html"));
        question.setQuestionAnswer(request.getString("question_answer"));
        question.setQuestionAnalysis(request.getString("question_analysis"));
        question.setDifficultyLevel(request.getInteger("difficulty_level"));
        question.setUpdateTime(new Date());
        return questionService.update(question);
    }

    /**
     * 管理员 查询院系列表
     */
    @RequestMapping(value = "/department/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Department> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("department_id")) {
            param.put("department_id", request.getString("department_id"));
        }
        if (request.containsKey("department_name")) {
            param.put("department_name", request.getString("department_name"));
        }
        return departmentService.qryPage(param, pageNo, pageSize);
    }

    /**
     * 管理员 添加院系
     */
    @RequestMapping(value = "/department/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Department> insert(HttpRequest request) {
        Department department = new Department();
        department.setDepartmentId(request.getString("department_id"));
        department.setDepartmentName(request.getString("department_name"));
        department.setUpdateTime(new Date());
        return departmentService.insert(department);
    }

    /**
     * 管理员 更新院系
     */
    @RequestMapping(value = "/department/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Department> update(HttpRequest request) {
        Department department = new Department();
        department.setDepartmentId(request.getString("department_id"));
        department.setDepartmentName(request.getString("department_name"));
        department.setUpdateTime(new Date());
    }

    /**
     * 教师 添加新的考试信息
     */
    @RequestMapping(value = "/examinfo/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> insert(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        return examInfoService.insert(exam);
    }

    /**
     * 教师 更新考试信息
     */
    @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> update(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setExamId(request.getInteger("exam_id"));
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        exam.setUpdateTime(new Date());
        return examInfoService.update(exam);
    }

    /**
     * 教师 新建状态的考试信息可以删除
     */
    @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> del(HttpRequest request) {
        List<Integer> examIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("exam_id_list");
        for (int i = 0; i < array.size(); i++) {
            examIdList.add(array.getInteger(i));
        }
        return examInfoService.del(examIdList);
    }

    /**
     * 教师 发布考试信息
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        return examInfoService.insert(exam);
    }

    /**
     * 教师 更新考试信息
     */
    @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> update(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setExamId(request.getInteger("exam_id"));
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        exam.setUpdateTime(new Date());
        return examInfoService.update(exam);
    }

    /**
     * 教师 新建状态的考试信息可以删除
     */
    @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> del(HttpRequest request) {
        List<Integer> examIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("exam_id_list");
        for (int i = 0; i < array.size(); i++) {
            examIdList.add(array.getInteger(i));
        }
        return examInfoService.del(examIdList);
    }
    public Result<Academics> del(HttpRequest request) {
        List<String> academicsIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("academics_id_list");
        for (int i = 0; i < array.size(); i++) {
            academicsIdList.add(array.getString(i));
        }
        return academicsService.del(academicsIdList);
    }

    /**
     * 管理员 查询所有科目
     */
    @RequestMapping(value = "/academics/qryAllList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Academics> qryAllList() {
        return academicsService.qryAllList();
    }

}

/**
 * 院系管理控制器
 */
@RestController

/**
 * 教师 相关界面
 */
@Controller
public class TeacherHtmlController {

    @Resource(name = "testPaperService")
    private ITestPaperService testPaperService;

    @Resource(name = "studentExamRecordService")
    private IStudentExamRecordService studentExamRecordService;

    /**
     * 教师界面 teacher/teacher.html
     */
    @RequestMapping(value = "/teacher/teacher/{url_id}")
    public String teacher(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/teacher";
    }

    /**
     * 教师 首页
     */
    @RequestMapping(value = "/teacher/index/{url_id}")
    public String index(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
        }
        return "teacher/index";
    }

    /**
     * 教师 题库管理
     */
    @RequestMapping(value = "/teacher/questionmanage/{url_id}")
    public String questionmanage(@PathVariable(value = "url_id") String urlId, Model model) {
        if (!ValidateUrlIdUtil.validate(urlId, model)) {
            return "error/error";
 */
@RestController
public class TeacherClassRefController {

    @Resource(name = "teacherClassRefService")
    private ITeacherClassRefService teacherClassRefService;

    /**
     * 管理员 查询班级所学科目和任教教师列表
     */
    @RequestMapping(value = "/teacherclassref/qryByClassId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<TeacherClassRef> qryByClassId(HttpRequest request) {
        return teacherClassRefService.qryByClassId(request.getString("class_id"));
    }

    /**
     * 管理员 添加班级所学科目任教教师
     */
    @RequestMapping(value = "/teacherclassref/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<TeacherClassRef> insert(HttpRequest request) {
        TeacherClassRef teacherClassRef = new TeacherClassRef();
        teacherClassRef.setClassId(request.getString("class_id"));
        teacherClassRef.setAcademicsId(request.getString("academics_id"));
        teacherClassRef.setTeacherId(request.getString("teacher_id"));
        return teacherClassRefService.insert(teacherClassRef);
    }

    /**
     * 管理员 删除班级所学科目任教教师
     */
    @RequestMapping(value = "/teacherclassref/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<TeacherClassRef> del(HttpRequest request) {
        TeacherClassRef teacherClassRef = new TeacherClassRef();
        teacherClassRef.setClassId(request.getString("class_id"));
        teacherClassRef.setAcademicsId(request.getString("academics_id"));
        teacherClassRef.setTeacherId(request.getString("teacher_id"));
        return teacherClassRefService.del(teacherClassRef);
    }

    /**
     * 教师 查询教师所教科目
        return classInfoService.qryPage(param, pageNo, pageSize);
    }

    /**
     * 管理员 添加班级信息
     */
    @RequestMapping(value = "/classinfo/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<ClassInfo> insert(HttpRequest request) {
        ClassInfo classInfo = new ClassInfo();
        classInfo.setClassId(request.getString("class_id"));
        classInfo.setClassName(request.getString("class_name"));
        classInfo.setDepartmentId(request.getString("department_id"));
        classInfo.setUpdateTime(new Date());
        return classInfoService.insert(classInfo);
    }

    /**
     * 管理员 更新班级信息
     */
    @RequestMapping(value = "/classinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<ClassInfo> update(HttpRequest request) {
        ClassInfo classInfo = new ClassInfo();
        classInfo.setClassId(request.getString("class_id"));
        classInfo.setClassName(request.getString("class_name"));
        classInfo.setDepartmentId(request.getString("department_id"));
        classInfo.setUpdateTime(new Date());
        return classInfoService.update(classInfo);
    }

    /**
     * 管理员 删除班级信息
     */
    @RequestMapping(value = "/classinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<ClassInfo> del(HttpRequest request) {
        List<String> classIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("class_id_list");
        for (int i = 0; i < array.size(); i++) {
            classIdList.add(array.getString(i));
        }
        return classInfoService.del(classIdList);
    }

}
        return teacherClassRefService.del(teacherClassRef);
    }

    /**
     * 教师 查询教师所教科目
     */
    @RequestMapping(value = "/teacherclassref/qryByTeacherId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public ListResult<Academics> qryByTeacherId() {
        if (SessionContext.containsKey("teacher_id")) {
            return teacherClassRefService.qryByTeacherId(SessionContext.get("teacher_id"));
        }
        ExceptionHelper.error(ErrorCode.ERROR_CODE_0021);
        return new ListResult<>();
    }

    /**
     * 教师 查询教师所教班级和科目
     */
    @RequestMapping(value = "/teacherclassref/qryRefByTeacherId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<TeacherClassRef> qryRefByTeacherId() {
        return teacherClassRefService.qryRefByTeacherId();
    }
}

/**
 * 学生控制器
 */
@RestController
public class StudentController {

    @Resource(name = "studentService")
    private IStudentService studentService;

    @Resource(name = "studentExamRecordService")
    private IStudentExamRecordService studentExamRecordService;

    /**学生 查询考试信息列表*/
    @RequestMapping(value = "/studentexamrecord/qryExamPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> qryExamPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        param.put("student_id", SessionContext.get("student_id"));
        param.put("now_time", DateUtils.parseDateToStr(new Date(), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS));
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        param.put("state",list);
        return studentExamRecordService.qryPage(param, pageNo, pageSize);
    }

    /**学生 查询考试成绩列表*/
    @RequestMapping(value = "/studentexamrecord/qryScorePage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> qryScorePage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        param.put("student_id", SessionContext.get("student_id"));
        List<Integer> list = new ArrayList<>();
        list.add(4);
        list.add(5);
        param.put("state",list);
        return studentExamRecordService.qryPage(param, pageNo, pageSize);
    }

    /**学生 打开试卷*/
    @RequestMapping(value = "/studentexamrecord/openexam", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> openexam(HttpRequest request) {
        return studentExamRecordService.openexam(request.getInteger("exam_id"), request.getString("student_id"));
    }

    /**学生 更新考试用时时间*/
    @RequestMapping(value = "/studentexamrecord/updateTime", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamRecord> updateTime(HttpRequest request) {
        return studentExamRecordService.updateTime(request.getInteger("exam_id"), request.getString("student_id"));

/**
 * 教师控制器
 */
@RestController
public class TeacherController {

    @Resource(name = "teacherService")
    private ITeacherService teacherService;

    /**
     * 管理员 查询教师列表
     */
    @RequestMapping(value = "/teacher/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Teacher> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("teacher_id")) {
            param.put("teacher_id", request.getString("teacher_id"));
        }
        if (request.containsKey("name")) {
            param.put("name", request.getString("name"));
        }
        return teacherService.qryPage(param, pageNo, pageSize);
    }

    /**
     * 管理员 添加教师
     */
    @RequestMapping(value = "/teacher/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> insert(HttpRequest request) {
        Teacher teacher = new Teacher();
        teacher.setTeacherId(request.getString("teacher_id"));
        teacher.setName(request.getString("teacher_name"));
        teacher.setPwd(request.getString("teacher_id"));
        teacher.setSex(request.getInteger("sex"));
        teacher.setUpdateTime(new Date());
        return teacherService.insert(teacher, ImageUtil.stringToBytes(request.getString("teacher_image")));
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        return examInfoService.insert(exam);
    }

    /**
     * 教师 更新考试信息
     */
    @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> update(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setExamId(request.getInteger("exam_id"));
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        exam.setUpdateTime(new Date());
        return examInfoService.update(exam);
    }

    /**
     * 教师 新建状态的考试信息可以删除
     */
    @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> del(HttpRequest request) {
        List<Integer> examIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("exam_id_list");
        for (int i = 0; i < array.size(); i++) {
            examIdList.add(array.getInteger(i));
        }
        return examInfoService.del(examIdList);
    }

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值