|
@@ -9,6 +9,9 @@ import com.ym.mec.common.entity.HttpResponseResult;
|
|
import com.ym.mec.common.security.AuthUser;
|
|
import com.ym.mec.common.security.AuthUser;
|
|
import com.ym.mec.common.security.SecurityUtils;
|
|
import com.ym.mec.common.security.SecurityUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
@@ -49,6 +52,11 @@ public class TokenController extends BaseController {
|
|
private SysUserService userService;
|
|
private SysUserService userService;
|
|
|
|
|
|
@PostMapping("/smsLogin")
|
|
@PostMapping("/smsLogin")
|
|
|
|
+ @ApiOperation(value = "短信验证码的方式登录")
|
|
|
|
+ @ApiImplicitParams({ @ApiImplicitParam(name = "smsCode", value = "验证码", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "clientSecret", value = "固定传 app", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "clientId", value = "固定传 app", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String") })
|
|
public Object smsLogin(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
|
public Object smsLogin(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
|
|
|
|
|
String clientId = request.getParameter("clientId");
|
|
String clientId = request.getParameter("clientId");
|
|
@@ -69,6 +77,7 @@ public class TokenController extends BaseController {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取用户信息")
|
|
@GetMapping("/api/queryUserInfo")
|
|
@GetMapping("/api/queryUserInfo")
|
|
public Object apiQueryUserInfo() {
|
|
public Object apiQueryUserInfo() {
|
|
AuthUser authUser = SecurityUtils.getUser();
|
|
AuthUser authUser = SecurityUtils.getUser();
|
|
@@ -79,6 +88,11 @@ public class TokenController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
@PostMapping("/usernameLogin")
|
|
@PostMapping("/usernameLogin")
|
|
|
|
+ @ApiOperation(value = "手机号密码方式登录")
|
|
|
|
+ @ApiImplicitParams({ @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "clientSecret", value = "固定传 app", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "clientId", value = "固定传 app", required = true, dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "username", value = "手机号", required = true, dataType = "String") })
|
|
public Object usernameLogin(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
|
public Object usernameLogin(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
|
|
|
|
|
String clientId = request.getParameter("clientId");
|
|
String clientId = request.getParameter("clientId");
|
|
@@ -90,7 +104,7 @@ public class TokenController extends BaseController {
|
|
return succeed(accessTokenService.getAccessToken(clientId, clientSecret, authentication));
|
|
return succeed(accessTokenService.getAccessToken(clientId, clientSecret, authentication));
|
|
}
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "/loginIn")
|
|
|
|
|
|
+ /*@PostMapping(value = "/loginIn")
|
|
//@PreAuthorize("hasAnyAuthority('sys_user_manage')")
|
|
//@PreAuthorize("hasAnyAuthority('sys_user_manage')")
|
|
public HttpResponseResult login(String username, String password, String clientId, String clientSecret) throws IOException {
|
|
public HttpResponseResult login(String username, String password, String clientId, String clientSecret) throws IOException {
|
|
String url = "http://auth-server/oauth/token";
|
|
String url = "http://auth-server/oauth/token";
|
|
@@ -111,9 +125,10 @@ public class TokenController extends BaseController {
|
|
ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
|
ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
|
|
|
|
|
return succeed(objectMapper.readValue(resp.getBody(), Map.class));
|
|
return succeed(objectMapper.readValue(resp.getBody(), Map.class));
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
@PostMapping(value = "/refreshToken")
|
|
@PostMapping(value = "/refreshToken")
|
|
|
|
+ @ApiOperation(value = "刷新token")
|
|
public HttpResponseResult refreshToken(String refreshToken, String clientId, String clientSecret) throws IOException {
|
|
public HttpResponseResult refreshToken(String refreshToken, String clientId, String clientSecret) throws IOException {
|
|
String url = "http://auth-server/oauth/token";
|
|
String url = "http://auth-server/oauth/token";
|
|
|
|
|
|
@@ -135,6 +150,7 @@ public class TokenController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
@PostMapping(value = "exit")
|
|
@PostMapping(value = "exit")
|
|
|
|
+ @ApiOperation(value = "推出登录")
|
|
public HttpResponseResult logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION) String authHeader) {
|
|
public HttpResponseResult logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION) String authHeader) {
|
|
if (StringUtils.isBlank(authHeader)) {
|
|
if (StringUtils.isBlank(authHeader)) {
|
|
return failed("退出失败,token 为空");
|
|
return failed("退出失败,token 为空");
|