diff --git a/src/main/java/org/ntlab/acanthus_server/entities/AnimationJson.java b/src/main/java/org/ntlab/acanthus_server/entities/AnimationJson.java new file mode 100644 index 0000000..e255853 --- /dev/null +++ b/src/main/java/org/ntlab/acanthus_server/entities/AnimationJson.java @@ -0,0 +1,31 @@ +package org.ntlab.acanthus_server.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "aid", + "animationName" +}) + +//----------------------------------------------------------------- +// 作品一覧取得用のJsonクラス + +public class AnimationJson { + @JsonProperty("aid") + private Integer aid; + + @JsonProperty("animationName") + private String animationName; + + + public AnimationJson(Animation animation){ + this.aid = animation.getAid(); + this.animationName = animation.getName(); + + } + + +} diff --git a/src/main/java/org/ntlab/acanthus_server/models/Gallery.java b/src/main/java/org/ntlab/acanthus_server/models/Gallery.java index 2ed3d3e..33ff5f3 100644 --- a/src/main/java/org/ntlab/acanthus_server/models/Gallery.java +++ b/src/main/java/org/ntlab/acanthus_server/models/Gallery.java @@ -32,15 +32,28 @@ } + + //----------------------------------------------------------------- + // 作品をすべて返す + public HashMap getMap(){return animationHashMap;} + //----------------------------------------------------------------- + // 1つの作品の全ての情報を返す. + public Animation getAnimationInformation( Integer aid){return animationHashMap.get(aid);} - public int registAnimation(String name, Account owner){ - var newAnimation = new Animation(name, owner); + + + //----------------------------------------------------------------- + // 作品を作る + + public int createAnimation(String animationName, Account owner){ + var newAnimation = new Animation(animationName, owner); var aid = new Random().nextInt(); newAnimation.setAid(aid); animationHashMap.put(aid,newAnimation); + newAnimation.setName(animationName); return aid; } 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 14d7e3d..8cbf468 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,7 +1,5 @@ package org.ntlab.acanthus_server.resources.accounts; -import org.ntlab.acanthus_server.entities.Account; -import org.ntlab.acanthus_server.entities.Animation; import org.ntlab.acanthus_server.entities.Work; import org.ntlab.acanthus_server.entities.WorkJson; import org.ntlab.acanthus_server.models.Accounts; @@ -10,7 +8,6 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; import java.util.Collection; @Component @@ -50,7 +47,7 @@ if(account != null && account.getToken().equals(token)){ //指定ユーザーの新しい作品の追加 String name = "aa"; - int newAid = gallery.registAnimation(name, account); + int newAid = gallery.createAnimation(name, account); var animation = gallery.getAnimationInformation(newAid); var newWork = new Work(); newWork.setWork(); diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java index af5ada5..8bf24de 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java @@ -24,11 +24,11 @@ @POST @Produces(MediaType.APPLICATION_JSON) - public Integer createAnimation(@FormParam("aid") Integer aid , @FormParam("name") String name ,@FormParam("token") String token ,@FormParam("uid") Integer uid){ + public Integer createAnimation(@FormParam("name") String animationName ,@FormParam("token") String token ,@FormParam("uid") Integer uid){ Accounts accounts = Accounts.getInstance(); Account Owner = accounts.getAccountByUid(uid); - return gallery.registAnimation(name, Owner); + return gallery.createAnimation(animationName, Owner); }