补全登录退出接口并统一登出路径

This commit is contained in:
2026-04-12 13:05:46 +08:00
parent 2e6c59cfb6
commit 05f47b92a8
3 changed files with 12 additions and 10 deletions
@@ -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("已登出");
}
}
@@ -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();
}
}