diff --git a/src/main/java/org/ntlab/acanthus_server/entities/AidJson.java b/src/main/java/org/ntlab/acanthus_server/entities/AidJson.java new file mode 100644 index 0000000..f333f0d --- /dev/null +++ b/src/main/java/org/ntlab/acanthus_server/entities/AidJson.java @@ -0,0 +1,22 @@ +package org.ntlab.acanthus_server.entities; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AidJson { + @JsonProperty("message") + private String message = "success"; + @JsonProperty("aid") + private Integer aid; + + public AidJson(Integer aid){ + this.aid = aid; + } + + public Integer getAid() { + return aid; + } + + public void setAid(Integer aid){ + this.aid = aid; + } +} diff --git a/src/main/java/org/ntlab/acanthus_server/entities/WorkJson.java b/src/main/java/org/ntlab/acanthus_server/entities/WorkJson.java index db60023..2bf3752 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/WorkJson.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/WorkJson.java @@ -1,9 +1,12 @@ package org.ntlab.acanthus_server.entities; +import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.ArrayList; import java.util.Collection; public class WorkJson { + @JsonProperty("aid") private ArrayList aid = new ArrayList<>(); //ユーザーの制作作品idをレスポンスとして返す際に、JSONのレスポンスに合わせる @@ -14,7 +17,6 @@ aid.add(strAid); } - getAid(); } public Collection getAid() { diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/WorkRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/WorkRest.java index 8d0cc89..fde3b20 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/WorkRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/WorkRest.java @@ -1,5 +1,6 @@ package org.ntlab.acanthus_server.resources.accounts; +import org.ntlab.acanthus_server.entities.AidJson; import org.ntlab.acanthus_server.entities.Work; import org.ntlab.acanthus_server.entities.WorkJson; import org.ntlab.acanthus_server.models.Accounts; @@ -41,7 +42,7 @@ @Path("/{uid}/work") @POST @Produces(MediaType.APPLICATION_JSON) - public Integer createWork(@PathParam("uid") Integer uid, @FormParam("name") String animationName, @FormParam("token") String token){ + public AidJson createWork(@PathParam("uid") Integer uid, @FormParam("name") String animationName, @FormParam("token") String token){ var account = accounts.getAccountByUid(uid); if(account != null && account.getToken().equals(token)){ @@ -49,10 +50,12 @@ int newAid = gallery.createAnimation(animationName, account); //新しい作品の作成 var animation = gallery.getAnimationInformation(newAid); //作成した作品情報取得 var newWork = new Work(); //ユーザーの制作作品の作成 + newWork.setWork(); newWork.setAnimation(animation); account.addWork(newWork); - return newAid; + + return new AidJson(newAid); }else{ //ユーザーID、トークンが間違っている時のレスポンス throw new WebApplicationException(401);