浏览代码

收藏题目

jinxia.mo 1 月之前
父节点
当前提交
09e136fc1c

+ 55 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontFavoritesController.java

@@ -0,0 +1,55 @@
+package com.ruoyi.web.controller.front;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.learn.domain.LearnPaper;
+import com.ruoyi.learn.domain.LearnQuestions;
+import com.ruoyi.learn.service.ILearnPaperService;
+import com.ruoyi.learn.service.ILearnQuestionsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Api(tags = "前端V2 收藏")
+@RestController
+@RequestMapping("front/favorites")
+public class FrontFavoritesController extends BaseController {
+    @Autowired
+    private ILearnPaperService papersService;
+    @Autowired
+    private ILearnQuestionsService questionsService;
+
+    @ApiOperation("收藏的试卷列表")
+    @GetMapping("papers")
+    public TableDataInfo papers(Long subjectId) {
+        Long userId = SecurityUtils.getLoginUser().getUserId();
+        startPage();
+        LearnPaper papers = new LearnPaper();
+        papers.setSubjectId(subjectId);
+        papers.setExamineeId(userId);
+        papers.setCollect(true);
+        List<LearnPaper> list = papersService.selectPapersListFromFavorites(papers);
+        list.stream().forEach(t -> t.setCollect(true));
+        return getDataTable(list);
+    }
+
+    @ApiOperation("收藏的问题列表")
+    @GetMapping("questions")
+    public TableDataInfo questions(Long subjectId) {
+        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
+        startPage();
+        LearnQuestions questions = new LearnQuestions();
+        questions.setSubjectId(subjectId);
+        questions.setUserId(userId);
+        List<LearnQuestions> list = questionsService.selectCollectedList(questions);
+        questionsService.fillCollectInfo(SecurityUtils.getLoginUser().getUser().getUserId(), list);
+        return getDataTable(list);
+    }
+
+}

+ 39 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontQuestionsController.java

@@ -0,0 +1,39 @@
+package com.ruoyi.web.controller.front;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.mingxue.domain.QuestionCollection;
+import com.ruoyi.mingxue.service.IQuestionCollectionService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "前端V2 题库")
+@RestController
+@RequestMapping("front/questions")
+public class FrontQuestionsController extends BaseController {
+    @Autowired
+    private IQuestionCollectionService questionCollectionService;
+
+    @ApiOperation("收藏试题")
+    @PostMapping("collect")
+    public AjaxResult collect(Long questionId) {
+        QuestionCollection questionCollection = new QuestionCollection();
+        questionCollection.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
+        questionCollection.setQuestionId(questionId);
+        if(CollectionUtils.isEmpty(questionCollectionService.selectQuestionCollectionList(questionCollection))) {
+            return toAjax(questionCollectionService.insertQuestionCollection(questionCollection));
+        }
+        return toAjax(1);
+    }
+
+    @ApiOperation("取消收藏试题")
+    @PostMapping("cancelCollect")
+    public AjaxResult cancelQuestionCollection(Long questionId) {
+        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
+        return toAjax(questionCollectionService.deleteQuestionCollectionById(questionId, userId));
+    }
+}

+ 43 - 23
ie-system/src/main/java/com/ruoyi/learn/domain/LearnPaper.java

@@ -7,7 +7,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 试卷对象 learn_paper
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
@@ -80,32 +80,52 @@ public class LearnPaper extends BaseEntity
 
     private String conditions;
 
-    public void setId(Long id) 
+    private Long examineeId;
+
+    private boolean collect;
+
+    public Long getExamineeId() {
+        return examineeId;
+    }
+
+    public void setExamineeId(Long examineeId) {
+        this.examineeId = examineeId;
+    }
+
+    public boolean isCollect() {
+        return collect;
+    }
+
+    public void setCollect(boolean collect) {
+        this.collect = collect;
+    }
+
+    public void setId(Long id)
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Long getId()
     {
         return id;
     }
 
-    public void setSubjectId(Long subjectId) 
+    public void setSubjectId(Long subjectId)
     {
         this.subjectId = subjectId;
     }
 
-    public Long getSubjectId() 
+    public Long getSubjectId()
     {
         return subjectId;
     }
 
-    public void setPaperName(String paperName) 
+    public void setPaperName(String paperName)
     {
         this.paperName = paperName;
     }
 
-    public String getPaperName() 
+    public String getPaperName()
     {
         return paperName;
     }
@@ -120,12 +140,12 @@ public class LearnPaper extends BaseEntity
         return year;
     }
 
-    public void setPaperType(String paperType) 
+    public void setPaperType(String paperType)
     {
         this.paperType = paperType;
     }
 
-    public String getPaperType() 
+    public String getPaperType()
     {
         return paperType;
     }
@@ -168,72 +188,72 @@ public class LearnPaper extends BaseEntity
         return paperSource;
     }
 
-    public void setDirectKey(String directKey) 
+    public void setDirectKey(String directKey)
     {
         this.directKey = directKey;
     }
 
-    public String getDirectKey() 
+    public String getDirectKey()
     {
         return directKey;
     }
 
-    public void setTiid(String tiid) 
+    public void setTiid(String tiid)
     {
         this.tiid = tiid;
     }
 
-    public String getTiid() 
+    public String getTiid()
     {
         return tiid;
     }
 
-    public void setOsspath(String osspath) 
+    public void setOsspath(String osspath)
     {
         this.osspath = osspath;
     }
 
-    public String getOsspath() 
+    public String getOsspath()
     {
         return osspath;
     }
 
-    public void setFilename(String filename) 
+    public void setFilename(String filename)
     {
         this.filename = filename;
     }
 
-    public String getFilename() 
+    public String getFilename()
     {
         return filename;
     }
 
-    public void setRelateId(Long relateId) 
+    public void setRelateId(Long relateId)
     {
         this.relateId = relateId;
     }
 
-    public Long getRelateId() 
+    public Long getRelateId()
     {
         return relateId;
     }
 
-    public void setLocations(String locations) 
+    public void setLocations(String locations)
     {
         this.locations = locations;
     }
 
-    public String getLocations() 
+    public String getLocations()
     {
         return locations;
     }
 
-    public void setExamineeTypes(String examineeTypes) 
+    public void setExamineeTypes(String examineeTypes)
     {
         this.examineeTypes = examineeTypes;
     }
 
-    public String getExamineeTypes() 
+    public String getExamineeTypes()
     {
         return examineeTypes;
     }

+ 108 - 89
ie-system/src/main/java/com/ruoyi/learn/domain/LearnQuestions.java

@@ -8,7 +8,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 试题对象 learn_questions
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
@@ -191,442 +191,461 @@ public class LearnQuestions extends BaseEntity
     @Excel(name = "子题类型")
     private String isSubType;
 
-    public void setId(Long id) 
+    private Long userId;
+    boolean collect;
+
+    public boolean isCollect() {
+        return collect;
+    }
+
+    public void setCollect(boolean collect) {
+        this.collect = collect;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public void setId(Long id)
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Long getId()
     {
         return id;
     }
 
-    public void setTitle(String title) 
+    public void setTitle(String title)
     {
         this.title = title;
     }
 
-    public String getTitle() 
+    public String getTitle()
     {
         return title;
     }
 
-    public void setOptionA(String optionA) 
+    public void setOptionA(String optionA)
     {
         this.optionA = optionA;
     }
 
-    public String getOptionA() 
+    public String getOptionA()
     {
         return optionA;
     }
 
-    public void setOptionB(String optionB) 
+    public void setOptionB(String optionB)
     {
         this.optionB = optionB;
     }
 
-    public String getOptionB() 
+    public String getOptionB()
     {
         return optionB;
     }
 
-    public void setOptionC(String optionC) 
+    public void setOptionC(String optionC)
     {
         this.optionC = optionC;
     }
 
-    public String getOptionC() 
+    public String getOptionC()
     {
         return optionC;
     }
 
-    public void setOptionD(String optionD) 
+    public void setOptionD(String optionD)
     {
         this.optionD = optionD;
     }
 
-    public String getOptionD() 
+    public String getOptionD()
     {
         return optionD;
     }
 
-    public void setOptionE(String optionE) 
+    public void setOptionE(String optionE)
     {
         this.optionE = optionE;
     }
 
-    public String getOptionE() 
+    public String getOptionE()
     {
         return optionE;
     }
 
-    public void setOptionF(String optionF) 
+    public void setOptionF(String optionF)
     {
         this.optionF = optionF;
     }
 
-    public String getOptionF() 
+    public String getOptionF()
     {
         return optionF;
     }
 
-    public void setOptionG(String optionG) 
+    public void setOptionG(String optionG)
     {
         this.optionG = optionG;
     }
 
-    public String getOptionG() 
+    public String getOptionG()
     {
         return optionG;
     }
 
-    public void setAnswer1(String answer1) 
+    public void setAnswer1(String answer1)
     {
         this.answer1 = answer1;
     }
 
-    public String getAnswer1() 
+    public String getAnswer1()
     {
         return answer1;
     }
 
-    public void setAnswer2(String answer2) 
+    public void setAnswer2(String answer2)
     {
         this.answer2 = answer2;
     }
 
-    public String getAnswer2() 
+    public String getAnswer2()
     {
         return answer2;
     }
 
-    public void setQtpye(String qtpye) 
+    public void setQtpye(String qtpye)
     {
         this.qtpye = qtpye;
     }
 
-    public String getQtpye() 
+    public String getQtpye()
     {
         return qtpye;
     }
 
-    public void setSubjectId(Long subjectId) 
+    public void setSubjectId(Long subjectId)
     {
         this.subjectId = subjectId;
     }
 
-    public Long getSubjectId() 
+    public Long getSubjectId()
     {
         return subjectId;
     }
 
-    public void setPaperId(Long paperId) 
+    public void setPaperId(Long paperId)
     {
         this.paperId = paperId;
     }
 
-    public Long getPaperId() 
+    public Long getPaperId()
     {
         return paperId;
     }
 
-    public void setKnowledgeId(Long knowledgeId) 
+    public void setKnowledgeId(Long knowledgeId)
     {
         this.knowledgeId = knowledgeId;
     }
 
-    public Long getKnowledgeId() 
+    public Long getKnowledgeId()
     {
         return knowledgeId;
     }
 
-    public void setDiff(BigDecimal diff) 
+    public void setDiff(BigDecimal diff)
     {
         this.diff = diff;
     }
 
-    public BigDecimal getDiff() 
+    public BigDecimal getDiff()
     {
         return diff;
     }
 
-    public void setSimilarity(Long similarity) 
+    public void setSimilarity(Long similarity)
     {
         this.similarity = similarity;
     }
 
-    public Long getSimilarity() 
+    public Long getSimilarity()
     {
         return similarity;
     }
 
-    public void setParse(String parse) 
+    public void setParse(String parse)
     {
         this.parse = parse;
     }
 
-    public String getParse() 
+    public String getParse()
     {
         return parse;
     }
 
-    public void setKnowId(Long knowId) 
+    public void setKnowId(Long knowId)
     {
         this.knowId = knowId;
     }
 
-    public Long getKnowId() 
+    public Long getKnowId()
     {
         return knowId;
     }
 
-    public void setGradeId(Long gradeId) 
+    public void setGradeId(Long gradeId)
     {
         this.gradeId = gradeId;
     }
 
-    public Long getGradeId() 
+    public Long getGradeId()
     {
         return gradeId;
     }
 
-    public void setKnowledges(String knowledges) 
+    public void setKnowledges(String knowledges)
     {
         this.knowledges = knowledges;
     }
 
-    public String getKnowledges() 
+    public String getKnowledges()
     {
         return knowledges;
     }
 
-    public void setArea(String area) 
+    public void setArea(String area)
     {
         this.area = area;
     }
 
-    public String getArea() 
+    public String getArea()
     {
         return area;
     }
 
-    public void setYear(Long year) 
+    public void setYear(Long year)
     {
         this.year = year;
     }
 
-    public Long getYear() 
+    public Long getYear()
     {
         return year;
     }
 
-    public void setPaperTpye(String paperTpye) 
+    public void setPaperTpye(String paperTpye)
     {
         this.paperTpye = paperTpye;
     }
 
-    public String getPaperTpye() 
+    public String getPaperTpye()
     {
         return paperTpye;
     }
 
-    public void setSource(String source) 
+    public void setSource(String source)
     {
         this.source = source;
     }
 
-    public String getSource() 
+    public String getSource()
     {
         return source;
     }
 
-    public void setFromSite(String fromSite) 
+    public void setFromSite(String fromSite)
     {
         this.fromSite = fromSite;
     }
 
-    public String getFromSite() 
+    public String getFromSite()
     {
         return fromSite;
     }
 
-    public void setIsSub(Integer isSub) 
+    public void setIsSub(Integer isSub)
     {
         this.isSub = isSub;
     }
 
-    public Integer getIsSub() 
+    public Integer getIsSub()
     {
         return isSub;
     }
 
-    public void setIsNormal(Integer isNormal) 
+    public void setIsNormal(Integer isNormal)
     {
         this.isNormal = isNormal;
     }
 
-    public Integer getIsNormal() 
+    public Integer getIsNormal()
     {
         return isNormal;
     }
 
-    public void setIsKonw(Integer isKonw) 
+    public void setIsKonw(Integer isKonw)
     {
         this.isKonw = isKonw;
     }
 
-    public Integer getIsKonw() 
+    public Integer getIsKonw()
     {
         return isKonw;
     }
 
-    public void setTiid(String tiid) 
+    public void setTiid(String tiid)
     {
         this.tiid = tiid;
     }
 
-    public String getTiid() 
+    public String getTiid()
     {
         return tiid;
     }
 
-    public void setMd5(String md5) 
+    public void setMd5(String md5)
     {
         this.md5 = md5;
     }
 
-    public String getMd5() 
+    public String getMd5()
     {
         return md5;
     }
 
-    public void setIsunique(Long isunique) 
+    public void setIsunique(Long isunique)
     {
         this.isunique = isunique;
     }
 
-    public Long getIsunique() 
+    public Long getIsunique()
     {
         return isunique;
     }
 
-    public void setMd52(String md52) 
+    public void setMd52(String md52)
     {
         this.md52 = md52;
     }
 
-    public String getMd52() 
+    public String getMd52()
     {
         return md52;
     }
 
-    public void setScore(BigDecimal score) 
+    public void setScore(BigDecimal score)
     {
         this.score = score;
     }
 
-    public BigDecimal getScore() 
+    public BigDecimal getScore()
     {
         return score;
     }
 
-    public void setOptions(String options) 
+    public void setOptions(String options)
     {
         this.options = options;
     }
 
-    public String getOptions() 
+    public String getOptions()
     {
         return options;
     }
 
-    public void setNumber(Long number) 
+    public void setNumber(Long number)
     {
         this.number = number;
     }
 
-    public Long getNumber() 
+    public Long getNumber()
     {
         return number;
     }
 
-    public void setPaperTypeTitle(String paperTypeTitle) 
+    public void setPaperTypeTitle(String paperTypeTitle)
     {
         this.paperTypeTitle = paperTypeTitle;
     }
 
-    public String getPaperTypeTitle() 
+    public String getPaperTypeTitle()
     {
         return paperTypeTitle;
     }
 
-    public void setOptions0(String options0) 
+    public void setOptions0(String options0)
     {
         this.options0 = options0;
     }
 
-    public String getOptions0() 
+    public String getOptions0()
     {
         return options0;
     }
 
-    public void setTitle0(String title0) 
+    public void setTitle0(String title0)
     {
         this.title0 = title0;
     }
 
-    public String getTitle0() 
+    public String getTitle0()
     {
         return title0;
     }
 
-    public void setTitle1(String title1) 
+    public void setTitle1(String title1)
     {
         this.title1 = title1;
     }
 
-    public String getTitle1() 
+    public String getTitle1()
     {
         return title1;
     }
 
-    public void setParse0(String parse0) 
+    public void setParse0(String parse0)
     {
         this.parse0 = parse0;
     }
 
-    public String getParse0() 
+    public String getParse0()
     {
         return parse0;
     }
 
-    public void setAnswer0(String answer0) 
+    public void setAnswer0(String answer0)
     {
         this.answer0 = answer0;
     }
 
-    public String getAnswer0() 
+    public String getAnswer0()
     {
         return answer0;
     }
 
-    public void setIsUpdate(Long isUpdate) 
+    public void setIsUpdate(Long isUpdate)
     {
         this.isUpdate = isUpdate;
     }
 
-    public Long getIsUpdate() 
+    public Long getIsUpdate()
     {
         return isUpdate;
     }
 
-    public void setIsSubType(String isSubType) 
+    public void setIsSubType(String isSubType)
     {
         this.isSubType = isSubType;
     }
 
-    public String getIsSubType() 
+    public String getIsSubType()
     {
         return isSubType;
     }

+ 10 - 8
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnPaperMapper.java

@@ -7,17 +7,17 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 /**
  * 试卷Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
-public interface LearnPaperMapper 
+public interface LearnPaperMapper
 {
     public List<LearnPaper> selectLearnPaperForStudent(@Param("studentId") Long studentId, @Param("status") Integer status);
 
     /**
      * 查询试卷
-     * 
+     *
      * @param id 试卷主键
      * @return 试卷
      */
@@ -25,7 +25,7 @@ public interface LearnPaperMapper
 
     /**
      * 查询试卷列表
-     * 
+     *
      * @param learnPaper 试卷
      * @return 试卷集合
      */
@@ -33,7 +33,7 @@ public interface LearnPaperMapper
 
     /**
      * 新增试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -41,7 +41,7 @@ public interface LearnPaperMapper
 
     /**
      * 修改试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -49,7 +49,7 @@ public interface LearnPaperMapper
 
     /**
      * 删除试卷
-     * 
+     *
      * @param id 试卷主键
      * @return 结果
      */
@@ -57,9 +57,11 @@ public interface LearnPaperMapper
 
     /**
      * 批量删除试卷
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteLearnPaperByIds(Long[] ids);
+
+    public List<LearnPaper> selectPapersListFromFavorites(LearnPaper papers);
 }

+ 11 - 8
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnQuestionsMapper.java

@@ -7,15 +7,15 @@ import com.ruoyi.learn.domain.LearnQuestions;
 
 /**
  * 试题Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
-public interface LearnQuestionsMapper 
+public interface LearnQuestionsMapper
 {
     /**
      * 查询试题
-     * 
+     *
      * @param id 试题主键
      * @return 试题
      */
@@ -23,7 +23,7 @@ public interface LearnQuestionsMapper
 
     /**
      * 查询试题列表
-     * 
+     *
      * @param learnQuestions 试题
      * @return 试题集合
      */
@@ -31,7 +31,7 @@ public interface LearnQuestionsMapper
 
     /**
      * 新增试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -39,7 +39,7 @@ public interface LearnQuestionsMapper
 
     /**
      * 修改试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -47,7 +47,7 @@ public interface LearnQuestionsMapper
 
     /**
      * 删除试题
-     * 
+     *
      * @param id 试题主键
      * @return 结果
      */
@@ -55,7 +55,7 @@ public interface LearnQuestionsMapper
 
     /**
      * 批量删除试题
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -67,4 +67,7 @@ public interface LearnQuestionsMapper
     public List<LearnQuestions> statByKnowledge(Map cond);
 
     public List<LearnQuestions> selectQuestionsForPaper(LearnQuestions cond);
+
+    public List<LearnQuestions> selectCollectedList(LearnQuestions questions);
+    public List<LearnQuestions> selectCollectInfo(Map<String, Object> map);
 }

+ 9 - 9
ie-system/src/main/java/com/ruoyi/learn/service/ILearnPaperService.java

@@ -5,15 +5,15 @@ import com.ruoyi.learn.domain.LearnPaper;
 
 /**
  * 试卷Service接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
-public interface ILearnPaperService 
+public interface ILearnPaperService
 {
     /**
      * 查询试卷
-     * 
+     *
      * @param id 试卷主键
      * @return 试卷
      */
@@ -21,15 +21,15 @@ public interface ILearnPaperService
 
     /**
      * 查询试卷列表
-     * 
+     *
      * @param learnPaper 试卷
      * @return 试卷集合
      */
     public List<LearnPaper> selectLearnPaperList(LearnPaper learnPaper);
-
+    public List<LearnPaper> selectPapersListFromFavorites(LearnPaper papers);
     /**
      * 新增试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ILearnPaperService
 
     /**
      * 修改试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ILearnPaperService
 
     /**
      * 批量删除试卷
-     * 
+     *
      * @param ids 需要删除的试卷主键集合
      * @return 结果
      */
@@ -53,7 +53,7 @@ public interface ILearnPaperService
 
     /**
      * 删除试卷信息
-     * 
+     *
      * @param id 试卷主键
      * @return 结果
      */

+ 12 - 8
ie-system/src/main/java/com/ruoyi/learn/service/ILearnQuestionsService.java

@@ -5,15 +5,15 @@ import com.ruoyi.learn.domain.LearnQuestions;
 
 /**
  * 试题Service接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
-public interface ILearnQuestionsService 
+public interface ILearnQuestionsService
 {
     /**
      * 查询试题
-     * 
+     *
      * @param id 试题主键
      * @return 试题
      */
@@ -21,7 +21,7 @@ public interface ILearnQuestionsService
 
     /**
      * 查询试题列表
-     * 
+     *
      * @param learnQuestions 试题
      * @return 试题集合
      */
@@ -29,7 +29,7 @@ public interface ILearnQuestionsService
 
     /**
      * 新增试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ILearnQuestionsService
 
     /**
      * 修改试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ILearnQuestionsService
 
     /**
      * 批量删除试题
-     * 
+     *
      * @param ids 需要删除的试题主键集合
      * @return 结果
      */
@@ -53,9 +53,13 @@ public interface ILearnQuestionsService
 
     /**
      * 删除试题信息
-     * 
+     *
      * @param id 试题主键
      * @return 结果
      */
     public int deleteLearnQuestionsById(Long id);
+
+    public List<LearnQuestions> selectCollectedList(LearnQuestions questions);
+
+    public void fillCollectInfo(Long userId, List<LearnQuestions> questions);
 }

+ 13 - 8
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnPaperServiceImpl.java

@@ -10,19 +10,19 @@ import com.ruoyi.learn.service.ILearnPaperService;
 
 /**
  * 试卷Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
 @Service
-public class LearnPaperServiceImpl implements ILearnPaperService 
+public class LearnPaperServiceImpl implements ILearnPaperService
 {
     @Autowired
     private LearnPaperMapper learnPaperMapper;
 
     /**
      * 查询试卷
-     * 
+     *
      * @param id 试卷主键
      * @return 试卷
      */
@@ -34,7 +34,7 @@ public class LearnPaperServiceImpl implements ILearnPaperService
 
     /**
      * 查询试卷列表
-     * 
+     *
      * @param learnPaper 试卷
      * @return 试卷
      */
@@ -44,9 +44,14 @@ public class LearnPaperServiceImpl implements ILearnPaperService
         return learnPaperMapper.selectLearnPaperList(learnPaper);
     }
 
+    @Override
+    public List<LearnPaper> selectPapersListFromFavorites(LearnPaper papers) {
+        return learnPaperMapper.selectPapersListFromFavorites(papers);
+    }
+
     /**
      * 新增试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -59,7 +64,7 @@ public class LearnPaperServiceImpl implements ILearnPaperService
 
     /**
      * 修改试卷
-     * 
+     *
      * @param learnPaper 试卷
      * @return 结果
      */
@@ -71,7 +76,7 @@ public class LearnPaperServiceImpl implements ILearnPaperService
 
     /**
      * 批量删除试卷
-     * 
+     *
      * @param ids 需要删除的试卷主键
      * @return 结果
      */
@@ -83,7 +88,7 @@ public class LearnPaperServiceImpl implements ILearnPaperService
 
     /**
      * 删除试卷信息
-     * 
+     *
      * @param id 试卷主键
      * @return 结果
      */

+ 35 - 8
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnQuestionsServiceImpl.java

@@ -1,7 +1,13 @@
 package com.ruoyi.learn.service.impl;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 import com.ruoyi.common.utils.DateUtils;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.learn.mapper.LearnQuestionsMapper;
@@ -10,19 +16,19 @@ import com.ruoyi.learn.service.ILearnQuestionsService;
 
 /**
  * 试题Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2025-09-18
  */
 @Service
-public class LearnQuestionsServiceImpl implements ILearnQuestionsService 
+public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 {
     @Autowired
     private LearnQuestionsMapper learnQuestionsMapper;
 
     /**
      * 查询试题
-     * 
+     *
      * @param id 试题主键
      * @return 试题
      */
@@ -34,7 +40,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     /**
      * 查询试题列表
-     * 
+     *
      * @param learnQuestions 试题
      * @return 试题
      */
@@ -46,7 +52,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     /**
      * 新增试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -59,7 +65,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     /**
      * 修改试题
-     * 
+     *
      * @param learnQuestions 试题
      * @return 结果
      */
@@ -71,7 +77,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     /**
      * 批量删除试题
-     * 
+     *
      * @param ids 需要删除的试题主键
      * @return 结果
      */
@@ -83,7 +89,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     /**
      * 删除试题信息
-     * 
+     *
      * @param id 试题主键
      * @return 结果
      */
@@ -92,4 +98,25 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
     {
         return learnQuestionsMapper.deleteLearnQuestionsById(id);
     }
+
+    @Override
+    public List<LearnQuestions> selectCollectedList(LearnQuestions questions) {
+        return learnQuestionsMapper.selectCollectedList(questions);
+    }
+
+    @Override
+    public void fillCollectInfo(Long userId, List<LearnQuestions> questions) {
+        if (CollectionUtils.isEmpty(questions)) {
+            return;
+        }
+        List<Long> ids = questions.stream().map(LearnQuestions::getId).collect(Collectors.toList());
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("userId", userId);
+        map.put("ids", ids);
+        List<LearnQuestions> collectInfos = learnQuestionsMapper.selectCollectInfo(map);
+        Set<Long> collected = collectInfos.stream().map(LearnQuestions::getId).collect(Collectors.toSet());
+        questions.forEach(e -> {
+            e.setCollect(collected.contains(e.getId()));
+        });
+    }
 }

+ 13 - 5
ie-system/src/main/resources/mapper/learn/LearnPaperMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.learn.mapper.LearnPaperMapper">
-    
+
     <resultMap type="LearnPaper" id="LearnPaperResult">
         <result property="id"    column="id"    />
         <result property="subjectId"    column="subjectId"    />
@@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLearnPaperList" parameterType="LearnPaper" resultMap="LearnPaperResult">
         <include refid="selectLearnPaperVo"/>
-        <where>  
+        <where>
             <if test="subjectId != null "> and subjectId = #{subjectId}</if>
             <if test="paperName != null  and paperName != ''"> and paperName like concat('%', #{paperName}, '%')</if>
             <if test="year != null "> and year = #{year}</if>
@@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
 
     </select>
-    
+
     <select id="selectLearnPaperById" parameterType="Long" resultMap="LearnPaperResult">
         <include refid="selectLearnPaperVo"/>
         where id = #{id}
@@ -132,9 +132,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLearnPaperByIds" parameterType="String">
-        delete from learn_paper where id in 
+        delete from learn_paper where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+
+    <select id="selectPapersListFromFavorites" parameterType="LearnPaper" resultMap="LearnPaperResult">
+        select p.*,0 readNum from b_customer_favorites f
+        left join learn_paper p on f.refId = p.id
+        where f.type = 'paper' and f.customercode = #{examineeId} and f.course = #{subjectId} <if test="collect "> and f.status = 1</if>
+    </select>
+
+
+</mapper>

+ 23 - 5
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.learn.mapper.LearnQuestionsMapper">
-    
+
     <resultMap type="LearnQuestions" id="LearnQuestionsResult">
         <result property="id"    column="id"    />
         <result property="title"    column="title"    />
@@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLearnQuestionsList" parameterType="LearnQuestions" resultMap="LearnQuestionsResult">
         <include refid="selectLearnQuestionsVo"/>
-        <where>  
+        <where>
             <if test="title != null  and title != ''"> and title = #{title}</if>
             <if test="optionA != null  and optionA != ''"> and option_a = #{optionA}</if>
             <if test="optionB != null  and optionB != ''"> and option_b = #{optionB}</if>
@@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSubType != null  and isSubType != ''"> and isSubType = #{isSubType}</if>
         </where>
     </select>
-    
+
     <select id="selectLearnQuestionsById" parameterType="Long" resultMap="LearnQuestionsResult">
         <include refid="selectLearnQuestionsVo"/>
         where id = #{id}
@@ -262,7 +262,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLearnQuestionsByIds" parameterType="String">
-        delete from learn_questions where id in 
+        delete from learn_questions where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
@@ -317,4 +317,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         limit #{number}, 500
     </select>
 
-</mapper>
+    <select id="selectCollectedList"  parameterType="LearnQuestions" resultMap="LearnQuestionsResult">
+        select q.* from mxjb_question_collection c
+        left join learn_questions q on c.question_id = q.id
+        left join dz_subject s on q.subjectId = s.subject_id
+        where c.user_id = #{userId}
+        and q.subjectId = #{subjectId}
+    </select>
+
+    <select id="selectCollectInfo"  parameterType="java.util.HashMap" resultMap="LearnQuestionsResult">
+        SELECT q.id from mxjb_question_collection c
+        left join questions q on c.question_id = q.id
+        where user_id = #{userId}
+        and c.question_id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
+
+</mapper>