补全登录退出接口并统一登出路径
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("已登出");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user