|
@@ -6,27 +6,27 @@
|
|
|
package org.eco.vip.auth.controller.auth;
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eco.vip.auth.domain.auth.pojo.AuthQuery;
|
|
|
import org.eco.vip.auth.domain.auth.pojo.AuthVO;
|
|
|
-import org.eco.vip.auth.domain.auth.pojo.LoginUserVO;
|
|
|
import org.eco.vip.auth.domain.client.pojo.ClientVO;
|
|
|
-import org.eco.vip.auth.domain.user.pojo.UserVO;
|
|
|
import org.eco.vip.auth.service.auth.IAuthService;
|
|
|
import org.eco.vip.auth.service.client.IClientService;
|
|
|
-import org.eco.vip.auth.service.user.IUserService;
|
|
|
import org.eco.vip.orm.constant.Constants;
|
|
|
import org.eco.vip.orm.exception.BusinessException;
|
|
|
import org.eco.vip.orm.pojo.CommonResult;
|
|
|
-import org.eco.vip.orm.pojo.LoginUser;
|
|
|
import org.eco.vip.orm.utils.JsonUtils;
|
|
|
import org.eco.vip.orm.utils.ObjUtils;
|
|
|
import org.eco.vip.orm.utils.StrUtils;
|
|
|
import org.eco.vip.orm.utils.ValidatorUtils;
|
|
|
-import org.eco.vip.security.utils.LoginHelper;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import static org.eco.vip.orm.pojo.CommonResult.fail;
|
|
|
import static org.eco.vip.orm.pojo.CommonResult.success;
|
|
@@ -49,9 +49,6 @@ public class AuthController {
|
|
|
@Resource
|
|
|
private IClientService clientService;
|
|
|
|
|
|
- @Resource
|
|
|
- private IUserService userService;
|
|
|
-
|
|
|
@PostMapping("/login")
|
|
|
public CommonResult<AuthVO> login(@RequestBody String body) {
|
|
|
AuthQuery authQueryBody = JsonUtils.parseObject(body, AuthQuery.class);
|
|
@@ -72,20 +69,12 @@ public class AuthController {
|
|
|
return success(adminAuthService.login(authQueryBody, clientVO, grantType));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/info")
|
|
|
- public CommonResult<LoginUserVO> getInfo() {
|
|
|
- LoginUserVO loginUserVO = new LoginUserVO();
|
|
|
- LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
- if (ObjUtils.isNull(loginUser)) {
|
|
|
- return fail("用户无权限!");
|
|
|
- }
|
|
|
- UserVO userVO = userService.selectById(loginUser.getUserId());
|
|
|
- if (ObjUtils.isNull(userVO)) {
|
|
|
- return fail("用户无权限!");
|
|
|
- }
|
|
|
- loginUserVO.setUser(userVO);
|
|
|
- loginUserVO.setPermissionCodes(loginUser.getPermissionCodes());
|
|
|
- loginUserVO.setRoleCodes(loginUser.getRoleCodes());
|
|
|
- return success(loginUserVO);
|
|
|
+ @GetMapping("/logout")
|
|
|
+ public CommonResult<Void> logout() {
|
|
|
+ // 清除缓存session
|
|
|
+ StpUtil.getTokenSession().logout();
|
|
|
+ // 退出登录
|
|
|
+ StpUtil.logout();
|
|
|
+ return success();
|
|
|
}
|
|
|
}
|