QuestionsController.java 1.88 KB
package com.laowu.controller;


import com.laowu.model.QuestionsDO;
import com.laowu.service.QuestionsService;
import com.laowu.util.ResponseData;
import com.laowu.util.ResponseVO;
import io.swagger.annotations.Api;
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;

/**
 * <p>
 * Q && A 前端控制器
 * </p>
 *
 * @author Tuyp
 * @since 2023-02-15
 */
@RestController
@Api(tags = "Q && A")
@RequestMapping("/questions")
public class QuestionsController {

    @Autowired
    private QuestionsService questionsService;

    @PostMapping("contentQuestions")
    @ApiOperation("某个目录下的问题&答案  contentId")
    public ResponseVO contentQuestions(@RequestBody QuestionsDO questionsDO){
        return ResponseData.generateCreatedResponse(0,questionsService.contentQuestions(questionsDO));
    }

    @PostMapping("deleteQuestion")
    @ApiOperation("删除答疑 id")
    public ResponseVO deleteQuestion(@RequestBody QuestionsDO questionsDO){
        return ResponseData.generateCreatedResponse(0,questionsService.deleteQuestion(questionsDO));
    }

    @PostMapping("addQuestion")
    @ApiOperation("新增答疑  contentId  question answer")
    public ResponseVO addQuestion(@RequestBody QuestionsDO questionsDO){
        return ResponseData.generateCreatedResponse(0,questionsService.addQuestion(questionsDO));
    }

    @PostMapping("updateQuestion")
    @ApiOperation("修改答疑  id  contentId  question answer")
    public ResponseVO updateQuestion(@RequestBody QuestionsDO questionsDO){
        return ResponseData.generateCreatedResponse(0,questionsService.updateQuestion(questionsDO));
    }

}