Merge branch 'dev' of http://110.42.96.65:19890/GoCo/OL-LearnPlatform-Backend into dev
# Conflicts: # jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java
This commit is contained in:
commit
81a6f0ee43
@ -35,6 +35,8 @@ public final class EntityLinkConst {
|
||||
public static final String EXAM = "exam";
|
||||
// 课程
|
||||
public static final String COURSE = "course";
|
||||
// 题库
|
||||
public static final String REPO = "repo";
|
||||
}
|
||||
|
||||
/** 资源类型 0:视频,1:图片,2:文档 */
|
||||
|
@ -5,7 +5,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.gen.question.controller.QuestionController;
|
||||
import org.jeecg.modules.biz.constant.EntityLinkConst;
|
||||
import org.jeecg.modules.biz.service.EntityLinkBizService;
|
||||
import org.jeecg.modules.gen.question.entity.Question;
|
||||
import org.jeecg.modules.gen.question.service.IQuestionService;
|
||||
import org.jeecg.modules.gen.questionanswer.entity.QuestionAnswer;
|
||||
@ -14,29 +15,51 @@ import org.jeecg.modules.gen.questionoption.entity.QuestionOption;
|
||||
import org.jeecg.modules.gen.questionoption.service.IQuestionOptionService;
|
||||
import org.jeecg.modules.gen.questionrepo.service.IQuestionRepoService;
|
||||
import org.jeecg.modules.gen.repo.entity.Repo;
|
||||
import org.jeecg.modules.gen.repo.mapper.RepoMapper;
|
||||
import org.jeecg.modules.gen.repo.service.IRepoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/biz/repo")
|
||||
@Tag(name = "题库")
|
||||
@Tag(name = "题库题目")
|
||||
@Slf4j
|
||||
public class RepoBizController {
|
||||
|
||||
@Autowired
|
||||
private RepoMapper repoMapper;
|
||||
private IRepoService repoService;
|
||||
@Autowired
|
||||
private IQuestionRepoService questionRepoService;
|
||||
@Autowired
|
||||
private EntityLinkBizService entityLinkBizService;
|
||||
private IQuestionService questionService;
|
||||
@Autowired
|
||||
private IQuestionOptionService questionOptionService;
|
||||
@Autowired
|
||||
private IQuestionAnswerService questionAnswerService;
|
||||
|
||||
@PostMapping("course_add")
|
||||
@Operation(summary = "获取课程下的题库")
|
||||
@Transactional
|
||||
public Result<Integer> correct(@RequestBody Map<String, Object> data) {
|
||||
String title = (String) data.get("title");
|
||||
String remark = (String) data.get("remark");
|
||||
String courseId = (String) data.get("courseId");
|
||||
|
||||
Repo repo = new Repo();
|
||||
repo.setTitle(title);
|
||||
repo.setRemark(remark);
|
||||
|
||||
repoMapper.insert(repo);
|
||||
entityLinkBizService.save(EntityLinkConst.SourceType.COURSE, courseId, EntityLinkConst.TargetType.REPO, repo.getId());
|
||||
return Result.OK(repo.getId());
|
||||
}
|
||||
|
||||
@PostMapping(value = "/courseAdd")
|
||||
@Operation(summary = "课程新建题库")
|
||||
@ -44,11 +67,6 @@ public class RepoBizController {
|
||||
return repoService.save(repo)?Result.OK("添加成功!"):Result.error("添加失败!");
|
||||
}
|
||||
|
||||
@GetMapping("/courseList")
|
||||
@Operation(summary = "获取课程题库")
|
||||
public Result<?> courseList(@RequestParam String courseId) {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/questionList/{repoId}")
|
||||
@Operation(summary = "查询题库下题目")
|
||||
@ -57,6 +75,18 @@ public class RepoBizController {
|
||||
return Result.ok(questionService.listByIds(list));
|
||||
}
|
||||
|
||||
@GetMapping("course_list")
|
||||
@Operation(summary = "获取课程下的题库")
|
||||
public Result<List<Repo>> courseList(@RequestParam String courseId) {
|
||||
List<String> targetIds = entityLinkBizService.listTargetIds(EntityLinkConst.SourceType.COURSE, courseId, EntityLinkConst.TargetType.REPO);
|
||||
|
||||
if (targetIds.size() > 0) {
|
||||
List<Repo> list = repoMapper.selectByIds(targetIds);
|
||||
return Result.OK(list);
|
||||
} else {
|
||||
return Result.OK(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/repoList/{questionId}")
|
||||
@Operation(summary = "查询题目详情")
|
||||
|
@ -14,4 +14,13 @@ public interface EntityLinkBizService extends IService<EntityLink>{
|
||||
* @return target_id 列表(去重)
|
||||
*/
|
||||
List<String> listTargetIds(String sourceType, String sourceId, String targetType);
|
||||
|
||||
/**
|
||||
* 保存主体与内容类型的绑定关系
|
||||
* @param sourceType 主体类型
|
||||
* @param sourceId 主体ID
|
||||
* @param targetType 内容类型
|
||||
* @param targetId 内容ID
|
||||
*/
|
||||
void save(String sourceType, String sourceId, String targetType, String targetId);
|
||||
}
|
||||
|
@ -23,4 +23,14 @@ public class EntityLinkBizServiceImpl extends ServiceImpl<EntityLinkMapper, Enti
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String sourceType, String sourceId, String targetType, String targetId) {
|
||||
EntityLink entityLink = new EntityLink();
|
||||
entityLink.setSourceType(sourceType);
|
||||
entityLink.setSourceId(sourceId);
|
||||
entityLink.setTargetType(targetType);
|
||||
entityLink.setTargetId(targetId);
|
||||
this.save(entityLink);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user