|
@@ -1,17 +1,22 @@
|
|
package com.hhsx.minigame.service.impl;
|
|
package com.hhsx.minigame.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.hhsx.minigame.constant.Constant;
|
|
import com.hhsx.minigame.entity.News;
|
|
import com.hhsx.minigame.entity.News;
|
|
import com.hhsx.minigame.entity.vo.NewsVO;
|
|
import com.hhsx.minigame.entity.vo.NewsVO;
|
|
import com.hhsx.minigame.mapper.NewsMapper;
|
|
import com.hhsx.minigame.mapper.NewsMapper;
|
|
import com.hhsx.minigame.service.NewsService;
|
|
import com.hhsx.minigame.service.NewsService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.hhsx.minigame.utils.AccessToken;
|
|
|
|
-import com.hhsx.minigame.utils.HttpRespMsg;
|
|
|
|
-import com.hhsx.minigame.utils.WechatUserNews;
|
|
|
|
-import com.hhsx.minigame.utils.WechatAndMicroblogUtil;
|
|
|
|
|
|
+import com.hhsx.minigame.utils.*;
|
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.security.KeyManagementException;
|
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
|
+import java.security.NoSuchProviderException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -33,8 +38,7 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
|
|
if(newsVO.getType()==0){
|
|
if(newsVO.getType()==0){
|
|
//微信授权的链接
|
|
//微信授权的链接
|
|
try {
|
|
try {
|
|
- String newAccessToken = AccessToken.getNewAccessToken();
|
|
|
|
- WechatUserNews wechatUserNews = WechatAndMicroblogUtil.getWechatUserNews(newsVO.getOpenId(), newAccessToken);
|
|
|
|
|
|
+ WechatUserNews wechatUserNews = WechatAndMicroblogUtil.getWechatUserNews(newsVO.getOpenId(), AccessToken.getNewAccessToken());
|
|
News news = new News();
|
|
News news = new News();
|
|
news.setNickName(wechatUserNews.getNickname());
|
|
news.setNickName(wechatUserNews.getNickname());
|
|
news.setHeaderPic(wechatUserNews.getHeadimgurl());
|
|
news.setHeaderPic(wechatUserNews.getHeadimgurl());
|
|
@@ -49,8 +53,20 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
|
|
|
|
|
|
}else if(newsVO.getType()==1){
|
|
}else if(newsVO.getType()==1){
|
|
//微博授权的链接
|
|
//微博授权的链接
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //微博授权登录
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg login(NewsVO newsVO,String callbackURL) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
|
|
|
|
+ String authorizationURL = "https://api.weibo.com/oauth2/authorize?client_id="+Constant.MICROBLOG_APPKEY +"&response_type=code&redirect_uri="+callbackURL;
|
|
|
|
+ String resp = HttpKit.get(authorizationURL, true);
|
|
|
|
+ resp = StringEscapeUtils.unescapeJava(resp);
|
|
|
|
+ JSONObject json = (JSONObject) JSON.parse(resp);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|