Blame view

ExerciseDictController.java 5.85 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
package com.meishu.controller;


import com.meishu.common.ResponseData;
import com.meishu.common.ResponseVO;
import com.meishu.common.interceptor.LoginRequired;
import com.meishu.dto.exercise.*;
import com.meishu.dto.voddict.GetToCheckVodCountsDTO;
import com.meishu.dto.voddict.PublicCheckingDTO;
import com.meishu.model.ExerciseDictDO;
import com.meishu.model.ExerciseTreeMappingDO;
import com.meishu.service.ExerciseDictService;
import com.meishu.util.ConstantUtils;
import com.meishu.util.LatexUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

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

    @Autowired
    private ExerciseDictService exerciseDictService;

    @PostMapping("getTreeExercises")
    @ApiOperation("获取某个知识点下的题目  {subjectId treeId exerciseType difficulty  shareStatus 0:个人库 1:公共库 title pageSize pageNum}")
//    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getTreeExercises(@RequestBody GetTreeExercisesDTO getTreeExercisesDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getTreeExercises(getTreeExercisesDTO));
    }

    @PostMapping("getCheckTreeExercises")
    @ApiOperation("获取某个知识点下的题目  {subjectId treeId exerciseType difficulty shareStatus 分享状态  checkStatus 1:已审核 2:待审核   title pageSize pageNum}")
//    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getCheckTreeExercises(@RequestBody GetTreeExercisesDTO getTreeExercisesDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getCheckTreeExercises(getTreeExercisesDTO));
    }

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

    @PostMapping("addExercise")
    @ApiOperation("新增习题 {subjectId:科目id   exerciseType:选择/填空  administerId:提供者 difficulty:难度" +
            "title:题目  items:选项  adviceLength  rightAnswer:正确答案  detail:解析 treeIds:知识点(数组)}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addExercise(@RequestBody AddExerciseDTO addExerciseDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.addExercise(addExerciseDTO));
    }

    @PostMapping("updateExercise")
    @ApiOperation("修改习题 {id subjectId:科目id   exerciseType:选择/填空  administerId:提供者 difficulty:难度" +
            " title:题目  items:选项  adviceLength  rightAnswer:正确答案  detail:解析 treeIds:知识点(数组)}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateExercise(@RequestBody AddExerciseDTO addExerciseDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.updateExercise(addExerciseDTO));
    }

    @PostMapping("getToCheckExeCounts")
    @ApiOperation("获取所有未审核的习题")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getToCheckExeCounts(GetToCheckVodCountsDTO getToCheckVodCountsDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getToCheckExeCounts(getToCheckVodCountsDTO));
    }

    @PostMapping("checkExercise")
    @ApiOperation("审核题目  {checkId 审核人id  id 题目id  treeIds checkStatus difficulty adviceLength  1:审核通过  3:未通过  reason  不通过原因}")
    public ResponseVO checkExercise(@RequestBody CheckExerciseDTO checkExerciseDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.checkExercise(checkExerciseDTO));
    }

    @PostMapping("publicUpload")
    @ApiOperation("公共资源上载  {userId   checkStatus 1:审核通过 2:审核中 3:未通过}")
    public ResponseVO publicUpload(@RequestBody PublicCheckingDTO publicCheckingDTO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.publicUpload(publicCheckingDTO));
    }

    @PostMapping("withdraw")
    @ApiOperation("撤回题目  id 题目id")
    public ResponseVO withdraw(@RequestBody ExerciseDictDO exerciseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.withdraw(exerciseDictDO));
    }

    @PostMapping("getExerciseDetail")
    @ApiOperation("获取一个视频详情{id}")
    public ResponseVO getVodDetail(@RequestBody ExerciseDictDO exerciseDictDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.getExerciseDetail(exerciseDictDO));
    }

    @PostMapping("/getLatexBaseString")
    @ApiOperation("公式转Base64图片   {latex : latex公式表达式}")
    public ResponseVO getLatexBaseString(@RequestBody ExeLatexExpressDTO latex){
        return ResponseData.generateCreatedResponse(0,(Object) LatexUtils.latex2Png(latex.getLatex()).replace("\r\n",""));
    }

    @PostMapping("/setRelatedExercise")
    @ApiOperation("设置为关联习题  {status 关联:1 取消:0   exerciseId  习题id}")
    public ResponseVO setRelatedExercise(@RequestBody ExerciseTreeMappingDO exerciseTreeMappingDO){
        return ResponseData.generateCreatedResponse(0,exerciseDictService.setRelatedExercise(exerciseTreeMappingDO));
    }


}