diff --git a/.gradle/8.14/fileChanges/last-build.bin b/.gradle/8.14/fileChanges/last-build.bin
deleted file mode 100644
index f76dd23..0000000
--- a/.gradle/8.14/fileChanges/last-build.bin
+++ /dev/null
Binary files differ
diff --git a/.gradle/8.14/gc.properties b/.gradle/8.14/gc.properties
deleted file mode 100644
index e69de29..0000000
--- a/.gradle/8.14/gc.properties
+++ /dev/null
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
deleted file mode 100644
index e69de29..0000000
--- a/.gradle/vcs-1/gc.properties
+++ /dev/null
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 9080f9e..9879958 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/build/classes/java/main/org/ntlab/tampoposerver/JerseyConfig.class b/build/classes/java/main/org/ntlab/tampoposerver/JerseyConfig.class
deleted file mode 100644
index aca4086..0000000
--- a/build/classes/java/main/org/ntlab/tampoposerver/JerseyConfig.class
+++ /dev/null
Binary files differ
diff --git a/build/classes/java/main/org/ntlab/tampoposerver/ServletInitializer.class b/build/classes/java/main/org/ntlab/tampoposerver/ServletInitializer.class
deleted file mode 100644
index 0db777a..0000000
--- a/build/classes/java/main/org/ntlab/tampoposerver/ServletInitializer.class
+++ /dev/null
Binary files differ
diff --git a/build/classes/java/main/org/ntlab/tampoposerver/TampopoServerApplication.class b/build/classes/java/main/org/ntlab/tampoposerver/TampopoServerApplication.class
deleted file mode 100644
index 91eb52f..0000000
--- a/build/classes/java/main/org/ntlab/tampoposerver/TampopoServerApplication.class
+++ /dev/null
Binary files differ
diff --git a/build/classes/java/main/org/ntlab/tampoposerver/models/User.class b/build/classes/java/main/org/ntlab/tampoposerver/models/User.class
deleted file mode 100644
index 93237a2..0000000
--- a/build/classes/java/main/org/ntlab/tampoposerver/models/User.class
+++ /dev/null
Binary files differ
diff --git a/build/classes/java/main/org/ntlab/tampoposerver/repositories/UserRepository.class b/build/classes/java/main/org/ntlab/tampoposerver/repositories/UserRepository.class
deleted file mode 100644
index d0ae91f..0000000
--- a/build/classes/java/main/org/ntlab/tampoposerver/repositories/UserRepository.class
+++ /dev/null
Binary files differ
diff --git a/build/resources/main/application.properties b/build/resources/main/application.properties
deleted file mode 100644
index 5370fb9..0000000
--- a/build/resources/main/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-spring.application.name=tampopo-server
diff --git a/build/tmp/bootWar/MANIFEST.MF b/build/tmp/bootWar/MANIFEST.MF
deleted file mode 100644
index 59499bc..0000000
--- a/build/tmp/bootWar/MANIFEST.MF
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-
diff --git a/build/tmp/war/MANIFEST.MF b/build/tmp/war/MANIFEST.MF
deleted file mode 100644
index 59499bc..0000000
--- a/build/tmp/war/MANIFEST.MF
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-
diff --git a/src/main/java/org/ntlab/tampoposerver/resources/FriendsResource.java b/src/main/java/org/ntlab/tampoposerver/resources/FriendsResource.java
index df7ee74..01502e8 100644
--- a/src/main/java/org/ntlab/tampoposerver/resources/FriendsResource.java
+++ b/src/main/java/org/ntlab/tampoposerver/resources/FriendsResource.java
@@ -1,18 +1,104 @@
package org.ntlab.tampoposerver.resources;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.QueryParam;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.ntlab.tampoposerver.models.FriendPair;
+import org.ntlab.tampoposerver.repositories.UserRepository;
+import org.ntlab.tampoposerver.services.FriendService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;
+import java.util.UUID;
+
@Path("/friends")
@Component
public class FriendsResource {
- @Path("/{pair-id}")
- @GET
- public String getFriends(@QueryParam("token") String token, @PathParam("pair-id") String pairId) {
- return "Hello World!!";
+
+ private UserRepository userRepository = null;
+ private FriendService friendService = null;
+
+ @Autowired
+ public FriendsResource(UserRepository userRepository, FriendService friendService) {
+ this.userRepository = userRepository;
+ this.friendService = friendService;
}
+
+
+
+ @Path("/{pair-id}")
+ @GET
+ public Response getFriend(@QueryParam("token") String token, @PathParam("pair-id") int pairId) {
+ //400
+
+ //200
+ FriendPair pair = friendService.getFriendPair(token, pairId);
+ if (pair == null) {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ return Response.status(Response.Status.OK).build();
+ }
+ @POST
+ @Consumes (MediaType.APPLICATION_FORM_URLENCODED)
+ public void postFriends(@FormParam("token")String token,@FormParam("user0-id")String user0Id,@FormParam("user1-id")String user1Id){
+ //400
+ if (token.isBlank()){ //トークンが空文字だった時
+ var response = Response.status(Response.Status.NOT_FOUND).entity("不正なリクエストです!");
+ throw new WebApplicationException(response.build());
+ }
+ //401
+ //if (!UserRepository.getUser()){ //トークンが通らなかった時
+ // var response = Response.status(Response.Status.NOT_FOUND).entity("トークンが無効です。");//404
+ // throw new WebApplicationException(response.build());
+ //}
+
+ //403
+
+ //404
+ //if (!friendService.createFriendPair(user0Id,user1Id){ //ユーザIDが変化した時、
+ // var response = Response.status(Response.Status.NOT_FOUND).entity("データが存在しません。");//404
+ // throw new WebApplicationException(response.build());
+ //}
+
+
+ //200
+
+ //500は勝手にサーバがエラーでたらでるから書かない
+
+
+ return;
+ }
+ @Path("/{pair-id}")
+ @DELETE
+ public Response deleteFriend(@QueryParam("token") String token, @PathParam("pair-id") Integer pairId) {
+ //400
+ if (token.isBlank()){ //トークンが空文字だった時
+ var response = Response.status(Response.Status.NOT_FOUND).entity("不正なリクエストです。");
+ throw new WebApplicationException(response.build());
+ }
+
+ //401
+ //if (!userRepository.getUser()){ //トークンが通らなかった時
+ // var response = Response.status(Response.Status.NOT_FOUND).entity("トークンが無効です。");//404
+ // throw new WebApplicationException(response.build());
+ //}
+ //403ここで書く必要なし
+
+ //404
+ if (!friendService.removeFriendPair(token,pairId)){ //トークンに対応したユーザが選択したフレンドが存在しない時
+ var response = Response.status(Response.Status.NOT_FOUND).entity("データが存在しないです。");//404
+ throw new WebApplicationException(response.build());
+ }
+
+ //200
+ return Response.status(Response.Status.OK).build();
+
+ //500は勝手にサーバがエラーでたらでるから書かない
+ }
+
+
}
+