登录检查. @author @JunzhouLiu @Kurenai @since 2020-11-22 4:57
| 19 | * @since 2020-11-22 4:57 |
| 20 | */ |
| 21 | @Slf4j |
| 22 | public class UserCheck implements Task { |
| 23 | |
| 24 | @Override |
| 25 | public void run() { |
| 26 | JsonObject userJson = HttpUtils.doGet(ApiList.LOGIN); |
| 27 | if (userJson == null) { |
| 28 | log.info("用户信息请求失败,如果是412错误,请在config.json中更换UA,412问题仅影响用户信息确认,不影响任务"); |
| 29 | } else { |
| 30 | userJson = HttpUtils.doGet(ApiList.LOGIN); |
| 31 | //判断Cookies是否有效 |
| 32 | if (userJson.get(STATUS_CODE_STR).getAsInt() == 0 |
| 33 | && userJson.get("data").getAsJsonObject().get("isLogin").getAsBoolean()) { |
| 34 | userInfo = new Gson().fromJson(userJson |
| 35 | .getAsJsonObject("data"), UserData.class); |
| 36 | log.info("Cookies有效,登录成功"); |
| 37 | } else { |
| 38 | log.debug(String.valueOf(userJson)); |
| 39 | log.warn("Cookies可能失效了,请仔细检查配置中的Cookies是否有效"); |
| 40 | } |
| 41 | |
| 42 | log.info("用户名称: {}", HelpUtil.userNameEncode(userInfo.getUname())); |
| 43 | log.info("硬币余额: {}", userInfo.getMoney()); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public String getName() { |
| 50 | return "登录检查"; |
| 51 | } |
| 52 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…