diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java index 88b550c..0b601a6 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java @@ -1,7 +1,9 @@ package org.ntlab.acanthus_server.resources.gallery; import org.ntlab.acanthus_server.entities.Layer; +import org.ntlab.acanthus_server.entities.Page; import org.ntlab.acanthus_server.entities.Position; +import org.ntlab.acanthus_server.entities.Stroke; import org.ntlab.acanthus_server.models.Gallery; import org.springframework.stereotype.Component; @@ -26,7 +28,7 @@ @GET @Produces(MediaType.APPLICATION_JSON) public Integer getLayers(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid) { - var pages = gallery.getAnimationByAid(aid).getPages(); + var pages = gallery.getAnimationByAid(aid).getPageMap(); return pages.get(pid).getLayers().size(); } @@ -40,13 +42,15 @@ @POST @Produces(MediaType.APPLICATION_JSON) public Integer addLayer(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid) { - var pages = gallery.getAnimationByAid(aid).getPages(); + var pages = gallery.getAnimationByAid(aid).getPageMap(); - if (pages.get(pid).getLayers().size() < 4) { - pages.get(pid).getLayers().add(new Layer()); + for (var p : pages) { + if (!p.getPid().equals(pid)) continue; + page = p; + if (p.getLayers().size() < layerSize) p.getLayers().add(new Layer()); } - return pages.get(pid).getLayers().size(); + return page.getLayers().size(); } @@ -60,7 +64,7 @@ @GET @Produces(MediaType.APPLICATION_JSON) public Integer getStrokeNo(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("layerNo") Integer layerNo) { - var pages = gallery.getAnimationByAid(aid).getPages(); + var pages = gallery.getAnimationByAid(aid).getPageMap(); var strokes = pages.get(pid).getLayers().get(layerNo).getStrokes(); if (strokes == null) return null;