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);
|
return CommonResult.success("登录成功!", token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "退出登录API-功能未完成")
|
@Operation(summary = "退出登录API")
|
||||||
@PostMapping("/loingOut")
|
@PostMapping("/logout")
|
||||||
public CommonResult<Void> loingOut(@RequestBody LoginBody loginBody) throws AppException {
|
public CommonResult<Void> logout() {
|
||||||
//todo loginOut 退出登录API
|
loginService.logout();
|
||||||
// loginService.loginOut();
|
|
||||||
return CommonResult.success("已登出");
|
return CommonResult.success("已登出");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -28,11 +28,11 @@ public class StudySessionResponse {
|
|||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "实际使用时间(分钟)")
|
@Schema(description = "实际使用时间(秒)")
|
||||||
private double actualTime;
|
private double actualTime;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "有效学习时间(分钟)")
|
@Schema(description = "有效学习时间(秒)")
|
||||||
private double effectiveTime;
|
private double effectiveTime;
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class StudySessionResponse {
|
|||||||
@Schema(description = "学习会话的状态(进行中、暂停、已结束)")
|
@Schema(description = "学习会话的状态(进行中、暂停、已结束)")
|
||||||
private String sessionState;
|
private String sessionState;
|
||||||
|
|
||||||
@Schema(description = "倒计时开始位置(S)")
|
@Schema(description = "倒计时指针位置(毫秒)")
|
||||||
private double pointerPosition;
|
private double pointerPosition;
|
||||||
|
|
||||||
@Schema(description = "系统提示")
|
@Schema(description = "系统提示")
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
StudySessionsEntity studySessionsEntity = new StudySessionsEntity();
|
StudySessionsEntity studySessionsEntity = new StudySessionsEntity();
|
||||||
studySessionsEntity.setSessionNum(GenerateNumTool.generateNum("SESSION"));
|
studySessionsEntity.setSessionNum(GenerateNumTool.generateNum("SESSION"));
|
||||||
studySessionsEntity.setStartTime(LocalDateTime.now());
|
studySessionsEntity.setStartTime(LocalDateTime.now());
|
||||||
|
studySessionsEntity.setLastStartTime(LocalDateTime.now());
|
||||||
|
studySessionsEntity.setPointerPosition(WORK_DURATION * 60 * 1000L);
|
||||||
studySessionsEntity.setLastModifiedTime(LocalDateTime.now());
|
studySessionsEntity.setLastModifiedTime(LocalDateTime.now());
|
||||||
studySessionsEntity.setSessionState(StudySessionStateEnum.ONGOING.name());
|
studySessionsEntity.setSessionState(StudySessionStateEnum.ONGOING.name());
|
||||||
return studySessionsEntity;
|
return studySessionsEntity;
|
||||||
@@ -150,13 +152,7 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isFirstRun() {
|
public boolean isFirstRun() {
|
||||||
if (ObjectUtils.isEmpty(this.lastStartTime)) {
|
return ObjectUtils.isEmpty(this.pointerPosition);
|
||||||
return false;
|
|
||||||
} else if (this.lastStartTime.equals(this.startTime)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,10 +183,13 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
case ONGOING:
|
case ONGOING:
|
||||||
long elapsedMillis = Duration.between(lastStartTime, LocalDateTime.now()).toMillis();
|
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) {
|
if (newPointerPosition <= 0) {
|
||||||
// 如果循环已经结束,则需要重置指针位置
|
// 如果循环已经结束,则需要重置指针位置
|
||||||
this.pointerPosition = WORK_DURATION * 1000L;
|
this.pointerPosition = WORK_DURATION * 60 * 1000L;
|
||||||
} else {
|
} else {
|
||||||
this.pointerPosition = newPointerPosition;
|
this.pointerPosition = newPointerPosition;
|
||||||
}
|
}
|
||||||
@@ -215,4 +214,4 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
long minutes = Duration.between(ObjectUtils.isEmpty(lastStartTime) ? LocalDateTime.now() : lastStartTime, now).toMinutes();
|
long minutes = Duration.between(ObjectUtils.isEmpty(lastStartTime) ? LocalDateTime.now() : lastStartTime, now).toMinutes();
|
||||||
return minutes >= WORK_DURATION * 2;
|
return minutes >= WORK_DURATION * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,6 @@ import com.guo.learningprogresstracker.exception.AppException;
|
|||||||
public interface LoginService {
|
public interface LoginService {
|
||||||
|
|
||||||
String login(String userId) throws AppException;
|
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 cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.guo.learningprogresstracker.exception.AppException;
|
import com.guo.learningprogresstracker.exception.AppException;
|
||||||
import com.guo.learningprogresstracker.service.LoginService;
|
import com.guo.learningprogresstracker.service.LoginService;
|
||||||
import com.guo.learningprogresstracker.service.UserService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LoginServiceImpl implements LoginService {
|
public class LoginServiceImpl implements LoginService {
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String login(String userId) throws AppException {
|
public String login(String userId) throws AppException {
|
||||||
@@ -18,4 +14,9 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
//todo Token只在此处使用了,属于后续优化点
|
//todo Token只在此处使用了,属于后续优化点
|
||||||
return StpUtil.getTokenInfo().getTokenValue();
|
return StpUtil.getTokenInfo().getTokenValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logout() {
|
||||||
|
StpUtil.logout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,17 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
|||||||
@Override
|
@Override
|
||||||
public void updateTask(String taskId, TaskRequest updatedTask) {
|
public void updateTask(String taskId, TaskRequest updatedTask) {
|
||||||
TaskEntity taskEntity = TaskConvert.MAPPER.taskRequestToTaskEntity(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:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
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
|
username: root
|
||||||
password: GUOxy5157
|
password: GUOxy5157
|
||||||
server:
|
server:
|
||||||
|
|||||||
@@ -2,17 +2,18 @@ spring:
|
|||||||
# 配置数据库
|
# 配置数据库
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
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
|
username: root
|
||||||
password:
|
password: GUOxy5157
|
||||||
server:
|
server:
|
||||||
port: 5157
|
port: 5157
|
||||||
|
|
||||||
cors:
|
cors:
|
||||||
|
allowCredentials: true
|
||||||
allowed-origins:
|
allowed-origins:
|
||||||
- http://localhost:5158
|
- '*'
|
||||||
- http://192.168.123.199:5158
|
|
||||||
|
|
||||||
sa-token:
|
sa-token:
|
||||||
cookie:
|
cookie:
|
||||||
secure: false
|
secure: false
|
||||||
|
sameSite: Lax
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
from study_sessions ss
|
from study_sessions ss
|
||||||
left join tasks t on ss.task_num = t.task_num and ss.session_state != 'ENDED' and ss.deleted = 0
|
left join tasks t on ss.task_num = t.task_num and ss.session_state != 'ENDED' and ss.deleted = 0
|
||||||
where t.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>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user