Merge branch 'dev'
# Conflicts: # Jenkinsfile # src/main/resources/application-prod.yml
This commit is contained in:
@@ -33,11 +33,10 @@ public class LoginController {
|
||||
return CommonResult.success("登录成功!", token);
|
||||
}
|
||||
|
||||
@Operation(summary = "退出登录API-功能未完成")
|
||||
@PostMapping("/loingOut")
|
||||
public CommonResult<Void> loingOut(@RequestBody LoginBody loginBody) throws AppException {
|
||||
//todo loginOut 退出登录API
|
||||
// loginService.loginOut();
|
||||
@Operation(summary = "退出登录API")
|
||||
@PostMapping("/logout")
|
||||
public CommonResult<Void> logout() {
|
||||
loginService.logout();
|
||||
return CommonResult.success("已登出");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -28,11 +28,11 @@ public class StudySessionResponse {
|
||||
private LocalDateTime endTime;
|
||||
|
||||
|
||||
@Schema(description = "实际使用时间(分钟)")
|
||||
@Schema(description = "实际使用时间(秒)")
|
||||
private double actualTime;
|
||||
|
||||
|
||||
@Schema(description = "有效学习时间(分钟)")
|
||||
@Schema(description = "有效学习时间(秒)")
|
||||
private double effectiveTime;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StudySessionResponse {
|
||||
@Schema(description = "学习会话的状态(进行中、暂停、已结束)")
|
||||
private String sessionState;
|
||||
|
||||
@Schema(description = "倒计时开始位置(S)")
|
||||
@Schema(description = "倒计时指针位置(毫秒)")
|
||||
private double pointerPosition;
|
||||
|
||||
@Schema(description = "系统提示")
|
||||
|
||||
@@ -95,6 +95,8 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
||||
StudySessionsEntity studySessionsEntity = new StudySessionsEntity();
|
||||
studySessionsEntity.setSessionNum(GenerateNumTool.generateNum("SESSION"));
|
||||
studySessionsEntity.setStartTime(LocalDateTime.now());
|
||||
studySessionsEntity.setLastStartTime(LocalDateTime.now());
|
||||
studySessionsEntity.setPointerPosition(WORK_DURATION * 60 * 1000L);
|
||||
studySessionsEntity.setLastModifiedTime(LocalDateTime.now());
|
||||
studySessionsEntity.setSessionState(StudySessionStateEnum.ONGOING.name());
|
||||
return studySessionsEntity;
|
||||
@@ -150,13 +152,7 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public boolean isFirstRun() {
|
||||
if (ObjectUtils.isEmpty(this.lastStartTime)) {
|
||||
return false;
|
||||
} else if (this.lastStartTime.equals(this.startTime)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.isEmpty(this.pointerPosition);
|
||||
}
|
||||
|
||||
|
||||
@@ -187,10 +183,13 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
||||
|
||||
case ONGOING:
|
||||
long elapsedMillis = Duration.between(lastStartTime, LocalDateTime.now()).toMillis();
|
||||
long newPointerPosition = pointerPosition - elapsedMillis;
|
||||
long basePointerPosition = ObjectUtils.isEmpty(pointerPosition)
|
||||
? WORK_DURATION * 60 * 1000L
|
||||
: pointerPosition;
|
||||
long newPointerPosition = basePointerPosition - elapsedMillis;
|
||||
if (newPointerPosition <= 0) {
|
||||
// 如果循环已经结束,则需要重置指针位置
|
||||
this.pointerPosition = WORK_DURATION * 1000L;
|
||||
this.pointerPosition = WORK_DURATION * 60 * 1000L;
|
||||
} else {
|
||||
this.pointerPosition = newPointerPosition;
|
||||
}
|
||||
|
||||
@@ -5,4 +5,6 @@ import com.guo.learningprogresstracker.exception.AppException;
|
||||
public interface LoginService {
|
||||
|
||||
String login(String userId) throws AppException;
|
||||
|
||||
void logout();
|
||||
}
|
||||
|
||||
@@ -3,14 +3,10 @@ package com.guo.learningprogresstracker.service.impl;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.guo.learningprogresstracker.exception.AppException;
|
||||
import com.guo.learningprogresstracker.service.LoginService;
|
||||
import com.guo.learningprogresstracker.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public String login(String userId) throws AppException {
|
||||
@@ -18,4 +14,9 @@ public class LoginServiceImpl implements LoginService {
|
||||
//todo Token只在此处使用了,属于后续优化点
|
||||
return StpUtil.getTokenInfo().getTokenValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() {
|
||||
StpUtil.logout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,17 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
@Override
|
||||
public void updateTask(String taskId, TaskRequest updatedTask) {
|
||||
TaskEntity taskEntity = TaskConvert.MAPPER.taskRequestToTaskEntity(updatedTask);
|
||||
this.updateById(taskEntity);
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(taskId);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("任务ID格式错误: " + taskId);
|
||||
}
|
||||
taskEntity.setId(id);
|
||||
boolean updated = this.updateById(taskEntity);
|
||||
if (!updated) {
|
||||
throw new IllegalArgumentException("任务不存在或更新失败: " + taskId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,4 +96,3 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
# 配置数据库
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://mysql8:3306/learning_progress_tracker?allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://mysql:3306/learning_progress_tracker?allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: GUOxy5157
|
||||
server:
|
||||
|
||||
@@ -2,17 +2,18 @@ spring:
|
||||
# 配置数据库
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/learning_progress_tracker?characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://39.105.149.197:8109/learning_progress_tracker?allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password:
|
||||
password: GUOxy5157
|
||||
server:
|
||||
port: 5157
|
||||
|
||||
cors:
|
||||
allowCredentials: true
|
||||
allowed-origins:
|
||||
- http://localhost:5158
|
||||
- http://192.168.123.199:5158
|
||||
- '*'
|
||||
|
||||
sa-token:
|
||||
cookie:
|
||||
secure: false
|
||||
sameSite: Lax
|
||||
@@ -26,6 +26,8 @@
|
||||
from study_sessions ss
|
||||
left join tasks t on ss.task_num = t.task_num and ss.session_state != 'ENDED' and ss.deleted = 0
|
||||
where t.deleted = 0
|
||||
and t.task_num = ${task_num}
|
||||
and t.task_num = #{task_num}
|
||||
order by ss.last_modified_time desc, ss.created_time desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user