| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import com.stylefeng.guns.modular.system.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信小程序登录 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static LoginWeChatXiao loginWeChatXiao(String code) { |
| | | HttpRequest post = HttpUtil.createPost("https://casme.teamshub.com/webapp-backstage/ajax/loginWeChatXiao/v1.0"); |
| | | post.header("Content-Type", "text/plain;charset=UTF-8"); |
| | | post.header("Accept-encodeing", "UTF-8"); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("version", "1.0"); |
| | | try { |
| | | body.put("id", UUIDUtil.getRandomCode(6)); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("type", "loginWeChatXiao"); |
| | | body.put("action", "request"); |
| | | body.put("code", code); |
| | | body.put("appId", ""); |
| | | post.body(body.toJSONString()); |
| | | HttpResponse execute = post.execute(); |
| | | if (200 != execute.getStatus()) { |
| | | log.error("微信登录失败"); |
| | | return null; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(execute.body()); |
| | | Integer status = jsonObject.getInteger("status"); |
| | | if (0 != status) { |
| | | log.error("微信登录失败:" + jsonObject.getString("desc")); |
| | | return null; |
| | | } |
| | | LoginWeChatXiao loginWeChatXiao = jsonObject.getObject("data", LoginWeChatXiao.class); |
| | | return loginWeChatXiao; |
| | | } |
| | | |
| | | } |