|
@@ -1,11 +1,18 @@
|
|
package com.hhsx.minigame.service.impl;
|
|
package com.hhsx.minigame.service.impl;
|
|
|
|
|
|
import com.hhsx.minigame.entity.News;
|
|
import com.hhsx.minigame.entity.News;
|
|
|
|
+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 org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -17,4 +24,33 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
|
|
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ NewsMapper newsMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg addUserNews(NewsVO newsVO) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ if(newsVO.getType()==0){
|
|
|
|
+ //微信授权的链接
|
|
|
|
+ try {
|
|
|
|
+ String newAccessToken = AccessToken.getNewAccessToken();
|
|
|
|
+ WechatUserNews wechatUserNews = WechatAndMicroblogUtil.getWechatUserNews(newsVO.getOpenId(), newAccessToken);
|
|
|
|
+ News news = new News();
|
|
|
|
+ news.setNickName(wechatUserNews.getNickname());
|
|
|
|
+ news.setHeaderPic(wechatUserNews.getHeadimgurl());
|
|
|
|
+ news.setMessage(newsVO.getMessage());
|
|
|
|
+ news.setType(newsVO.getType());
|
|
|
|
+ newsMapper.insert(news);
|
|
|
|
+ msg.data = news;
|
|
|
|
+ return msg;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else if(newsVO.getType()==1){
|
|
|
|
+ //微博授权的链接
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|