diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Editor.java b/src/main/java/org/ntlab/acanthus_server/entities/Editor.java index a9a1167..54f8f57 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Editor.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Editor.java @@ -1,10 +1,26 @@ package org.ntlab.acanthus_server.entities; public class Editor { - public Editor(Account owner){ - } - /* - public boolean owner(){return false;} - */ + private Account account; + private Boolean isOwner = false; + private Integer page; + private Integer layer; + public Editor(Account account){ + this.account = account; + isOwner = false; + } + public Editor(Account account, boolean isOwner){ + this.account = account; + this.isOwner = isOwner; + } + public Account getAccount() { + return account; + } + public void setAccount(Account account) { + this.account = account; + } + + public Account getEditor(){ return this.account; } + public void setAnimation(Account editor) { this.account = account; } } diff --git a/src/main/java/org/ntlab/acanthus_server/entities/EditorJson.java b/src/main/java/org/ntlab/acanthus_server/entities/EditorJson.java new file mode 100644 index 0000000..850a17a --- /dev/null +++ b/src/main/java/org/ntlab/acanthus_server/entities/EditorJson.java @@ -0,0 +1,25 @@ +package org.ntlab.acanthus_server.entities; + +import java.util.ArrayList; +import java.util.Collection; + +public class EditorJson { + private ArrayList uid = new ArrayList<>(); + + //ユーザーの制作作品idをレスポンスとして返す際に、JSONのレスポンスに合わせる + public EditorJson(Collection editorList){ + for (var intUid : editorList){ + String strUid = "/Editor/" + intUid.getEditor().getUid(); + uid.add(strUid); + } + getUid(); + } + + public Collection getUid() { + return uid; + } + + public void setAid(ArrayList uid) { + this.uid = uid; + } +} 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 41c423d..f55f30b 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,23 +1,38 @@ package org.ntlab.acanthus_server.resources.gallery; +import org.ntlab.acanthus_server.entities.*; import org.ntlab.acanthus_server.models.Accounts; +import org.ntlab.acanthus_server.models.Gallery; import org.springframework.stereotype.Component; +import javax.validation.constraints.Null; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.util.Collection; @Component -@Path("gallery") -public class EditorsRest { - private Accounts accounts = Accounts.getInstance(); +@Path("/gallery") +public class EditorsRest { + //private Accounts accounts = Accounts.getInstance(); + private Gallery gallery = Gallery.getInstance(); /* Editorに追加 */ @Path("{aid}/Editors") @GET - public String getEditors(@PathParam("aid")Integer aid, @QueryParam("uid") Integer uid, @QueryParam("token") String token) { - var account = accounts.getAccountByUid(uid); - return "Ok"; + @Produces(MediaType.APPLICATION_JSON) + public Collection getEditors(@PathParam("aid")Integer aid, @QueryParam("uid") Integer uid) { + var atGallery = gallery.getAnimationInformation(aid); + + if(atGallery != null){ + //指定作成のエディターを表示 + Collection editorList = atGallery.getEditors(); + return editorList; + }else{ + //aid間違っている時のレスポンス + throw new WebApplicationException(401); + } } /* @@ -25,13 +40,15 @@ */ @Path("/{aid}/Editors") @PUT + @Produces(MediaType.APPLICATION_JSON) public String addEditors(@PathParam("aid")Integer aid, @FormParam("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); - } + /*var account = accounts.getAccountByUid(uid); + var animation = gallery.getAnimationInformation(aid); + if (account != null && animation != null && account.getToken().equals(token)) { + return "ok"; + } else {*/ + //ユーザーID、トークンが間違っている時のレスポンス + throw new WebApplicationException(401); +// } } }