feat: 🎸 新建题库
This commit is contained in:
parent
0d83336140
commit
049ee30611
@ -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:文档 */
|
||||
|
@ -0,0 +1,65 @@
|
||||
package org.jeecg.modules.biz.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.biz.constant.EntityLinkConst;
|
||||
import org.jeecg.modules.biz.service.EntityLinkBizService;
|
||||
import org.jeecg.modules.gen.repo.entity.Repo;
|
||||
import org.jeecg.modules.gen.repo.mapper.RepoMapper;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/biz/repo")
|
||||
@Tag(name = "题库")
|
||||
@Slf4j
|
||||
public class RepoBizController {
|
||||
|
||||
@Autowired
|
||||
private RepoMapper repoMapper;
|
||||
@Autowired
|
||||
private EntityLinkBizService entityLinkBizService;
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@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<>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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