|
@@ -2,10 +2,13 @@ package com.zhongshu.card.server.core.controller.org;
|
|
|
|
|
|
|
|
import com.github.microservice.auth.client.constant.AuthConstant;
|
|
import com.github.microservice.auth.client.constant.AuthConstant;
|
|
|
import com.github.microservice.auth.client.model.LoginTokenModel;
|
|
import com.github.microservice.auth.client.model.LoginTokenModel;
|
|
|
|
|
+import com.github.microservice.auth.client.model.UserTokenModel;
|
|
|
import com.github.microservice.auth.security.annotations.ResourceAuth;
|
|
import com.github.microservice.auth.security.annotations.ResourceAuth;
|
|
|
import com.github.microservice.auth.security.helper.AuthHelper;
|
|
import com.github.microservice.auth.security.helper.AuthHelper;
|
|
|
import com.github.microservice.auth.security.type.AuthType;
|
|
import com.github.microservice.auth.security.type.AuthType;
|
|
|
import com.zhongshu.card.client.model.base.AuthTypeParam;
|
|
import com.zhongshu.card.client.model.base.AuthTypeParam;
|
|
|
|
|
+import com.zhongshu.card.client.model.base.ReTokenParam;
|
|
|
|
|
+import com.zhongshu.card.client.model.base.TokenParam;
|
|
|
import com.zhongshu.card.client.model.org.*;
|
|
import com.zhongshu.card.client.model.org.*;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultState;
|
|
import com.zhongshu.card.client.ret.ResultState;
|
|
@@ -75,4 +78,25 @@ public class IndexController {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Operation(summary = "刷新token", description = "刷新token")
|
|
|
|
|
+ @RequestMapping(value = "refreshToken", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public ResultContent refreshToken(@RequestBody ReTokenParam param, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ ResultContent<UserTokenModel> result = indexService.refreshToken(param.getRefreshToken());
|
|
|
|
|
+ if (result != null && result.getState() == ResultState.Success) {
|
|
|
|
|
+ UserTokenModel tokenModel = (UserTokenModel) result.getContent();
|
|
|
|
|
+ response.setHeader("accessToken", tokenModel.getAccessToken());
|
|
|
|
|
+ Cookie cookie = new Cookie("accessToken", String.valueOf(tokenModel.getExpireTime()));
|
|
|
|
|
+ cookie.setMaxAge(60 * 60 * 24 * 30);
|
|
|
|
|
+ cookie.setPath("/");
|
|
|
|
|
+ response.addCookie(cookie);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "退出登录", description = "退出登录")
|
|
|
|
|
+ @RequestMapping(value = "loginOut", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public ResultContent loginOut(@RequestBody TokenParam param) {
|
|
|
|
|
+ return indexService.loginOut(param.getToken());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|