| | |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | import com.yeshi.buwan.exception.LoginUserException; |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.pptv.PPTVApiUtil; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.entity.wx.WeiXinUser; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public void updateSelectiveByPrimaryKey(LoginUserExtra extra) { |
| | | loginUserExtraDao.updateSelective(extra); |
| | | } |
| | | |
| | | @Override |
| | | public String updatePPTVOpenId(String uid) throws PPTVException { |
| | | LoginUserExtra extra = getExtra(uid); |
| | | if (extra == null) { |
| | | extra = initExtra(uid); |
| | | } |
| | | String code = PPTVUtil.getPPTVCode(extra.getPptvUid()); |
| | | |
| | | boolean login = PPTVApiUtil.login(code); |
| | | if (!login) { |
| | | throw new PPTVException(101, "登录失败"); |
| | | } |
| | | |
| | | String openId = PPTVApiUtil.getOpenId(extra.getPptvUid()); |
| | | if (StringUtil.isNullOrEmpty(openId)) { |
| | | throw new PPTVException(102, "openId获取失败"); |
| | | } |
| | | LoginUserExtra update=new LoginUserExtra(); |
| | | update.setId(uid); |
| | | update.setPptvOpenId(openId); |
| | | updateSelectiveByPrimaryKey(update); |
| | | return openId; |
| | | } |
| | | } |