Merge branch 'dev' of http://110.42.96.65:19890/GoCo/OL-LearnPlatform-Backend into dev
merge
This commit is contained in:
commit
78de817ca9
@ -1,35 +1,52 @@
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.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;
|
||||
import org.jeecg.modules.gen.questionanswer.service.IQuestionAnswerService;
|
||||
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.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
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 = "题库")
|
||||
@Tag(name = "题库题目")
|
||||
@Slf4j
|
||||
public class RepoBizController {
|
||||
|
||||
@Autowired
|
||||
private RepoMapper repoMapper;
|
||||
@Autowired
|
||||
private IRepoService repoService;
|
||||
@Autowired
|
||||
private IQuestionRepoService questionRepoService;
|
||||
@Autowired
|
||||
private EntityLinkBizService entityLinkBizService;
|
||||
@Autowired
|
||||
private IQuestionService questionService;
|
||||
@Autowired
|
||||
private IQuestionOptionService questionOptionService;
|
||||
@Autowired
|
||||
private IQuestionAnswerService questionAnswerService;
|
||||
|
||||
@PostMapping("course_add")
|
||||
@Operation(summary = "获取课程下的题库")
|
||||
@ -45,10 +62,24 @@ public class RepoBizController {
|
||||
|
||||
repoMapper.insert(repo);
|
||||
entityLinkBizService.save(EntityLinkConst.SourceType.COURSE, courseId, EntityLinkConst.TargetType.REPO, repo.getId());
|
||||
|
||||
return Result.OK(repo.getId());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/courseAdd")
|
||||
@Operation(summary = "课程新建题库")
|
||||
public Result<String> courseAdd(@RequestBody Repo repo) {
|
||||
return repoService.save(repo)?Result.OK("添加成功!"):Result.error("添加失败!");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/questionList/{repoId}")
|
||||
@Operation(summary = "查询题库下题目")
|
||||
public Result<List<Question>> questionList(@PathVariable String repoId) {
|
||||
List<String> list = questionRepoService.questionList(repoId);
|
||||
return Result.ok(questionService.listByIds(list));
|
||||
}
|
||||
|
||||
@GetMapping("course_list")
|
||||
@Operation(summary = "获取课程下的题库")
|
||||
public Result<List<Repo>> courseList(@RequestParam String courseId) {
|
||||
@ -62,4 +93,37 @@ public class RepoBizController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/repoList/{questionId}")
|
||||
@Operation(summary = "查询题目详情")
|
||||
public Result<?> questionDetail(@PathVariable String questionId,@RequestParam Integer type) {
|
||||
if (type == 1 || type == 2 || type == 3) {
|
||||
return Result.ok(choiceDetail(questionId));
|
||||
}else if(type == 4 || type == 5) {
|
||||
return Result.ok(answerDetail(questionId));
|
||||
}else {
|
||||
return Result.ok(questionService.list(
|
||||
new LambdaQueryWrapper<Question>().
|
||||
eq(Question::getParentId, questionId)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
public List<QuestionOption> choiceDetail(String questionId) {
|
||||
return questionOptionService.list(
|
||||
new LambdaQueryWrapper<QuestionOption>().
|
||||
eq(QuestionOption::getQuestionId, questionId).
|
||||
orderByAsc(QuestionOption::getOrderNo)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public List<QuestionAnswer> answerDetail(String questionId) {
|
||||
return questionAnswerService.list(
|
||||
new LambdaQueryWrapper<QuestionAnswer>().
|
||||
eq(QuestionAnswer::getQuestionId, questionId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,43 +1,39 @@
|
||||
package org.jeecg.modules.gen.question.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.gen.question.entity.Question;
|
||||
import org.jeecg.modules.gen.question.service.IQuestionService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.gen.question.entity.Question;
|
||||
import org.jeecg.modules.gen.question.entity.QuestionRequest;
|
||||
import org.jeecg.modules.gen.question.service.IQuestionService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.modules.gen.questionanswer.entity.QuestionAnswer;
|
||||
import org.jeecg.modules.gen.questionanswer.service.IQuestionAnswerService;
|
||||
import org.jeecg.modules.gen.questionoption.entity.QuestionOption;
|
||||
import org.jeecg.modules.gen.questionoption.service.IQuestionOptionService;
|
||||
import org.jeecg.modules.gen.questionrepo.entity.QuestionRepo;
|
||||
import org.jeecg.modules.gen.questionrepo.service.IQuestionRepoService;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @Description: 题目
|
||||
* @Author: jeecg-boot
|
||||
@ -51,6 +47,13 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
public class QuestionController extends JeecgController<Question, IQuestionService> {
|
||||
@Autowired
|
||||
private IQuestionService questionService;
|
||||
@Autowired
|
||||
private IQuestionRepoService questionRepoService;
|
||||
@Autowired
|
||||
private IQuestionAnswerService questionAnswerService;
|
||||
@Autowired
|
||||
private IQuestionOptionService questionOptionService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
@ -79,7 +82,6 @@ public class QuestionController extends JeecgController<Question, IQuestionServi
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param question
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "题目-添加")
|
||||
@ -118,7 +120,24 @@ public class QuestionController extends JeecgController<Question, IQuestionServi
|
||||
@RequiresPermissions("gen.question:question:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Question question = questionService.getById(id);
|
||||
questionService.removeById(id);
|
||||
questionRepoService.remove(
|
||||
new LambdaQueryWrapper<QuestionRepo>()
|
||||
.eq(QuestionRepo::getQuestionId,id)
|
||||
);
|
||||
//选择题
|
||||
if( question.getType() >= 0 && question.getType() <= 2){
|
||||
questionOptionService.remove(
|
||||
new LambdaQueryWrapper<QuestionOption>()
|
||||
.eq(QuestionOption::getQuestionId,id)
|
||||
);
|
||||
}else {
|
||||
questionAnswerService.remove(
|
||||
new LambdaQueryWrapper<QuestionAnswer>()
|
||||
.eq(QuestionAnswer::getQuestionId,id)
|
||||
);
|
||||
}
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.gen.question.entity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QuestionRequest {
|
||||
/**题目*/
|
||||
Question question;
|
||||
/**题库id*/
|
||||
@Schema(description = "题库id")
|
||||
List<String> repoIds = new ArrayList<>();
|
||||
}
|
@ -2,6 +2,7 @@ package org.jeecg.modules.gen.questionrepo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.gen.questionrepo.entity.QuestionRepo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @Date: 2025-08-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface QuestionRepoMapper extends BaseMapper<QuestionRepo> {
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package org.jeecg.modules.gen.questionrepo.service;
|
||||
|
||||
import org.jeecg.modules.gen.question.entity.Question;
|
||||
import org.jeecg.modules.gen.questionrepo.entity.QuestionRepo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 题库题目
|
||||
* @Author: jeecg-boot
|
||||
@ -11,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IQuestionRepoService extends IService<QuestionRepo> {
|
||||
|
||||
List<String> questionList(String repoId);
|
||||
}
|
||||
|
@ -1,12 +1,18 @@
|
||||
package org.jeecg.modules.gen.questionrepo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.modules.gen.question.entity.Question;
|
||||
import org.jeecg.modules.gen.questionrepo.entity.QuestionRepo;
|
||||
import org.jeecg.modules.gen.questionrepo.mapper.QuestionRepoMapper;
|
||||
import org.jeecg.modules.gen.questionrepo.service.IQuestionRepoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 题库题目
|
||||
* @Author: jeecg-boot
|
||||
@ -16,4 +22,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@Service
|
||||
public class QuestionRepoServiceImpl extends ServiceImpl<QuestionRepoMapper, QuestionRepo> implements IQuestionRepoService {
|
||||
|
||||
@Autowired
|
||||
private QuestionRepoMapper questionRepoMapper;
|
||||
@Override
|
||||
public List<String> questionList(String repoId) {
|
||||
List<QuestionRepo> questionRepos = questionRepoMapper.selectList(
|
||||
new LambdaQueryWrapper<QuestionRepo>().eq(QuestionRepo::getRepoId, repoId));
|
||||
return questionRepos.stream().map(QuestionRepo::getQuestionId).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,20 @@ package org.jeecg.modules.gen.repo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.gen.repo.entity.Repo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import javax.mail.MailSessionDefinition;
|
||||
|
||||
/**
|
||||
* @Description: 题库
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-08-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface RepoMapper extends BaseMapper<Repo> {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user