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 deleted file mode 100644 index 14d7e3d..0000000 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/WorkRest.java +++ /dev/null @@ -1,85 +0,0 @@ -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; -import org.ntlab.acanthus_server.models.Gallery; -import org.springframework.stereotype.Component; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.Collection; - -@Component -@Path("/accounts") -public class WorkRest -{ - private Accounts accounts = Accounts.getInstance(); - private Gallery gallery = Gallery.getInstance(); - - //各ユーザーの作品を取得するメソッド - - @Path("/{uid}/work") - @GET - @Produces(MediaType.APPLICATION_JSON) - public WorkJson getWork(@PathParam("uid") Integer uid, @QueryParam("token") String token) { - var account = accounts.getAccountByUid(uid); - - if(account != null && account.getToken().equals(token)){ - //指定ユーザーの制作作品の表示 - Collection workList = account.getWorkingList().values(); - return new WorkJson(workList); - }else{ - //ユーザーID、トークンが間違っている時のレスポンス - throw new WebApplicationException(401); - } - - } - - //新しい作品を制作するメソッド - - @Path("/{uid}/work") - @POST - @Produces(MediaType.APPLICATION_JSON) - public Integer createWork(@PathParam("uid") Integer uid, @FormParam("token") String token){ - var account = accounts.getAccountByUid(uid); - - if(account != null && account.getToken().equals(token)){ - //指定ユーザーの新しい作品の追加 - String name = "aa"; - int newAid = gallery.registAnimation(name, account); - var animation = gallery.getAnimationInformation(newAid); - var newWork = new Work(); - newWork.setWork(); - newWork.setAnimation(animation); - account.addWork(newWork); - return newAid; - }else{ - //ユーザーID、トークンが間違っている時のレスポンス - throw new WebApplicationException(401); - } - - } - - //作品への参加を許可するメソッド - - @Path("/{uid}/work") - @PUT - @Produces(MediaType.APPLICATION_JSON) - public String updateWork(@PathParam("uid") Integer uid, @FormParam("token") String token, @FormParam("aid") Integer aid) { - var account = accounts.getAccountByUid(uid); - - if(account != null && account.getToken().equals(token)){ - //指定ユーザーの制作作品への参加の許可 - return "fake3"; - }else{ - //ユーザーID、トークンが間違っている時のレスポンス - throw new WebApplicationException(401); - } - - } - -}