瀏覽代碼

i am a LEGEND

nafis nibir 6 年之前
父節點
當前提交
52d44cfee7
共有 3 個文件被更改,包括 22 次插入7 次删除
  1. 1
    2
      Client/src/main/java/Id.java
  2. 5
    2
      Client/src/main/java/SimpleShell.java
  3. 16
    3
      Client/src/main/java/YouAreEll.java

+ 1
- 2
Client/src/main/java/Id.java 查看文件

@@ -1,5 +1,5 @@
1 1
 public class Id {
2
-    private String userid = "";
2
+    private String userid;
3 3
     private String name;
4 4
     private String github;
5 5
 
@@ -7,7 +7,6 @@ public class Id {
7 7
         return userid;
8 8
     }
9 9
 
10
-    public Id(){}
11 10
 
12 11
     public Id( String userid, String name, String github) {
13 12
         this.userid = userid;

+ 5
- 2
Client/src/main/java/SimpleShell.java 查看文件

@@ -82,7 +82,10 @@ public class SimpleShell {
82 82
                         SimpleShell.prettyPrint(result);
83 83
                     } else {
84 84
                     //SUPPOSED TO UPDATE A USER BUT IT DOESNT WORK FML
85
-                        Id id = new Id("",list.get(2) , list.get(3));
85
+                    //BUT GUESS WHAT IT FUCKING WORKS NOW HA HA
86
+                        String userid = webber.get_userid(list.get(3));
87
+                        String trimmed = userid.substring(3,userid.length()-3);
88
+                        Id id = new Id( trimmed,list.get(2) , list.get(3));
86 89
                         String result = webber.put_id(id);
87 90
                         SimpleShell.prettyPrint(result);
88 91
                     }
@@ -101,7 +104,7 @@ public class SimpleShell {
101 104
                         SimpleShell.prettyPrint(results);
102 105
                     } else if (list.size() == 3){
103 106
                     // get messages for a person from another person DOESNT WORK
104
-                        String results = webber.get_messages(list.get(1), list.get(2));
107
+                        String results = webber.get_messages_from(list.get(1), list.get(2));
105 108
                         SimpleShell.prettyPrint(results);
106 109
                     }
107 110
                     continue;

+ 16
- 3
Client/src/main/java/YouAreEll.java 查看文件

@@ -24,6 +24,11 @@ public class YouAreEll {
24 24
         return MakeURLCall("/ids", "GET", "");
25 25
     }
26 26
 
27
+    public String get_userid(String github) throws IOException{
28
+
29
+        return MakeURLCall("/ids/" + github, "GET", "");
30
+    }
31
+
27 32
     public String post_id(String jpayload) throws IOException{
28 33
 
29 34
         return MakeURLCall("/ids", "POST", jpayload);
@@ -35,16 +40,24 @@ public class YouAreEll {
35 40
     }
36 41
 
37 42
     public String get_messages(String...path) throws IOException{
43
+
38 44
         String mainurl = "/messages";
39
-        if (path.length > 0)
45
+        if (path.length > 0) {
40 46
             mainurl = "/ids/" + path[0] + mainurl;
41
-
42
-        if (path.length > 1)
47
+        }
48
+        if (path.length > 1) {
43 49
             mainurl = mainurl + "/" + path[1];
50
+        }
44 51
 
45 52
         return MakeURLCall(mainurl, "GET", "");
46 53
     }
47 54
 
55
+    public String get_messages_from(String to, String from) throws IOException{
56
+        String nutty = "/ids/" + to + "/from/" + from;
57
+        System.out.println(nutty);
58
+        return MakeURLCall(nutty, "GET", "");
59
+    }
60
+
48 61
     public String post_messages(Message message) throws IOException{
49 62
         String jpayload = mapper.writeValueAsString(message);
50 63
         if (message.getToid().equalsIgnoreCase("")){