package com.ruoyi.study.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.management.api.feignClient.ManagementClient;
import com.ruoyi.study.domain.*;
import com.ruoyi.study.dto.SubjectDTO;
import com.ruoyi.study.dto.SubjectQuery;
import com.ruoyi.study.service.*;
import com.ruoyi.study.vo.SubjectVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
* 题目管理 前端控制器
*
*
* @author 无关风月
* @since 2024-04-26
*/
@RestController
@RequestMapping("/base/tSubject")
public class TSubjectController {
@Autowired
private ITStudyAnswerService studyAnswerService;
@Autowired
private ITStudyInductionService studyInductionService;
@Autowired
private ITStudyLookService studyLookService;
@Autowired
private ITStudyListenService studyListenService;
@Autowired
private ITStudyPairService studyPairService;
@Autowired
private ITGameService gameService;
@Autowired
private ITStoryListenService storyListenService;
@Autowired
private ITSubjectService subjectService;
@Autowired
private ITStoryService storyService;
@Autowired
private ITStudyService studyService;
@PostMapping("/subjectList")
// @ApiOperation(value = "列表查询", tags = {"题目管理"})
public R> subjectList(@RequestBody SubjectQuery query) {
PageInfo res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
List list = subjectService.listAll(query);
for (SubjectVO subjectVO : list) {
// StringBuilder stringBuilder = new StringBuilder("");
// for (String s : subjectVO.getType().split(",")) {
// switch (s) {
// case "1":
// stringBuilder.append("自主学习一、");
// break;
// case "2":
// stringBuilder.append("自主学习二、");
// break;
// case "3":
// stringBuilder.append("自主学习三、");
// break;
// case "4":
// stringBuilder.append("自主学习四、");
// break;
// case "5":
// stringBuilder.append("自主学习五、");
// break;
// }
// }
// String string = stringBuilder.toString();
// String substring = string.substring(0, string.length() - 1);
subjectVO.setType(subjectVO.getType());
}
res.setRecords(list);
res.setTotal(list.size());
return R.ok(res);
}
@PostMapping("/add")
// @ApiOperation(value = "添加", tags = {"题目管理"})
public R add(@RequestBody SubjectDTO dto) {
TSubject tSubject = new TSubject();
BeanUtils.copyProperties(dto,tSubject);
subjectService.save(tSubject);
return R.ok("添加成功");
}
@PostMapping("/update")
// @ApiOperation(value = "编辑", tags = {"题目管理"})
public R update(@RequestBody SubjectDTO dto) {
TSubject tSubject = new TSubject();
// 判断当前题目有没有被使用
R