From a5889f996d63a01eb6f7de3f8480364347786715 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Mon, 25 Mar 2019 21:13:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4wechatAccessToken=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lq/cms/service/impl/WechatUserServiceImpl.java | 9 ++++++--- src/main/java/com/lq/dao/WechatUserDao.java | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lq/cms/service/impl/WechatUserServiceImpl.java b/src/main/java/com/lq/cms/service/impl/WechatUserServiceImpl.java index e2f2174..48b5c6a 100755 --- a/src/main/java/com/lq/cms/service/impl/WechatUserServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/WechatUserServiceImpl.java @@ -12,6 +12,7 @@ import com.lq.dao.WechatUserDao; import com.lq.entity.WechatAccessToken; import com.lq.entity.WechatInfo; import com.lq.entity.WechatUser; +import com.lq.wechat.util.accessToken.AccessTokenUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,15 +29,17 @@ public class WechatUserServiceImpl extends BaseServiceImpl implement @Autowired private WechatUserDao wechatUserDao; @Autowired - private WechatAccesstokenDao wechatAccesstokenDao; + private AccessTokenUtil accessTokenUtil; @Override public WechatUser saveWechatUser(String openId, WechatInfo wechatInfo) { WechatUser wechatUser = wechatUserDao.getByOpenId(openId); if (wechatUser==null){ wechatUser = new WechatUser(); - WechatAccessToken wechatAccessToken = wechatAccesstokenDao.getByWechatInfoIdAndTokenType(wechatInfo.getId(), WechatAccessTokenTypeEnum.CURRENCY.getValue()); - + // WechatAccessToken wechatAccessToken = wechatAccesstokenDao.getByWechatInfoIdAndTokenType(wechatInfo.getId(), WechatAccessTokenTypeEnum.CURRENCY.getValue()); + String accessToken = accessTokenUtil.getAccessToken(wechatInfo); + wechatUser.setWechatInfoId(wechatInfo.getId()); + wechatUserDao.save(wechatUser); } return wechatUser; diff --git a/src/main/java/com/lq/dao/WechatUserDao.java b/src/main/java/com/lq/dao/WechatUserDao.java index f14205b..a2ce9e2 100755 --- a/src/main/java/com/lq/dao/WechatUserDao.java +++ b/src/main/java/com/lq/dao/WechatUserDao.java @@ -4,6 +4,7 @@ import com.lq.cms.dao.AdminBaseDao; import com.lq.cms.vo.AdminBaseVo; import com.lq.code.dao.BaseDao; import com.lq.entity.WechatUser; +import org.apache.ibatis.annotations.Param; /** * @Author: qi @@ -12,5 +13,5 @@ import com.lq.entity.WechatUser; */ public interface WechatUserDao extends BaseDao{ - WechatUser getByOpenId(String openId); + WechatUser getByOpenId(@Param("openId") String openId); }