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 656618a..af1f83c 100644 --- a/src/main/java/org/ntlab/acanthus_server/models/Gallery.java +++ b/src/main/java/org/ntlab/acanthus_server/models/Gallery.java @@ -1,4 +1,29 @@ package org.ntlab.acanthus_server.models; +import java.util.*; + +/* + * 作品管理シングルトン + * + */ + public class Gallery { + private static Gallery theInstance = null; + private HashMap animationHashMap = new HashMap<>(); + + //シングルトン取得 + public static Gallery getInstance() { + if (theInstance == null) { + theInstance = new Gallery(); + } + return theInstance; + } + + /*インスタンス生成を禁止するコンストラクタ*/ + private Gallery(){ + + } + + public HashMap getMap(){return animationMap;} + } 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 a41d637..ce1980c 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,16 +1,31 @@ package org.ntlab.acanthus_server.resources.gallery; +import org.ntlab.acanthus_server.models.Gallery; import org.springframework.stereotype.Component; -import javax.ws.rs.GET; -import javax.ws.rs.Path; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +import java.util.*; @Component @Path("/gallery") public class GalleryRest { + private Gallery gallery = Gallery.getInstance(); + @GET - public String getGallery(){return "anime";} + @Produces(MediaType.APPLICATION_JSON) + public Collection getGallery(){return gallery.getMap().values();} + + @POST + @Produces(MediaType.APPLICATION_JSON) + public void createAnimetion(@FormParam("aid") Integer aid , @FormParam("name") String name ,@FormParam("token") String token{ + + + + } + }