diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java index 50fe520..a990c50 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java @@ -1,5 +1,6 @@ package org.ntlab.acanthus_server.resources.gallery; +import org.ntlab.acanthus_server.models.Accounts; import org.springframework.stereotype.Component; import javax.ws.rs.*; @@ -7,21 +8,31 @@ @Component @Path("gallery") public class EditorsRest { + private Accounts accounts = Accounts.getInstance(); + /* - 各ユーザーの作品を取得するメソッド + Editorに追加 + */ @Path("{aid}/Editors") @GET - public String getEditors(@PathParam("uid") String uid, @QueryParam("token") String token) { + public String getEditors(@QueryParam("uid") Integer uid, @QueryParam("token") String token) { + var account = accounts.getAccountByUid(uid); return "Ok"; } /* - 作品への参加を許可するメソッド + galleryのinvitesにいるか確認 */ @Path("/{aid}/Editors") @PUT - public String addEditors(@PathParam("uid")String uid, @FormParam("token") String token) { - return "Ok"; + public String addEditors(@QueryParam("uid")Integer uid, @FormParam("token") String token) { + var account = accounts.getAccountByUid(uid); + if(uid != null && account.getToken().equals(token)){ + return "OK"; + } + else { + throw new WebApplicationException(401); + } } }