|
@@ -23,7 +23,9 @@ import com.miaxis.system.dto.system.UserInfoDTO;
|
|
import com.miaxis.system.service.ISysMenuService;
|
|
import com.miaxis.system.service.ISysMenuService;
|
|
import com.miaxis.wx.dto.DyTokenDTO;
|
|
import com.miaxis.wx.dto.DyTokenDTO;
|
|
import com.miaxis.wx.dto.DyUserInfoDTO;
|
|
import com.miaxis.wx.dto.DyUserInfoDTO;
|
|
|
|
+import com.miaxis.wx.dto.ToutiaoTokenDTO;
|
|
import com.miaxis.wx.service.DyService;
|
|
import com.miaxis.wx.service.DyService;
|
|
|
|
+import com.miaxis.wx.service.ToutiaoService;
|
|
import com.miaxis.wx.service.WxService;
|
|
import com.miaxis.wx.service.WxService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -72,6 +74,10 @@ public class SysLoginController
|
|
@Autowired
|
|
@Autowired
|
|
private DyService dyService;
|
|
private DyService dyService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ToutiaoService toutiaoService;
|
|
|
|
+
|
|
|
|
+
|
|
private static Logger logger = LoggerFactory.getLogger(SysLoginController.class);
|
|
private static Logger logger = LoggerFactory.getLogger(SysLoginController.class);
|
|
|
|
|
|
|
|
|
|
@@ -89,6 +95,12 @@ public class SysLoginController
|
|
@Value("${dy.appSecret}")
|
|
@Value("${dy.appSecret}")
|
|
private String dyappSecret;
|
|
private String dyappSecret;
|
|
|
|
|
|
|
|
+ @Value("${tt.appId}")
|
|
|
|
+ private String ttappid;
|
|
|
|
+
|
|
|
|
+ @Value("${tt.appSecret}")
|
|
|
|
+ private String ttappSecret;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -153,6 +165,41 @@ public class SysLoginController
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户 openid登录
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/login/ttcode")
|
|
|
|
+ @ApiOperation("字节小程序授权码模式登录")
|
|
|
|
+ public Response<TokenDTO> loginByTtAuthorizationCode(String authorizationCode ){
|
|
|
|
+ ToutiaoTokenDTO toutiaoTokenDTO = new ToutiaoTokenDTO();
|
|
|
|
+ toutiaoTokenDTO.setCode(authorizationCode);
|
|
|
|
+ toutiaoTokenDTO.setAppid(ttappid);
|
|
|
|
+ toutiaoTokenDTO.setSecret(ttappSecret);
|
|
|
|
+ String ttResultStr = toutiaoService.getTtUserInfo(toutiaoTokenDTO);
|
|
|
|
+ logger.info("字节小程序授权码登录返回值:"+ttResultStr);
|
|
|
|
+ TtResult ttResult = JSONObject.parseObject(ttResultStr,TtResult.class);
|
|
|
|
+
|
|
|
|
+ // 生成令牌
|
|
|
|
+ if (ttResult.getErr_no() != null){
|
|
|
|
+ throw new CustomException("抖音授权登录无效,错误原因:"+ttResult.getErr_tips());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ServletUtils.getRequest().setAttribute("third","douyin");
|
|
|
|
+ ServletUtils.getRequest().setAttribute("headImage","");
|
|
|
|
+ ServletUtils.getRequest().setAttribute("nickName","");
|
|
|
|
+
|
|
|
|
+ String token = loginService.login(ttResult.getOpenid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
|
+ TokenDTO tokenDTO = new TokenDTO();
|
|
|
|
+ tokenDTO.setToken(token);
|
|
|
|
+ tokenDTO.setThirdResult(ttResult);
|
|
|
|
+ return Response.success(tokenDTO) ;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|