feat: 新增碎片更新和会话查询的Service实现

- StudyReportFragmentsService 接口新增 updateFragments 和 getFragmentsBySession 方法
- ServiceImpl 实现碎片更新(校验存在性后更新)和按会话编号查询碎片列表
This commit is contained in:
2026-05-30 15:50:34 +08:00
parent e1cd5d5b82
commit 487b38e8b0
2 changed files with 29 additions and 0 deletions
@@ -1,10 +1,13 @@
package com.guo.learningprogresstracker.service; package com.guo.learningprogresstracker.service;
import com.guo.learningprogresstracker.dto.request.CreateFragmentsRequest; import com.guo.learningprogresstracker.dto.request.CreateFragmentsRequest;
import com.guo.learningprogresstracker.dto.request.UpdateFragmentsRequest;
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity; import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.guo.learningprogresstracker.exception.NotFindEntitiesException; import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
import java.util.List;
/** /**
* @author guo * @author guo
* @description 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service * @description 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service
@@ -13,4 +16,8 @@ import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
public interface StudyReportFragmentsService extends IService<StudyReportFragmentsEntity> { public interface StudyReportFragmentsService extends IService<StudyReportFragmentsEntity> {
void createFragments(CreateFragmentsRequest request) throws NotFindEntitiesException; void createFragments(CreateFragmentsRequest request) throws NotFindEntitiesException;
void updateFragments(Integer id, UpdateFragmentsRequest request) throws NotFindEntitiesException;
List<StudyReportFragmentsEntity> getFragmentsBySession(String sessionNum);
} }
@@ -3,6 +3,7 @@ package com.guo.learningprogresstracker.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guo.learningprogresstracker.dto.request.CreateFragmentsRequest; import com.guo.learningprogresstracker.dto.request.CreateFragmentsRequest;
import com.guo.learningprogresstracker.dto.request.UpdateFragmentsRequest;
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity; import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
import com.guo.learningprogresstracker.entity.StudySessionsEntity; import com.guo.learningprogresstracker.entity.StudySessionsEntity;
import com.guo.learningprogresstracker.exception.NotFindEntitiesException; import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
@@ -13,6 +14,8 @@ import com.guo.learningprogresstracker.mapper.StudyReportFragmentsMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service实现 * 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service实现
*/ */
@@ -34,4 +37,23 @@ public class StudyReportFragmentsServiceImpl extends ServiceImpl<StudyReportFrag
} }
this.save(entity); this.save(entity);
} }
@Override
public void updateFragments(Integer id, UpdateFragmentsRequest request) throws NotFindEntitiesException {
StudyReportFragmentsEntity existing = this.getById(id);
if (existing == null) {
throw new NotFindEntitiesException(String.format("未能找到学习残片id[%d]", id));
}
StudyReportFragmentsEntity entity = FragmentsConvert.MAPPER.toFragmentsEntity(request);
entity.setId(id);
this.updateById(entity);
}
@Override
public List<StudyReportFragmentsEntity> getFragmentsBySession(String sessionNum) {
return this.list(
Wrappers.lambdaQuery(StudyReportFragmentsEntity.class)
.eq(StudyReportFragmentsEntity::getSessionNum, sessionNum)
.orderByAsc(StudyReportFragmentsEntity::getCreatedTime));
}
} }