ExerciseDictController.java 3.09 KB
package com.subsidy.controller;


import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.exercise.GetAllExercisesDTO;
import com.subsidy.dto.exercise.SubmitDTO;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.ExerciseDictDO;
import com.subsidy.service.ExerciseDictService;
import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.Api;

/**
 * <p>
 * 习题库 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-10-12
 */
@RestController
@Api(tags = "习题库")
@RequestMapping("/exerciseDict")
public class ExerciseDictController {

    @Autowired
    private ExerciseDictService exerciseDictService;

    @PostMapping("getAllExercises")
    @ApiOperation("查询所有题目  {courseId 课程id exerciseType 题目类型  difficulty 难度  title 题目  pageSize pageNum}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getAllExercises(@RequestBody GetAllExercisesDTO getAllExercisesDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getAllExercises(getAllExercisesDTO));
    }

    @PostMapping("addExercise")
    @ApiOperation("添加题目  {courseId 课程id exerciseType 题目类型  difficulty 难度  title题目 items 选项 rightAnswer 正确答案 }")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addExercise(@RequestBody ExerciseDictDO exerciseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.addExercise(exerciseDictDO));
    }

    @PostMapping("deleteExercise")
    @ApiOperation("删除题目  id")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO deleteExercise(@RequestBody ExerciseDictDO exerciseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.deleteExercise(exerciseDictDO));
    }

    @PostMapping("updateExercise")
    @ApiOperation("修改题目  id exerciseType 题目类型  difficulty 难度  title题目 items 选项 rightAnswer 正确答案")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateExercise(@RequestBody ExerciseDictDO exerciseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.updateExercise(exerciseDictDO));
    }

    @PostMapping("getCourseExercises")
    @ApiOperation("获取课程的习题  id 课程id")
    public ResponseVO getCourseExercises(@RequestBody CourseDictDO courseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getCourseExercises(courseDictDO));
    }

    @PostMapping("submit")
    @ApiOperation("提交答案  {memberId 成员id  classId课程 courseId 课程id  memberExerciseVOS [ id   selectAnswer ]} ")
    public ResponseVO submit(@RequestBody SubmitDTO submitDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.submit(submitDTO));
    }


}