diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java new file mode 100644 index 00000000..df59777c --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java @@ -0,0 +1,94 @@ +package org.jeecg.modules.biz.controller; + +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.gen.question.controller.QuestionController; +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.service.IRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + + +@RestController +@RequestMapping("/biz/repo") +@Tag(name = "题库题目") +@Slf4j +public class RepoBizController { + @Autowired + private IRepoService repoService; + @Autowired + private IQuestionRepoService questionRepoService; + @Autowired + private IQuestionService questionService; + @Autowired + private IQuestionOptionService questionOptionService; + @Autowired + private IQuestionAnswerService questionAnswerService; + + + @PostMapping(value = "/courseAdd") + @Operation(summary = "课程新建题库") + public Result courseAdd(@RequestBody Repo repo) { + 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 = "查询题库下题目") + public Result> questionList(@PathVariable String repoId) { + List list = questionRepoService.questionList(repoId); + return Result.ok(questionService.listByIds(list)); + } + + + @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(). + eq(Question::getParentId, questionId) + ) + ); + } + + } + public List choiceDetail(String questionId) { + return questionOptionService.list( + new LambdaQueryWrapper(). + eq(QuestionOption::getQuestionId, questionId). + orderByAsc(QuestionOption::getOrderNo) + ); + } + + + public List answerDetail(String questionId) { + return questionAnswerService.list( + new LambdaQueryWrapper(). + eq(QuestionAnswer::getQuestionId, questionId) + ); + } + + +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java index 88cc0a21..b7262f81 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java @@ -1,44 +1,40 @@ 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 * @Date: 2025-08-21 @@ -51,7 +47,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; public class QuestionController extends JeecgController { @Autowired private IQuestionService questionService; - + @Autowired + private IQuestionRepoService questionRepoService; + @Autowired + private IQuestionAnswerService questionAnswerService; + @Autowired + private IQuestionOptionService questionOptionService; + + /** * 分页列表查询 * @@ -75,11 +78,10 @@ public class QuestionController extends JeecgController pageList = questionService.page(page, queryWrapper); return Result.OK(pageList); } - + /** * 添加 * - * @param question * @return */ @AutoLog(value = "题目-添加") @@ -91,7 +93,7 @@ public class QuestionController extends JeecgController delete(@RequestParam(name="id",required=true) String id) { + Question question = questionService.getById(id); questionService.removeById(id); + questionRepoService.remove( + new LambdaQueryWrapper() + .eq(QuestionRepo::getQuestionId,id) + ); + //选择题 + if( question.getType() >= 0 && question.getType() <= 2){ + questionOptionService.remove( + new LambdaQueryWrapper() + .eq(QuestionOption::getQuestionId,id) + ); + }else { + questionAnswerService.remove( + new LambdaQueryWrapper() + .eq(QuestionAnswer::getQuestionId,id) + ); + } return Result.OK("删除成功!"); } - + /** * 批量删除 * @@ -136,7 +155,7 @@ public class QuestionController extends JeecgController repoIds = new ArrayList<>(); +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/mapper/QuestionRepoMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/mapper/QuestionRepoMapper.java index 466bff47..6a5d3c74 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/mapper/QuestionRepoMapper.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/mapper/QuestionRepoMapper.java @@ -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 { } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/IQuestionRepoService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/IQuestionRepoService.java index 91f49f67..90ed36cd 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/IQuestionRepoService.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/IQuestionRepoService.java @@ -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 { + List questionList(String repoId); } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/impl/QuestionRepoServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/impl/QuestionRepoServiceImpl.java index b5de21a0..a1426b80 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/impl/QuestionRepoServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/questionrepo/service/impl/QuestionRepoServiceImpl.java @@ -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 implements IQuestionRepoService { + @Autowired + private QuestionRepoMapper questionRepoMapper; + @Override + public List questionList(String repoId) { + List questionRepos = questionRepoMapper.selectList( + new LambdaQueryWrapper().eq(QuestionRepo::getRepoId, repoId)); + return questionRepos.stream().map(QuestionRepo::getQuestionId).collect(Collectors.toList()); + + } } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/repo/mapper/RepoMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/repo/mapper/RepoMapper.java index 1b542226..fd4c729e 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/repo/mapper/RepoMapper.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/repo/mapper/RepoMapper.java @@ -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 { }