From bf4dc4bdbb4b0f7873f5a987556e0181b01ccd03 Mon Sep 17 00:00:00 2001
From: Nomop <13098939400@163.com>
Date: Thu, 24 Oct 2024 16:13:00 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
接入组件,获取GithubAPI-User-Data
---
.idea/compiler.xml | 21 +++
.idea/encodings.xml | 9 +
.idea/workspace.xml | 172 ++++++++++++++++++
assess-common/pom.xml | 26 +++
.../main/java/com/common/dto/GithubUser.java | 59 ++++++
.../src/main/java/com/common/dto/Plan.java | 22 +++
assess-web/pom.xml | 63 +++++++
.../com/web/controller/TestController.java | 62 +++++++
assess-web/src/main/java/test/Test.java | 46 +++++
.../com/web/controller/TestController.class | Bin 0 -> 2315 bytes
pom.xml | 66 +++++++
11 files changed, 546 insertions(+)
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/workspace.xml
create mode 100644 assess-common/pom.xml
create mode 100644 assess-common/src/main/java/com/common/dto/GithubUser.java
create mode 100644 assess-common/src/main/java/com/common/dto/Plan.java
create mode 100644 assess-web/pom.xml
create mode 100644 assess-web/src/main/java/com/web/controller/TestController.java
create mode 100644 assess-web/src/main/java/test/Test.java
create mode 100644 assess-web/target/classes/com/web/controller/TestController.class
create mode 100644 pom.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..a95575f
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..961cd4f
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..d958f5d
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1729731292150
+
+
+ 1729731292150
+
+
+
+
+
+
+
+
+ 1729731753929
+
+
+
+ 1729731753929
+
+
+ 1729733767035
+
+
+
+ 1729733767035
+
+
+ 1729756238756
+
+
+
+ 1729756238756
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assess-common/pom.xml b/assess-common/pom.xml
new file mode 100644
index 0000000..a4e4124
--- /dev/null
+++ b/assess-common/pom.xml
@@ -0,0 +1,26 @@
+
+
+ 4.0.0
+
+ org.example
+ qiniuyun1024
+ 1.0-SNAPSHOT
+
+
+ assess-common
+
+
+ UTF-8
+ UTF-8
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
\ No newline at end of file
diff --git a/assess-common/src/main/java/com/common/dto/GithubUser.java b/assess-common/src/main/java/com/common/dto/GithubUser.java
new file mode 100644
index 0000000..0014dd6
--- /dev/null
+++ b/assess-common/src/main/java/com/common/dto/GithubUser.java
@@ -0,0 +1,59 @@
+package com.common.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Description githubAPI获取对应用户的信息
+ * @Author nomo
+ * @Date 2024/10/24 15:37
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+@Builder
+public class GithubUser {
+
+ private String login;
+ private long id;
+ private String node_id;
+ private String avatar_url;
+ private String gravatar_id;
+ private String url;
+ private String html_url;
+ private String followers_url;
+ private String following_url;
+ private String gists_url;
+ private String starred_url;
+ private String subscriptions_url;
+ private String organizations_url;
+ private String repos_url;
+ private String events_url;
+ private String received_events_url;
+ private String type;
+ private String user_view_type;
+ private boolean site_admin;
+ private String name;
+ private String company;
+ private String blog;
+ private String location;
+ private String email;
+ private String hireable;
+ private String bio;
+ private String twitter_username;
+ private int public_repos;
+ private int public_gists;
+ private int followers;
+ private int following;
+ private String created_at;
+ private String updated_at;
+ private int private_gists;
+ private int total_private_repos;
+ private int owned_private_repos;
+ private long disk_usage;
+ private int collaborators;
+ private boolean two_factor_authentication;
+ private Plan plan;
+}
diff --git a/assess-common/src/main/java/com/common/dto/Plan.java b/assess-common/src/main/java/com/common/dto/Plan.java
new file mode 100644
index 0000000..a640242
--- /dev/null
+++ b/assess-common/src/main/java/com/common/dto/Plan.java
@@ -0,0 +1,22 @@
+package com.common.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Description
+ * @Author nomo
+ * @Date 2024/10/24 15:38
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+@Builder
+public class Plan {
+ private String name;
+ private long space;
+ private int collaborators;
+ private int private_repos;
+}
diff --git a/assess-web/pom.xml b/assess-web/pom.xml
new file mode 100644
index 0000000..2245d0d
--- /dev/null
+++ b/assess-web/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.example
+ qiniuyun1024
+ 1.0-SNAPSHOT
+
+
+ assess-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.projectlombok
+ lombok
+
+
+ com.google.guava
+ guava
+
+
+ cn.hutool
+ hutool-all
+
+
+ com.alibaba
+ fastjson
+
+
+ org.projectlombok
+ lombok
+
+
+ junit
+ junit
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assess-web/src/main/java/com/web/controller/TestController.java b/assess-web/src/main/java/com/web/controller/TestController.java
new file mode 100644
index 0000000..a7c7c2f
--- /dev/null
+++ b/assess-web/src/main/java/com/web/controller/TestController.java
@@ -0,0 +1,62 @@
+package com.web.controller;
+
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description
+ * @Author nomo
+ * @Date 2024/10/24 9:16
+ */
+@RestController
+@Slf4j
+public class TestController {
+
+ /*
+ * 测试SpringBoot
+ * */
+ @RequestMapping("/test")
+ private String test() {
+ System.out.println("sout:777");
+ log.info("999");
+ return "666";
+ }
+
+ /*
+ * 测试GithubAPI接口
+ * */
+ @RequestMapping("/GithubUser")
+ private String githubTest(){
+ //TODO: 输入GitHub 用户名
+ String username = "nomop";
+
+ final String GITHUB_API_URL = "https://api.github.com/users/";
+ final String TOKEN = "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";
+
+ // 构建完整的 URL
+ String url = GITHUB_API_URL + username;
+
+ // 使用 Hutool 发起 GET 请求
+ HttpResponse response = HttpRequest.get(url)
+ .header("Authorization", "token " + TOKEN) // 设置 GitHub Token 以避免限流
+ .header("Accept", "application/vnd.github.v3+json") // 设置接受的数据格式
+ .timeout(20000) // 设置超时时间(毫秒)
+ .execute();
+
+
+ //TODO:包装成VO类
+
+ // 检查响应状态码
+ if (response.getStatus() == 200) {
+ // 获取并输出返回的用户信息
+ log.info(response.body());
+ return "用户信息: " + response.body();
+ } else {
+ return "请求失败,状态码: " + response.getStatus();
+ }
+ }
+}
diff --git a/assess-web/src/main/java/test/Test.java b/assess-web/src/main/java/test/Test.java
new file mode 100644
index 0000000..89646b4
--- /dev/null
+++ b/assess-web/src/main/java/test/Test.java
@@ -0,0 +1,46 @@
+package test;
+
+import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSON;
+import com.google.common.base.Throwables;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description 组件测试
+ * @Author nomo
+ * @Date 2024/10/24 9:30
+ */
+public class Test {
+
+ public static void main(String[] args) {
+
+ try {
+ LombokTest lombokTest1 = LombokTest.builder().id("1").name("好吃").build();
+ LombokTest lombokTest2 = LombokTest.builder().id("2").name("好玩").build();
+ List lombokTests = Arrays.asList(lombokTest1, lombokTest2);
+ if (CollUtil.isNotEmpty(lombokTests)) {
+ System.out.println(JSON.toJSONString(lombokTests));
+ }
+ } catch (Exception e) {
+ System.out.println(Throwables.getStackTraceAsString(e));
+
+ }
+ }
+
+ @AllArgsConstructor
+ @NoArgsConstructor
+ @Data
+ @Builder
+ public static class LombokTest{
+ private String name;
+ private String id;
+ }
+
+}
diff --git a/assess-web/target/classes/com/web/controller/TestController.class b/assess-web/target/classes/com/web/controller/TestController.class
new file mode 100644
index 0000000000000000000000000000000000000000..809ab93fd58ddda3194427aba59327d4d831c345
GIT binary patch
literal 2315
zcmb7FSyLQU6#gzV&;#iZ=mZk75@V8?EHv3zW|Ami0+?Y5n?h9V>AB1_^mGrskboUVN6X)#Byau$_1x|uA%R4#nz?
z7s$%?$*Cb702#JA>=>3e>N#91q++OLh`D5uY;SL`K^^KPC^EKV2gCMFJQ$>+@HZ`j
zjE9&3IRZ4STuKmX#7+sjWHezn!$I9HsMmQ$)osgjY}4e9I>ueE=h2WDns$ysN!w0N
zbHAm+Q=an%?S4DnpPI9+sxPM@2aoOC7!yJyo^FU>D4
zO-%R`t*!oItD8O3J3MJjNjT21^Kn?hlXv@undMFmjv*qN78xp9DOg&u$gM2H$<5T-
zAYd6LB_K}AID@kkAI}c=VAv5)Y;YmlHndCVkkN@G!*1PD^S)=>rYcUY_E9s!=Y0~L
z#L01LTQ}wMY(EObd4{cBzL&QhV@dN2+lqlQu*I|IxYhh$r4vkFmeGZ75+=_z5{#i^
z6EYhQx&GYYMIchI5KNb@^P(5SWrqEvwQ1-9J$1p#u0?v`%<);*w#4pzGWzi%a>{Ak9`F2*p)Q2XHXuU9`^`TgfFR+n!ln`5{}v3_`aW%cey
ze|&lO;kRG?`Qv8~ZkAR*Tz+tCIoT{S=uMG?Z!zo@XM9G+64ke%Nyy01L3z6K>AQ7V
z(>>c+3~7cJli~3Cp!JxV>!uPL?=R8sv9l!CwzOgKLBEjU&X|@lX@+jQu9*{>V~BBi
zGV0|G(%?|~UyDYHpuHfYn?`&~1arc04MOU&ESsdH1SO!3kdmlaxfw?*@awiS7gVE+
zVP#eAk*!+3AOn;^qKr}TSkO$Lcvh<6HZ@_@5T%Q5q^KJf;fZrRtt&a#_V$nUjdxFX
z4fjuvkE97@Z0O1*N}!1EnB?y8Fiog1JvWQ!&QV_Ib3`jpNCJgn-HWhR7PhFpK}{Pc
zS_FSyH_IT~KxrsyJ@um0r&o(wP9v4R
zjJ}n}R>1C3rvfw7ie;c4Icnw50C^a}`YgSG6@haveT7}aJxI#d61Lq#gRm(7C{h!6dlCH82+zLECE^v35eJBAc7ai)rP^fD#}4
z0mmj+a6&m!!pYUpiSvfE``1N!R8WrOSqD(Y^p3_s2;!G
zLY&x&(Re_34e)gW3uZ&mJ8Sb(<@uo!-k{CI=^}wtZP-fvLo_-}9FL$H33>=m;3!Vw
z6k3oZjW3`T-BhCn(19s>0UV?P6)uLSDytB|Cn#c`G^oPIWHV11RAU(~^&*66!lPc4
zkow?bfueYwcHRT_HyKw+Xq0ec-EWu{HwwE%VR(l&2*ZCch#yd`G~UPbH)s$kz}BTe
S9dUS<<|^=B045yY2mS#_M^y6w
literal 0
HcmV?d00001
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e807710
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,66 @@
+
+
+ 4.0.0
+
+ org.example
+ qiniuyun1024
+ 1.0-SNAPSHOT
+ pom
+
+
+ assess-web
+ assess-common
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.5.6
+
+
+
+
+ UTF-8
+ UTF-8
+
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 4.13.2
+
+
+
+
+ cn.hutool
+ hutool-all
+ 5.7.15
+
+
+
+
+ com.google.guava
+ guava
+ 31.0.1-jre
+
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.83
+
+
+
+
+
+
\ No newline at end of file
--
Gitee