diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Animation.java b/src/main/java/org/ntlab/acanthus_server/entities/Animation.java index 2744949..9f51029 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Animation.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Animation.java @@ -2,9 +2,11 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Date; +import java.util.HashMap; public class Animation { - private Integer aid; + private int aid; private String name; private String description; private Boolean ispublic; @@ -13,19 +15,18 @@ private Integer likes; private Integer views; private ArrayList hashTag; - private Integer owner; + private Account owner; private ArrayList editors; private ArrayList invites; - private ArrayList pageMap; + private HashMap pageMap; - public Animation(String name, Integer owner) { - - //一意のaidをふる - // this.aid = - this.ispublic = false; + public Animation(String name, Account owner) { + Date dt = new Date(); + this.createdDate = dt.toString(); + setIsPublic(false); this.owner = owner; - //this.editors.add(Editor); - //this.pageMap.add(0, this.aid); + this.editors.add(new Editor(owner)); + this.pageMap.put(0, 0); } public void setName(String name){ @@ -43,4 +44,9 @@ public Collection getAnimationInvites() { return invites; } + + public Integer getAid() { + return aid; + } } + 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 e155267..077efb6 100644 --- a/src/main/java/org/ntlab/acanthus_server/models/Gallery.java +++ b/src/main/java/org/ntlab/acanthus_server/models/Gallery.java @@ -1,5 +1,6 @@ package org.ntlab.acanthus_server.models; +import org.ntlab.acanthus_server.entities.Account; import org.ntlab.acanthus_server.entities.Animation; import java.util.*; @@ -13,13 +14,13 @@ private static Gallery theInstance = null; private HashMap animationHashMap = new HashMap<>(); - //シングルトン取得 - public static Gallery getInstance() { - if (theInstance == null) { - theInstance = new Gallery(); - } - return theInstance; + //シングルトン取得 + public static Gallery getInstance() { + if (theInstance == null) { + theInstance = new Gallery(); } + return theInstance; + } /*インスタンス生成を禁止するコンストラクタ*/ private Gallery(){ @@ -28,4 +29,11 @@ public HashMap getMap(){return animationHashMap;} -} + public int registAnimation(String name, Account owner){ + var newAnimation = new Animation(name, owner); + var aid = new Random().nextInt(); + animationHashMap.put(aid,newAnimation); + return aid; + } + +} \ No newline at end of file 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 59f4a89..2bd2f86 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 @@ -1,12 +1,15 @@ 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.models.Accounts; import org.ntlab.acanthus_server.models.Gallery; import org.springframework.stereotype.Component; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; +//import java.security.acl.Owner; import java.util.*; @Component @@ -21,14 +24,13 @@ @POST @Produces(MediaType.APPLICATION_JSON) - public void createAnimation(@FormParam("aid") Integer aid , @FormParam("name") String name ,@FormParam("token") String token){ + public Integer createAnimation(@FormParam("aid") Integer aid , @FormParam("name") String name ,@FormParam("token") String token ,@FormParam("uid") Integer uid){ - + Accounts accounts = Accounts.getInstance(); + Account Owner = accounts.getAccountByUid(uid); + return gallery.registAnimation(name, Owner); } -} - - - +} \ No newline at end of file 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 bca3267..6176f0e 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 @@ -45,4 +45,4 @@ return "追加しました"; } -} +} \ No newline at end of file