| | |
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUserParam;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class WXLoginUtil {
|
| | |
| | | public static String WEXIN_APPID = "wx43617e2ed82c5b28";
|
| | | public static String WEXIN_SECRET = "f8a65908fb4681bdd181de70f6ab9a3b";
|
| | |
|
| | | static String APPID = "wx5c0d167c6e3ad726";
|
| | | static String SECRET = "0c79d5869bb0f2d7c13e43f9a18f440d";
|
| | |
|
| | | static {
|
| | | WEXIN_APPID = Constant.systemCommonConfig.getWxGZAppId();
|
| | | WEXIN_SECRET = Constant.systemCommonConfig.getWxGZAppSecret();
|
| | | APPID = Constant.systemCommonConfig.getWxOpenAppId();
|
| | | SECRET = Constant.systemCommonConfig.getWxOpenAppSecret();
|
| | | }
|
| | |
|
| | | // 通过code获取access_token openId
|
| | |
| | |
|
| | | public static String weiXinUrl2 = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";
|
| | |
|
| | | public static WeiXinUserParam getWxParam(String code) {
|
| | | String wxUrl = String.format(weiXinUrl1, APPID, SECRET, code);
|
| | | public static WeiXinUserParam getWxParam(String code,String appId,String appSecret) {
|
| | | String wxUrl = String.format(weiXinUrl1, appId, appSecret, code);
|
| | | String result = HttpUtil.get(wxUrl);
|
| | | WeiXinUserParam weiXinUserParam = getWeiXinUserParam(result);
|
| | | return weiXinUserParam;
|
| | |
| | | return weiXinUser;
|
| | | }
|
| | |
|
| | | public static WeiXinUser getWeiXinUser(String code) {
|
| | | WeiXinUserParam param = getWxParam(code);
|
| | | public static WeiXinUser getWeiXinUser(String code,String appId,String appSecret) {
|
| | | WeiXinUserParam param = getWxParam(code,appId,appSecret);
|
| | | if (param == null) {
|
| | | return null;
|
| | | }
|
| | |
| | | * @param code
|
| | | * @return
|
| | | */
|
| | | public static WeiXinUser getWeiXinUserWithSavePortrait(String code) {
|
| | | WeiXinUser user = getWeiXinUser(code);
|
| | | public static WeiXinUser getWeiXinUserWithSavePortrait(String code,String appId,String appSecret) {
|
| | | WeiXinUser user = getWeiXinUser(code,appId,appSecret);
|
| | | if (user != null) {
|
| | | if (!StringUtil.isNullOrEmpty(user.getHeadimgurl())) {
|
| | |
|
| | |
| | | }
|
| | |
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", user.getUnionid(), System.currentTimeMillis() + ""));
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", user.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | user.setHeadimgurl(result.getUrl());
|
| | | // COS删除其余头像
|