diff --git a/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java b/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java index 4595917..ca98622 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java @@ -338,7 +338,8 @@ return 1; } - public int setTodo(String accountId, int bookId, int year, int month, int day, int todoId, String title){ + public int setTodo(String accountId, int bookId, int year, int month, int day, + int newBookId, int newYear, int newMonth, int newDay, int todoId, String title){ if(!todos.containsKey(accountId)){ return -1; } @@ -357,11 +358,8 @@ if(!todos.get(accountId).get(bookId).get(year).get(month).get(day).containsKey(todoId)){ return -1; } - todos.get(accountId).get(bookId).get(year).get(month).get(day).get(todoId).setTitle(title); - todos.get(accountId).get(bookId).get(year).get(month).get(day).get(todoId).setBookId(bookId); - todos.get(accountId).get(bookId).get(year).get(month).get(day).get(todoId).setYear(year); - todos.get(accountId).get(bookId).get(year).get(month).get(day).get(todoId).setMonth(month); - todos.get(accountId).get(bookId).get(year).get(month).get(day).get(todoId).setDay(day); + todos.get(accountId).get(bookId).get(year).get(month).get(day).remove(todoId); + createTodo(accountId, newBookId, newYear, newMonth, newDay, title); return 1; } diff --git a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java index b435fc2..2ef7939 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java @@ -119,10 +119,10 @@ @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) public void setTodo(@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("title") String title, + @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @FormParam("title") String title, @FormParam("new_book_id") Integer newBookId, @FormParam("new_year") Integer new_year,@FormParam("new_month") Integer new_month,@FormParam("new_day") Integer new_day, @FormParam("token") String token){ if (accountManager.checkToken(account_id, token)) { - if (todoManager.setTodo(account_id, book_id, new_year, new_month, new_day, todo_id, title) == -1) { + if (todoManager.setTodo(account_id, book_id, year, month, day, newBookId, new_year, new_month, new_day, todo_id, title) == -1) { var response = Response.status(Response.Status.BAD_REQUEST).entity("変更失敗"); throw new WebApplicationException(response.build()); }