diff --git a/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java b/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java index 3a0fcc5..069f791 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/TodoManager.java @@ -1,12 +1,7 @@ package org.ntlab.citrusserver.repositories; import org.ntlab.citrusserver.entities.Todo; -import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Repository; -import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.server.ResponseStatusException; import java.util.HashMap; @@ -52,7 +47,7 @@ * } */ public HashMap>>> - getAllTodos(String accountId, int bookId, String token){ + getAllTodos(String accountId, int bookId){ if(!todos.containsKey(accountId)){ return null; } @@ -68,7 +63,7 @@ * @param month 月 * @return そのアカウントの本に所属するtodoのうち、指定した年月のtodoを返します */ - public HashMap> getTodosByMonth(String accountId, int bookId, int year, int month, String token){ + public HashMap> getTodosByMonth(String accountId, int bookId, int year, int month){ if(!todos.containsKey(accountId)){ return null; } @@ -89,11 +84,11 @@ * @param yearMonth 年月を-で区切った文字列(yyyy-mm) * @return そのアカウントの本に所属するtodoのうち、指定した年月のtodoを返します */ - public HashMap> getTodosByMonth(String accountId, int bookId, String yearMonth, String token){ + public HashMap> getTodosByMonth(String accountId, int bookId, String yearMonth){ String[] yearMonths = yearMonth.split("-"); int year = Integer.parseInt(yearMonths[0]); int month = Integer.parseInt(yearMonths[1]); - return getTodosByMonth(accountId, bookId, year, month, token); + return getTodosByMonth(accountId, bookId, year, month); } /** @@ -106,7 +101,7 @@ * @param day 日 * @return そのアカウントの本に所属するtodoのうち、指定した年月日のtodoを返します */ - public HashMap getTodosByDay(String accountId, int bookId, int year, int month, int day, String token){ + public HashMap getTodosByDay(String accountId, int bookId, int year, int month, int day){ if(!todos.get(accountId).get(bookId).containsKey(year)){ return null; } @@ -127,12 +122,12 @@ * @param yearMonthDay 年月日を-で区切った文字列(yyyy-mm-dd) * @return そのアカウントの本に所属するtodoのうち、指定した年月日のtodoを返します */ - public HashMap getTodosByDay(String accountId, int bookId, String yearMonthDay, String token){ + public HashMap getTodosByDay(String accountId, int bookId, String yearMonthDay){ String[] yearMonthDays = yearMonthDay.split("-"); int year = Integer.parseInt(yearMonthDays[0]); int month = Integer.parseInt(yearMonthDays[1]); int day = Integer.parseInt(yearMonthDays[2]); - return getTodosByDay(accountId, bookId, year, month, day, token); + return getTodosByDay(accountId, bookId, year, month, day); } @@ -147,7 +142,7 @@ * @param todoId todoのid * @return idを指定してtodoを返す */ - public Todo getTodoById(String accountId, int bookId, int year, int month, int day, int todoId, String token){ + public Todo getTodoById(String accountId, int bookId, int year, int month, int day, int todoId){ if(!todos.containsKey(accountId)){ return null; } @@ -175,12 +170,12 @@ * @param todoId todoのid * @return 指定したtodo */ - public Todo getTodoById(String accountId, int bookId, String yearMonthDay, int todoId, String token){ + public Todo getTodoById(String accountId, int bookId, String yearMonthDay, int todoId){ String[] yearMonthDays = yearMonthDay.split("-"); int year = Integer.parseInt(yearMonthDays[0]); int month = Integer.parseInt(yearMonthDays[1]); int day = Integer.parseInt(yearMonthDays[2]); - return getTodoById(accountId, bookId, year, month, day, todoId, token); + return getTodoById(accountId, bookId, year, month, day, todoId); } /** @@ -194,8 +189,8 @@ * @param title 追加するべきtodoのタイトル * @return 新しいtodoのid */ - public Todo createTodo(String accountId, int bookId, int year, int month, int day, String title, String token){ - if(bookManager.getBooks(accountId, token) == null){ + public Todo createTodo(String accountId, int bookId, int year, int month, int day, String title){ + if(bookManager.getBooks(accountId) == null){ return null; } if(!todos.containsKey(accountId)){ @@ -235,12 +230,12 @@ * @param title 追加したいtodoのタイトル * @return 新しいtodoのid */ - public Todo createTodo(String accountId, int bookId, String yearMonthDay, String title, String token){ + public Todo createTodo(String accountId, int bookId, String yearMonthDay, String title){ String[] yearMonthDays = yearMonthDay.split("-"); int year = Integer.parseInt(yearMonthDays[0]); int month = Integer.parseInt(yearMonthDays[1]); int day = Integer.parseInt(yearMonthDays[2]); - return createTodo(accountId, bookId, year, month, day, title, token); + return createTodo(accountId, bookId, year, month, day, title); } /** @@ -250,7 +245,7 @@ * @param bookId 本のid * @param todoId 削除したいtodoのid */ - public int deleteTodoById(String accountId, int bookId, int year, int month, int day, int todoId, String token){ + public int deleteTodoById(String accountId, int bookId, int year, int month, int day, int todoId){ if(!todos.containsKey(accountId)){ return -1; } @@ -280,13 +275,14 @@ * @param bookId 本のid * @param yearMonthDay 年月日を-で区切った文字列(yyyy-mm-dd) * @param todoId 削除したいtodoのid + * @return 0 -> 成功
-1 -> 失敗 */ - public void deleteTodoById(String accountId, int bookId, String yearMonthDay, int todoId, String token){ + public int deleteTodoById(String accountId, int bookId, String yearMonthDay, int todoId){ String[] yearMonthDays = yearMonthDay.split("-"); int year = Integer.parseInt(yearMonthDays[0]); int month = Integer.parseInt(yearMonthDays[1]); int day = Integer.parseInt(yearMonthDays[2]); - deleteTodoById(accountId, bookId, year, month, day, todoId, token); + return deleteTodoById(accountId, bookId, year, month, day, todoId); } /** @@ -296,8 +292,9 @@ * @param bookId 本のid * @param todoId 変更したいtodoのid * @param check 変更後の達成状態 + * @return 0 -> 成功
-1 -> 失敗 */ - public int setCheck(String accountId, int bookId, int year, int month, int day, int todoId, boolean check, String token){ + public int setCheck(String accountId, int bookId, int year, int month, int day, int todoId, boolean check){ if(!todos.containsKey(accountId)){ return -1; } @@ -328,12 +325,13 @@ * @param yearMonthDay 年月日を-で区切った文字列(yyyy-mm-dd) * @param todoId 変更したいtodoのid * @param check 変更後の達成状態 + * @return 0 -> 成功
-1 -> 失敗 */ - public void setCheck(String accountId, int bookId, String yearMonthDay, int todoId, boolean check, String token){ + public int setCheck(String accountId, int bookId, String yearMonthDay, int todoId, boolean check){ String[] yearMonthDays = yearMonthDay.split("-"); int year = Integer.parseInt(yearMonthDays[0]); int month = Integer.parseInt(yearMonthDays[1]); int day = Integer.parseInt(yearMonthDays[2]); - setCheck(accountId, bookId, year, month, day, todoId, check, token); + return setCheck(accountId, bookId, year, month, day, todoId, check); } }