diff --git a/src/main/java/org/ntlab/acanthus_server/entities/InvitesJson.java b/src/main/java/org/ntlab/acanthus_server/entities/InvitesJson.java new file mode 100644 index 0000000..48a4d53 --- /dev/null +++ b/src/main/java/org/ntlab/acanthus_server/entities/InvitesJson.java @@ -0,0 +1,25 @@ +package org.ntlab.acanthus_server.entities; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Collection; + +public class InvitesJson { + + @JsonProperty("invites") + private Collection invites; + + public InvitesJson(Collection accounts) { + for(Account inviter : accounts){ + this.invites.add(inviter.getUid()); + } + } + + public Collection getInvitesJson() { + return invites; + } + + public void setInvitesJson(Integer uid){ + this.invites.add(uid); + } +} diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/InvitesRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/InvitesRest.java index 6109de2..eb3a411 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/InvitesRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/InvitesRest.java @@ -1,12 +1,11 @@ package org.ntlab.acanthus_server.resources.gallery; -import org.ntlab.acanthus_server.entities.Account; -import org.ntlab.acanthus_server.entities.Animation; -import org.ntlab.acanthus_server.entities.Editor; -import org.ntlab.acanthus_server.entities.Work; +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 org.ntlab.acanthus_server.entities.InvitesJson; + import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -34,14 +33,14 @@ @Path("/{aid}/invites") @GET @Produces(MediaType.APPLICATION_JSON) - public Collection isGalleryInvites(@PathParam("aid") Integer aid, @QueryParam("invitedUid") String invitedUid, @QueryParam("invitedUserToken") String invitedUserToken, @QueryParam("ownerToken") String ownerToken) { + public InvitesJson isGalleryInvites(@PathParam("aid") Integer aid, @QueryParam("invitedUid") String invitedUid, @QueryParam("invitedUserToken") String invitedUserToken, @QueryParam("ownerToken") String ownerToken) { Animation animation = animations.getAnimationByAid(aid); //招待した人を確認する if (invitedUid == null && invitedUserToken == null) { Account owner = animation.getOwner(); if (owner != null && owner.getToken().equals(ownerToken)) { - return animation.getInvites(); + return new InvitesJson(animation.getInvites()); } else { throw new WebApplicationException(404); } @@ -52,7 +51,7 @@ Account invitedAccount = accounts.getAccountByUid(Integer.parseInt(invitedUid)); if (invitedAccount != null && invitedAccount.getToken().equals(invitedUserToken)) { //相手の作品の招待リストの中に自分が存在する - return animation.searchAnimationInvites(invitedAccount); + return new InvitesJson(animation.searchAnimationInvites(invitedAccount)); } else { //相手の作品の招待リストの中に自分が存在しない throw new WebApplicationException(404); @@ -141,4 +140,4 @@ } } -} \ No newline at end of file +}