zoujiajian 2 lat temu
rodzic
commit
ac50901ea2

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/AuthRedirect.java

@@ -72,4 +72,9 @@ public class AuthRedirect {
      * 店铺自定义id
      */
     private String cd;
+
+    /**
+     * 跳转url
+     */
+    private String url;
 }

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/CpsAuthDto.java

@@ -21,4 +21,6 @@ public class CpsAuthDto {
 	 * 授权标识
 	 */
 	private String authState;
+
+	private String redirectUrl;
 }

+ 8 - 2
netflix-web/src/main/java/com/cyksj/web/controller/cps/CpsBackLoginController.java

@@ -99,7 +99,7 @@ public class CpsBackLoginController {
 	 * cps后台微信授权登录
 	 */
 	@GetMapping("/wx/authLogin")
-	public Result<CpsAuthDto> wxAuthorize() throws Exception {
+	public Result<CpsAuthDto> wxAuthorize(String redirectUrl) throws Exception {
 		Object authUrlObj = redisService.get(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("cps", wxOpenPlatYHLXLoginConfig.getAppId()));
 		if (authUrlObj != null) {
 			CpsAuthDto cpsAuthDto = Jsons.parseObject(authUrlObj.toString(), CpsAuthDto.class);
@@ -110,6 +110,7 @@ public class CpsBackLoginController {
 		String authState = mappingId.toString();
 		redisService.set(authState, authState, 60 * 60 * 24L);
 		AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
+		redirect.setUrl(redirectUrl);
 		String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getCpsRedirectUri());
 		cpsAuthDto.setAuthUrl(wxAuthUrl);
@@ -140,9 +141,14 @@ public class CpsBackLoginController {
 		if (user == null) throw BusinessRuntimeException.getInstance("用户信息不存在");
 		UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, user.getId()).eq(UserDistribute::getDeleted, 1).select(UserDistribute::getId).last("limit 1"));
 		if (userDistribute == null) throw BusinessRuntimeException.getInstance("只支持渠道分销用户登录");
-		JSONObject res = new JSONObject();
 		StpCpsManageUser.login(user.getId());
 		String cpsToken = StpCpsManageUser.getTokenValue();
+		String url = re.getUrl();
+		if (StrUtil.isNotBlank(url)) {
+			response.sendRedirect(url.contains("?") ? url + "&t=" + cpsToken : url + "?t=" + cpsToken);
+			return;
+		}
+		JSONObject res = new JSONObject();
 		res.putOpt("satoken-cpsUser", cpsToken);
 		res.putOpt("img", user.getHeadimgurl());
 		res.putOpt("nickname", user.getNickname());