diff --git a/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java b/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java index f2fe69b..bbae24e 100644 --- a/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java +++ b/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java @@ -2,7 +2,7 @@ package com.guo.learningprogresstracker.controller; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.guo.learningprogresstracker.dto.request.EndedStudySessionRequest; -import com.guo.learningprogresstracker.dto.response.StudySessionResponce; +import com.guo.learningprogresstracker.dto.response.StudySessionResponse; import com.guo.learningprogresstracker.entity.CommonResult; import com.guo.learningprogresstracker.entity.StudySessionsEntity; import com.guo.learningprogresstracker.exception.ErrorParameterException; @@ -41,12 +41,12 @@ public class StudySessionController { * 通过sessionNum获取一个【学习会话】 */ @GetMapping("/{sessionNum}") - public CommonResult getStudySessionBySessionNum(@NotEmpty(message = "sessionNum不可为空") @PathVariable String sessionNum) throws ErrorParameterException { + public CommonResult getStudySessionBySessionNum(@NotEmpty(message = "sessionNum不可为空") @PathVariable String sessionNum) throws ErrorParameterException { StudySessionsEntity studySessionsEntity = studySessionsServiceImpl.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class) .eq(StudySessionsEntity::getSessionNum, sessionNum)) .orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在")); - StudySessionResponce studySessionResponce = StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity); - return CommonResult.success(studySessionResponce); + StudySessionResponse studySessionResponse = StudySessionConvert.MAPPER.toStudySessionResponse(studySessionsEntity); + return CommonResult.success(studySessionResponse); } /** diff --git a/src/main/java/com/guo/learningprogresstracker/controller/TaskController.java b/src/main/java/com/guo/learningprogresstracker/controller/TaskController.java index 0fdbf81..3e427e8 100644 --- a/src/main/java/com/guo/learningprogresstracker/controller/TaskController.java +++ b/src/main/java/com/guo/learningprogresstracker/controller/TaskController.java @@ -1,10 +1,9 @@ package com.guo.learningprogresstracker.controller; -import cn.dev33.satoken.stp.StpUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.guo.learningprogresstracker.common.Ops; import com.guo.learningprogresstracker.dto.TaskInfo; -import com.guo.learningprogresstracker.dto.response.StudySessionResponce; +import com.guo.learningprogresstracker.dto.response.StudySessionResponse; import com.guo.learningprogresstracker.dto.response.TaskInfoResponse; import com.guo.learningprogresstracker.entity.CommonResult; import com.guo.learningprogresstracker.dto.request.TaskRequest; @@ -80,9 +79,9 @@ public class TaskController { * 开始或继续一个【学习会话】 */ @GetMapping("/{taskNum}/study-sessions/start-or-continue") - public CommonResult startOrContinueStudySession(@NotEmpty(message = "taskNum不可为空") + public CommonResult startOrContinueStudySession(@NotEmpty(message = "taskNum不可为空") @PathVariable String taskNum) throws NotFindEntitiesException { - StudySessionResponce response = studySessionsServiceImpl.startOrContinueStudySession(taskNum); + StudySessionResponse response = studySessionsServiceImpl.startOrContinueStudySession(taskNum); return CommonResult.success(response); } @@ -91,9 +90,9 @@ public class TaskController { * 通过学习任务num获取该任务的未结束会话 */ @GetMapping("/{taskNum}/not-ended-study-session") - public CommonResult getNotEndedStudySessionByTaskNum(@NotEmpty(message = "taskNum不可为空") + public CommonResult getNotEndedStudySessionByTaskNum(@NotEmpty(message = "taskNum不可为空") @PathVariable String taskNum) throws ErrorParameterException { - StudySessionResponce response = studySessionsServiceImpl.getNotEndedStudySessionByTaskNum(taskNum); + StudySessionResponse response = studySessionsServiceImpl.getNotEndedStudySessionByTaskNum(taskNum); return CommonResult.success(response); } } diff --git a/src/main/java/com/guo/learningprogresstracker/dto/StudySessionsDto.java b/src/main/java/com/guo/learningprogresstracker/dto/StudySessionsDto.java new file mode 100644 index 0000000..49d8b37 --- /dev/null +++ b/src/main/java/com/guo/learningprogresstracker/dto/StudySessionsDto.java @@ -0,0 +1,53 @@ +package com.guo.learningprogresstracker.dto; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class StudySessionsDto { + + private String sessionNum; + + /** + * 任务名称 + */ + private String taskName; + + /** + * 任务编号 + */ + private String taskNum; + + /** + * 学习开始时间 + */ + private LocalDateTime startTime; + + private LocalDateTime lastStartTime; + + /** + * 学习结束时间 + */ + private LocalDateTime endTime; + + /** + * 实际使用时间(秒) + */ + private double actualTime; + + /** + * 有效学习时间(秒) + */ + private double effectiveTime; + + /** + * 有效时间比 + */ + private double effectivenessRatio; + + /** + * 学习会话的状态(进行中、暂停、已结束) + */ + private String sessionState; +} diff --git a/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponce.java b/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java similarity index 82% rename from src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponce.java rename to src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java index ea01c44..d2fb816 100644 --- a/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponce.java +++ b/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java @@ -6,12 +6,16 @@ import lombok.Data; import java.time.LocalDateTime; @Data -public class StudySessionResponce { +public class StudySessionResponse { + @Schema(description = "会话编号") private String sessionNum; - private String taskNum; + @Schema(description = "任务名称") + private String taskName; + @Schema(description = "任务编号") + private String taskNum; @Schema(description = "学习开始时间") private LocalDateTime startTime; diff --git a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java index 20ddcda..184602a 100644 --- a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java +++ b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java @@ -29,7 +29,7 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { private String sessionNum; /** - * + * 任务编号 */ @TableField(value = "task_num") private String taskNum; diff --git a/src/main/java/com/guo/learningprogresstracker/mapStruct/StudySessionConvert.java b/src/main/java/com/guo/learningprogresstracker/mapStruct/StudySessionConvert.java index c816a8c..d8b606f 100644 --- a/src/main/java/com/guo/learningprogresstracker/mapStruct/StudySessionConvert.java +++ b/src/main/java/com/guo/learningprogresstracker/mapStruct/StudySessionConvert.java @@ -1,6 +1,7 @@ package com.guo.learningprogresstracker.mapStruct; -import com.guo.learningprogresstracker.dto.response.StudySessionResponce; +import com.guo.learningprogresstracker.dto.StudySessionsDto; +import com.guo.learningprogresstracker.dto.response.StudySessionResponse; import com.guo.learningprogresstracker.entity.StudySessionsEntity; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; @@ -11,5 +12,7 @@ public interface StudySessionConvert { StudySessionConvert MAPPER = Mappers.getMapper(StudySessionConvert.class); - StudySessionResponce toStudySessionResponce(StudySessionsEntity studySessionsEntity); + StudySessionResponse toStudySessionResponse(StudySessionsEntity studySessionsEntity); + + StudySessionResponse toStudySessionResponse(StudySessionsDto dto); } diff --git a/src/main/java/com/guo/learningprogresstracker/mapper/StudyReportsMapper.java b/src/main/java/com/guo/learningprogresstracker/mapper/StudyReportsMapper.java index 24e08db..9c496c4 100644 --- a/src/main/java/com/guo/learningprogresstracker/mapper/StudyReportsMapper.java +++ b/src/main/java/com/guo/learningprogresstracker/mapper/StudyReportsMapper.java @@ -1,8 +1,10 @@ package com.guo.learningprogresstracker.mapper; +import com.guo.learningprogresstracker.dto.StudySessionsDto; import com.guo.learningprogresstracker.entity.StudyReportsEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * @author guo @@ -13,6 +15,7 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface StudyReportsMapper extends BaseMapper { + StudySessionsDto getNotEndedStudySessionDtoByTaskNum(@Param("task_num") String taskNum); } diff --git a/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java b/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java index ddbb3a1..b27bd49 100644 --- a/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java +++ b/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java @@ -1,6 +1,6 @@ package com.guo.learningprogresstracker.service; -import com.guo.learningprogresstracker.dto.response.StudySessionResponce; +import com.guo.learningprogresstracker.dto.response.StudySessionResponse; import com.guo.learningprogresstracker.entity.StudySessionsEntity; import com.baomidou.mybatisplus.extension.service.IService; import com.guo.learningprogresstracker.exception.ErrorParameterException; @@ -14,7 +14,7 @@ import java.util.ArrayList; */ public interface StudySessionsService extends IService { - StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException; + StudySessionResponse getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException; ArrayList getAllFragments(String sessionNum) throws ErrorParameterException; diff --git a/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java b/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java index a6fd742..d1f5ee3 100644 --- a/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java +++ b/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java @@ -2,7 +2,8 @@ package com.guo.learningprogresstracker.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.guo.learningprogresstracker.dto.response.StudySessionResponce; +import com.guo.learningprogresstracker.dto.StudySessionsDto; +import com.guo.learningprogresstracker.dto.response.StudySessionResponse; import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity; import com.guo.learningprogresstracker.entity.StudyReportsEntity; import com.guo.learningprogresstracker.entity.StudySessionsEntity; @@ -38,7 +39,7 @@ public class StudySessionsServiceImpl extends ServiceImpl new NotFindEntitiesException(String.format("[%s]不存在",taskNum))); @@ -53,13 +54,13 @@ public class StudySessionsServiceImpl extends ServiceImpl new ErrorParameterException("任务[" + taskNum + "]不存在进行中或暂停中的会话")); - return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity); + return StudySessionConvert.MAPPER.toStudySessionResponse(dto); } @Override diff --git a/src/main/resources/mapper/StudyReportsMapper.xml b/src/main/resources/mapper/StudyReportsMapper.xml index bac99eb..1d63e81 100644 --- a/src/main/resources/mapper/StudyReportsMapper.xml +++ b/src/main/resources/mapper/StudyReportsMapper.xml @@ -3,20 +3,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - + + + + + - report_id,session_id,content, - created_time,created_by,last_modified_time, + report_id, + session_id, + content, + created_time, + created_by, + last_modified_time, last_modified_by + +