|
|
@@ -34,11 +34,10 @@ import com.cyksj.model.response.WxGzhQrCodeTicketRep;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.authorization.AuthorizationService;
|
|
|
import com.cyksj.service.distribute.DistributeService;
|
|
|
-import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
|
|
|
+import com.cyksj.service.mail.MailService;
|
|
|
import com.cyksj.service.template.TemplateCommonService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
-import com.cyksj.service.mail.MailService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -91,23 +90,21 @@ public class AuthorizationController {
|
|
|
|
|
|
private final DistributeService distributeService;
|
|
|
|
|
|
- private final EquipmentDistributeService equipDistributeService;
|
|
|
-
|
|
|
@GetMapping(value = "/weChat")
|
|
|
- public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, HttpServletResponse response) throws Exception {
|
|
|
+ public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, Integer type, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
- log.info("微信授权转跳. url: {},authType:{}",url,authType);
|
|
|
+ log.info("微信授权转跳. url: {},authType:{}", url, authType);
|
|
|
|
|
|
// 无论是否为老用户 均转跳到授权页面
|
|
|
// 若授权过 则无需再次授权 直接回调 /user/wechat/redirect
|
|
|
// 新用户同意授权后 也会回调 /user/wechat/redirect
|
|
|
|
|
|
Long mappingId = SEQUENCE.nextId();
|
|
|
- redisService.set(mappingId.toString(),url,60*60*24L);
|
|
|
- AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId);
|
|
|
+ redisService.set(mappingId.toString(), url, 60 * 60 * 24L);
|
|
|
+ AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setType(type);
|
|
|
String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
|
|
|
|
- response.sendRedirect(authorizationService.createUrl(state,authType));
|
|
|
+ response.sendRedirect(authorizationService.createUrl(state, authType, type));
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -124,7 +121,7 @@ public class AuthorizationController {
|
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code,weChatConfig.getAppid());
|
|
|
+ AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
|
|
|
|
|
|
// 根据openid 与 access_token 获取用户信息
|
|
|
GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
|
|
|
@@ -170,7 +167,7 @@ public class AuthorizationController {
|
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code,weChatConfig.getAppid());
|
|
|
+ AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
|
|
|
|
|
|
// 查询用户期望转跳的url
|
|
|
String url = redisService.getStr(re.getMappingId().toString());
|
|
|
@@ -190,11 +187,11 @@ public class AuthorizationController {
|
|
|
* 微信js-sdk 权限验证
|
|
|
*/
|
|
|
@RequestMapping(value = "/jsTicket", method = RequestMethod.GET)
|
|
|
- public Result<JsSdkTicket> ticket(String url) throws Exception{
|
|
|
+ public Result<JsSdkTicket> ticket(String url, Integer type) throws Exception {
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入授权网址.");
|
|
|
}
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatConfig.getAppid(),url));
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatService.getWxAppId(type), url));
|
|
|
|
|
|
}
|
|
|
|