|
@@ -1,5 +1,6 @@
|
|
|
package com.miaxis.system.controller.system;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.miaxis.common.core.domain.Response;
|
|
|
import com.miaxis.common.core.domain.entity.SysMenu;
|
|
|
import com.miaxis.common.core.domain.entity.SysUser;
|
|
@@ -16,6 +17,8 @@ import com.miaxis.system.dto.common.RouterDTO;
|
|
|
import com.miaxis.system.dto.system.TokenDTO;
|
|
|
import com.miaxis.system.dto.system.UserInfoDTO;
|
|
|
import com.miaxis.system.service.ISysMenuService;
|
|
|
+import com.miaxis.wx.dto.WxResult;
|
|
|
+import com.miaxis.wx.service.WxService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -50,6 +53,22 @@ public class SysLoginController
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WxService wxService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${app.appId}")
|
|
|
+ private String appid;
|
|
|
+
|
|
|
+ @Value("${app.appSecret}")
|
|
|
+ private String appSecret;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -84,48 +103,45 @@ public class SysLoginController
|
|
|
tokenDTO.setToken(token);
|
|
|
return Response.success(tokenDTO);
|
|
|
}
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 用户 jscode登录
|
|
|
-// *
|
|
|
-// */
|
|
|
-// @PostMapping("/login/jscode")
|
|
|
-// @ApiOperation("用户jscode登录")
|
|
|
-// public Response<TokenDTO> getInfo(String jscode){
|
|
|
-// String result = wxService.getWxInfo(appid, secret, jscode,"authorization_code");
|
|
|
-// JSONObject jsonString = JSONObject.parseObject(result);
|
|
|
-// WxResult wxResult = JSONObject.toJavaObject(jsonString, WxResult.class);
|
|
|
-// TokenDTO tokenDTO = new TokenDTO();
|
|
|
-// // 生成令牌
|
|
|
-// if (wxResult.getOpenid() != null){
|
|
|
-// // 生成令牌
|
|
|
-// String token = loginService.login(wxResult.getOpenid(),null, StudentLoginTypeEnum.OPENID_LOGIN.getCode());
|
|
|
-// tokenDTO.setToken(token);
|
|
|
-// return Response.success(tokenDTO) ;
|
|
|
-// }
|
|
|
-// else{
|
|
|
-// return Response.error(500,wxResult.getErrmsg());
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
- * 用户 jscode登录
|
|
|
+ * 用户 openid登录
|
|
|
*
|
|
|
*/
|
|
|
- @PostMapping("/login/jscode-test")
|
|
|
- @ApiOperation("用户jscode登录(测试,固定openid)")
|
|
|
- public Response<TokenDTO> getInfoTest(String jscode){
|
|
|
+ @PostMapping("/login/code")
|
|
|
+ @ApiOperation("用户授权码模式登录")
|
|
|
+ public Response<TokenDTO> loginByAuthorizationCode(String authorizationCode ){
|
|
|
+
|
|
|
+
|
|
|
+ WxResult wxResult = wxService.getWxToken(appid, appSecret, authorizationCode, "authorization_code");
|
|
|
+ // 生成令牌
|
|
|
+ String token = loginService.login(wxResult.getOpenid(),null, StudentLoginTypeEnum.OPENID_LOGIN.getCode());
|
|
|
TokenDTO tokenDTO = new TokenDTO();
|
|
|
- // 生成令牌
|
|
|
- String token = loginService.login("oO7PJ5CPQJo62kZWA3uiUX2KG2s4",null, StudentLoginTypeEnum.OPENID_LOGIN.getCode());
|
|
|
tokenDTO.setToken(token);
|
|
|
+ tokenDTO.setWxToken(wxResult.getAccess_token());
|
|
|
return Response.success(tokenDTO) ;
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 用户 jscode登录
|
|
|
+// *
|
|
|
+// */
|
|
|
+// @PostMapping("/login/jscode-test")
|
|
|
+// @ApiOperation("用户jscode登录(测试,固定openid)")
|
|
|
+// public Response<TokenDTO> getInfoTest(String jscode){
|
|
|
+// TokenDTO tokenDTO = new TokenDTO();
|
|
|
+// // 生成令牌
|
|
|
+// String token = loginService.login("oO7PJ5CPQJo62kZWA3uiUX2KG2s4",null, StudentLoginTypeEnum.OPENID_LOGIN.getCode());
|
|
|
+// tokenDTO.setToken(token);
|
|
|
+// return Response.success(tokenDTO) ;
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息
|