diff --git a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java index 7e8c919..713bcc8 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java @@ -94,39 +94,49 @@ //todoを選んで達成状態を変更する //フォームパラメータでチェック状況 + //-1エラー 1達成 @PUT @Path("/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}/check") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void setCheck(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @FormParam("check") boolean check, @FormParam("token") String token) { if (accountManager.checkToken(account_id, token) == true) { - todoManager.setCheck(account_id, book_id, year, month, day, todo_id, check); + if (todoManager.setCheck(account_id, book_id, year, month, day, todo_id, check) == -1) { + var response = Response.status(Response.Status.BAD_REQUEST).entity("消去失敗"); + throw new WebApplicationException(response.build()); + } + }else{ + var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗"); + throw new WebApplicationException(response.build()); } } - //本のtodoを年月日とtodo_idを指定してそのtodoを削除する - //@DELETE - //@Path("/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") - //@Consumes(MediaType.APPLICATION_FORM_URLENCODED) - //public void deleteTodoById(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @QueryParam("token") String token){ - // if(accountManager.checkToken(account_id,token)==true) { - // todoManager.deleteTodoById(account_id, book_id, year, month, day, todo_id, token); - // } - //} + /* //本のtodoを年月日とtodo_idを指定してそのtodoを削除する + @DELETE + @Path("/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void deleteTodoById(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @QueryParam("token") String token){ + if(accountManager.checkToken(account_id,token)==true) { + todoManager.deleteTodoById(account_id, book_id, year, month, day, todo_id); + } + }*/ + //本のtodoを年月日とtodo_idを指定してそのtodoを削除する + //-1えらー 1達成 @DELETE @Path("/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void deleteTodoById(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @QueryParam("token") String token) { if (accountManager.checkToken(account_id, token) == true) { - if (todoManager.deleteTodoById(account_id, book_id, year, month, day, todo_id) == -1) { + if (todoManager.deleteTodoById(account_id, book_id, year, month, day, todo_id) == 1) { var response = Response.status(Response.Status.BAD_REQUEST).entity("消去失敗"); throw new WebApplicationException(response.build()); - } else { - var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗」"); - throw new WebApplicationException(response.build()); + } + }else { + var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗」"); + throw new WebApplicationException(response.build()); } } } -} +