无关风月
2024-07-22 da26806f0fbc78b501d58976092cc681f786c35b
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package com.ruoyi.management.controller;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.study.api.dto.*;
import com.ruoyi.study.api.feignClient.StudyClient;
import com.ruoyi.study.api.model.TStory;
import com.ruoyi.study.api.model.TSubject;
import com.ruoyi.study.api.vo.StudyDTO;
import com.ruoyi.study.api.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
 
import java.util.List;
 
/**
 * <p>
 * 学习类型前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-04-26
 */
@Controller
@RequestMapping("/tStudy")
public class TStudyController {
    @Autowired
    private StudyClient studyClient;
    @ApiOperation(value = "选择题目列表查询", tags = {"后台-学习"})
    @PostMapping(value = "/subjectList1")
    @ResponseBody
    public AjaxResult<PageInfo<TSubject>> subjectList(ChoiceSubject dto) {
        R<PageInfo<TSubject>> pageInfoR = studyClient.subjectList(dto);
        PageInfo<TSubject> data = pageInfoR.getData();
        return AjaxResult.success(data);
    }
    @ApiOperation(value = "选择故事列表查询", tags = {"后台-学习"})
    @PostMapping(value = "/storyList1")
    @ResponseBody
    public AjaxResult<PageInfo<TStory>> storyList(ChoiceStory dto) {
        R<PageInfo<TStory>> pageInfoR = studyClient.storyList(dto);
        PageInfo<TStory> data = pageInfoR.getData();
        return AjaxResult.success(data);
    }
    @ApiOperation(value = "新增或修改学习配置", tags = {"后台-学习"})
    @PostMapping(value = "/addStudySet")
    @ResponseBody
    public AjaxResult addStudySet(@RequestBody AddStudySetDTO dto) {
        R<Object> objectR = studyClient.addStudySet(dto);
        String string = objectR.getMsg().toString();
        int code = objectR.getCode();
        if (code == 500){
            return AjaxResult.error(string);
        }
        return AjaxResult.success("保存成功");
    }
 
    /**
     * 通过类型、周目、day查询学习配置
     * @return
     */
    @ApiOperation(value = "类型管理查看详情", tags = {"后台-学习"})
    @PostMapping(value = "/getStudySet")
    @ResponseBody
    public AjaxResult<StudyVO> getStudySet(StudyDTO dto) {
        R<StudyVO> studySet = studyClient.getStudySet(dto);
        StudyVO data = studySet.getData();
        return AjaxResult.success(data);
    }
    @ApiOperation(value = "类型管理列表数据", tags = {"后台-学习"})
    @PostMapping(value = "/getStudy")
    @ResponseBody
    public AjaxResult<List<StudyListVO>> getStudy() {
        R<List<StudyListVO>> data = studyClient.getStudyList();
        List<StudyListVO> res = data.getData();
        return AjaxResult.success(res);
    }
    @ApiOperation(value = "添加周目", tags = {"后台-学习"})
    @PostMapping(value = "/addWeek")
    @ResponseBody
    public AjaxResult addWeek(AddWeekDTO dto) {
        studyClient.addWeek(dto);
        return AjaxResult.success();
    }
    @ApiOperation(value = "列表查询", tags = {"后台-题目管理"})
    @PostMapping(value = "/subjectList")
    @ResponseBody
    public AjaxResult<PageInfo<SubjectVO>> subjectList(SubjectQuery query) {
        R<PageInfo<SubjectVO>> pageInfoR = studyClient.subjectList(query);
        return AjaxResult.success(pageInfoR.getData());
    }
    @ApiOperation(value = "列表查询", tags = {"后台-故事管理"})
    @PostMapping(value = "/storyList")
    @ResponseBody
    public AjaxResult<PageInfo<SubjectVO>> storyList(SubjectQuery query) {
        R<PageInfo<SubjectVO>> pageInfoR = studyClient.storyList(query);
        return AjaxResult.success(pageInfoR.getData());
    }
    @ApiOperation(value = "添加", tags = {"后台-题目管理"})
    @PostMapping(value = "/addSubject")
    @ResponseBody
    public AjaxResult addSubject(SubjectDTO dto) {
        studyClient.add(dto);
        return AjaxResult.success("添加成功");
    }
    @ApiOperation(value = "修改", tags = {"后台-题目管理"})
    @PostMapping(value = "/updateSubject")
    @ResponseBody
    public AjaxResult updateSubject(SubjectDTO dto) {
        R update = studyClient.update(dto);
        int code = update.getCode();
        if (code == 500){
            return AjaxResult.error(update.getMsg());
        }
        return AjaxResult.success("添加成功");
    }
    @ApiOperation(value = "查看详情", tags = {"后台-题目管理"})
    @PostMapping(value = "/getSubjectInfo")
    @ResponseBody
    public AjaxResult<SubjectDTO> getSubjectInfo(Integer id) {
        R<SubjectDTO> info = studyClient.getInfo(id);
        SubjectDTO data = info.getData();
        return AjaxResult.success(data);
    }
    @ApiOperation(value = "修改状态", tags = {"后台-题目管理"})
    @PostMapping(value = "/updateState")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(value = "id", name = "id", required = true),
            @ApiImplicitParam(value = "状态 1上架2下架3删除", name = "state", required = true),
    })
    public R updateState(Integer id, Integer state) {
        R update = studyClient.updateState(id,state);
        int code = update.getCode();
        if (code == 602){
            return R.failUpdate(update.getMsg());
        }
        return R.ok("修改成功");
    }
    @ApiOperation(value = "添加", tags = {"后台-故事管理"})
    @PostMapping(value = "/addStory")
    @ResponseBody
    public AjaxResult addStory(StoryDTO dto) {
        studyClient.add(dto);
        return AjaxResult.success("添加成功");
    }
    @ApiOperation(value = "修改", tags = {"后台-故事管理"})
    @PostMapping(value = "/updateStory")
    @ResponseBody
    public R updateStory(StoryDTO dto) {
        R update = studyClient.update(dto);
        int code = update.getCode();
        if (code == 602){
            return R.failUpdate(update.getMsg());
        }
 
        return R.ok("添加成功");
    }
    @ApiOperation(value = "查看详情", tags = {"后台-故事管理"})
    @PostMapping(value = "/getStoryInfo")
    @ResponseBody
    public AjaxResult<StoryDTO> getStoryInfo(Integer id) {
        R<StoryDTO> info = studyClient.getInfo1(id);
        StoryDTO data = info.getData();
        return AjaxResult.success(data);
    }
    @ApiOperation(value = "修改状态", tags = {"后台-故事管理"})
    @PostMapping(value = "/updateState1")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(value = "id", name = "id", required = true),
            @ApiImplicitParam(value = "状态 1上架2下架3删除", name = "state", required = true),
    })
    public R updateState1(Integer id, Integer state) {
        R update = studyClient.updateState1(id,state);
        int code = update.getCode();
        if (code == 602){
            return R.failUpdate(update.getMsg());
        }
        return R.ok("修改成功");
    }
}