xiangpei
2025-05-14 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403
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
package com.mindskip.xzs.controller.admin;
 
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.QuestionAnswer;
import com.mindskip.xzs.domain.vo.QuestionAnswerVO;
import com.mindskip.xzs.service.QuestionAnswerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
/**
 * @author gonghl
 * @since 2024/5/11 下午 3:57
 */
 
@RequiredArgsConstructor
@RestController("AdminQuestionAnswerController")
@RequestMapping("/api/admin/questionAnswer")
public class QuestionAnswerController extends BaseApiController {
 
    private final QuestionAnswerService questionAnswerService;
 
    /**
     * 保存、修改问答
     */
    @PostMapping("save")
    public RestResponse<String> saveQuestionAnswer(@RequestBody QuestionAnswer questionAnswer) {
        questionAnswerService.saveOrUpdate(questionAnswer);
        return RestResponse.ok("操作成功");
    }
 
    /**
     * 分页查询
     */
    @PostMapping("page")
    public RestResponse<PageInfo<QuestionAnswerVO>> page(@RequestBody QuestionAnswerVO questionAnswer) {
        return RestResponse.ok(questionAnswerService.questionAnswerPage(questionAnswer));
    }
 
    /**
     * 删除问答
     */
    @PostMapping("delete/{id}")
    public RestResponse<String> delete(@PathVariable Integer id) {
        questionAnswerService.removeById(id);
        return RestResponse.ok("操作成功");
    }
 
    /**
     * 查询问答
     */
    @PostMapping("query/{id}")
    public RestResponse<QuestionAnswer> query(@PathVariable Integer id) {
        return RestResponse.ok(questionAnswerService.getById(id));
    }
 
    /**
     * 修改问答
     */
    @PostMapping("update")
    public RestResponse<String> update(@RequestBody QuestionAnswer questionAnswer) {
        questionAnswerService.updateById(questionAnswer);
        return RestResponse.ok("操作成功");
    }
 
    /**
     * 修改问答状态
     */
    @PostMapping("updateStatus/{id}")
    public RestResponse<String> updateStatus(@PathVariable Integer id) {
        questionAnswerService.updateStatus(id);
        return RestResponse.ok("操作成功");
    }
 
    @GetMapping("getLastSequence")
    public RestResponse<Integer> getLastSequence() {
        return RestResponse.ok(questionAnswerService.getLastSequence());
    }
 
}