From fa0ff84bf9bc2934364ee1569a2d1b71f6b2e52f Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 20 Aug 2024 17:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=AF=E5=90=A6=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KnowledgeLearningRecordMapper.java | 2 +- .../KnowledgeLearningRecordServiceImpl.java | 23 +++++++++- .../RecordKnowledgeFinishServiceImpl.java | 43 +++++++++++++++++++ .../RecordResourceFinishServiceImpl.java | 32 ++++++++++++++ .../ResourceLearningRecordServiceImpl.java | 32 +++++++------- .../IRecordKnowledgeFinishService.java | 7 +++ .../records/IRecordResourceFinishService.java | 4 ++ 7 files changed, 124 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java index 2ddda90..d02a1f0 100644 --- a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java +++ b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java @@ -20,7 +20,7 @@ import java.util.List; */ public interface KnowledgeLearningRecordMapper extends BaseMapper { - @Select("SELECT knowledge_id FROM knowledge_learning_record WHERE user_id = #{userId} GROUP BY knowledge_id") + @Select("SELECT knowledge_id FROM record_knowledge_learning WHERE user_id = #{userId} GROUP BY knowledge_id") List selectDistinctKnowledgeIdsByUser(@Param("userId") String userId); List queryStudyKnowledgeMaxNumber(); diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index 04ba60b..b120f8a 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -15,6 +15,7 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; import com.teaching.backend.model.vo.knowGraph.KnowVO; import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo; @@ -50,6 +51,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { @@ -78,7 +81,14 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl getPage(int pagenum, int pagesize, String userId, String courseId) { //格式化时间 @@ -122,6 +139,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl implements IRecordKnowledgeFinishService { + @Override + public void addFinish(KnowledgeLearningRecord knowledgeLearningRecord) { + RecordKnowledgeFinish recordKnowledgeFinish = new RecordKnowledgeFinish(); + recordKnowledgeFinish.setUserId(knowledgeLearningRecord.getUserId()); + recordKnowledgeFinish.setCourseId(knowledgeLearningRecord.getCoursesId()); + recordKnowledgeFinish.setKnowledgeId(knowledgeLearningRecord.getKnowledgeId()); + recordKnowledgeFinish.setFinish(knowledgeLearningRecord.getFinish()); + save(recordKnowledgeFinish); + } + + @Override + public void addFinish(ResourceLearningRecord resourceLearningRecord) { + RecordKnowledgeFinish recordKnowledgeFinish = new RecordKnowledgeFinish(); + recordKnowledgeFinish.setUserId(resourceLearningRecord.getUserId()); + recordKnowledgeFinish.setCourseId(resourceLearningRecord.getCoursesId()); + recordKnowledgeFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId()); + recordKnowledgeFinish.setFinish(resourceLearningRecord.getFinish()); + save(recordKnowledgeFinish); + } + + @Override + public void editFinish(KnowledgeLearningRecord knowledgeLearningRecord) { + //设置完成状态 + RecordKnowledgeFinish one = query() + .eq("course_id", knowledgeLearningRecord.getCoursesId()) + .eq("knowledge_id", knowledgeLearningRecord.getKnowledgeId()) + .eq("user_id", knowledgeLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } + + @Override + public void editFinish(ResourceLearningRecord resourceLearningRecord) { + //设置完成状态 + RecordKnowledgeFinish one = query() + .eq("course_id", resourceLearningRecord.getCoursesId()) + .eq("knowledge_id", resourceLearningRecord.getKnowledgeId()) + .eq("user_id", resourceLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java index ba72c52..6892a5b 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java @@ -3,10 +3,14 @@ package com.teaching.backend.service.impl.records; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.mapper.records.RecordResourceFinishMapper; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; import com.teaching.backend.model.entity.records.RecordResourceFinish; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; import com.teaching.backend.service.records.IRecordResourceFinishService; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + /** *

* 服务实现类 @@ -18,4 +22,32 @@ import org.springframework.stereotype.Service; @Service public class RecordResourceFinishServiceImpl extends ServiceImpl implements IRecordResourceFinishService { + @Resource + private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService; + @Override + public void addFinish(ResourceLearningRecord resourceLearningRecord) { + //如果资源学习完成,知识点也改为完成 + if (resourceLearningRecord.getFinish() == 1){ + recordKnowledgeFinishService.editFinish(resourceLearningRecord); + } + RecordResourceFinish recordResourceFinish = new RecordResourceFinish(); + recordResourceFinish.setUserId(resourceLearningRecord.getUserId()); + recordResourceFinish.setCourseId(resourceLearningRecord.getCoursesId()); + recordResourceFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId()); + recordResourceFinish.setResourceId(resourceLearningRecord.getResourceId()); + recordResourceFinish.setFinish(resourceLearningRecord.getFinish()); + System.out.println(recordResourceFinish); + save(recordResourceFinish); + } + + @Override + public void editFinish(ResourceLearningRecord resourceLearningRecord) { + RecordResourceFinish one = query() + .eq("course_id", resourceLearningRecord.getCoursesId()) + .eq("knowledge_id", resourceLearningRecord.getKnowledgeId()) + .eq("resource_id",resourceLearningRecord.getResourceId()) + .eq("user_id", resourceLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java index b5121d8..bf57112 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java @@ -37,7 +37,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { @@ -68,6 +68,13 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl @@ -13,5 +16,9 @@ import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; * @since 2024-08-20 */ public interface IRecordKnowledgeFinishService extends IService { + void addFinish(KnowledgeLearningRecord knowledgeLearningRecord); + void addFinish(ResourceLearningRecord resourceLearningRecord); + void editFinish(KnowledgeLearningRecord knowledgeLearningRecord); + void editFinish(ResourceLearningRecord resourceLearningRecord); } diff --git a/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java index bd6666e..5e020f3 100644 --- a/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java +++ b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java @@ -2,7 +2,9 @@ package com.teaching.backend.service.records; import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; import com.teaching.backend.model.entity.records.RecordResourceFinish; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; /** *

@@ -13,5 +15,7 @@ import com.teaching.backend.model.entity.records.RecordResourceFinish; * @since 2024-08-20 */ public interface IRecordResourceFinishService extends IService { + void addFinish(ResourceLearningRecord resourceLearningRecord); + void editFinish(ResourceLearningRecord resourceLearningRecord); }