diff --git a/src/main/java/org/ntlab/citrusserver/repositories/ScheduleManager.java b/src/main/java/org/ntlab/citrusserver/repositories/ScheduleManager.java index 6153a9a..6a425ae 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/ScheduleManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/ScheduleManager.java @@ -1,6 +1,8 @@ package org.ntlab.citrusserver.repositories; +import org.ntlab.citrusserver.entities.Account; import org.ntlab.citrusserver.entities.Schedule; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.HashMap; @@ -8,41 +10,73 @@ @Repository public class ScheduleManager { - //Todo管理 - private final HashMap nextScheduleId = new HashMap<>(); + + @Autowired + public ScheduleManager(AccountManager accountManager) { + this.accountManager = accountManager; + } + + //管理 + private final HashMap>>>> schedules = new HashMap<>(); - public void getScheduleAll(String account_id){ + public void getScheduleAll(String accountId){ } - public void getScheduleYear(String account_id, int year){ + public void getScheduleYear(String accountId, int year){ } - public void getScheduleMonth(String account_id, int year, int month){ + public void getScheduleMonth(String accountId, int year, int month){ } - public void getScheduleDay(String account_id, int year, int month, int day){ + public void getScheduleDay(String accountId, int year, int month, int day){ } - public void addSchedule(String account_id, int year, int month, int day){ + public Schedule addSchedule(String accountId, int year, int month, int day, String title, String startTime, String endTime, int bookId){ + if(!schedules.containsKey(accountId)){ + schedules.put(accountId, new HashMap<>()); + } + if(!schedules.get(accountId).containsKey(year)){ + schedules.get(accountId).put(year, new HashMap<>()); + } + if(!schedules.get(accountId).get(year).containsKey(month)){ + schedules.get(accountId).get(year).put(month, new HashMap<>()); + } + if(!schedules.get(accountId).get(year).get(month).containsKey(day)){ + schedules.get(accountId).get(year).get(month).put(day, new HashMap<>()); + } + + String accountSchedule = accountId + year + month + day;// + if(!nextScheduleId.containsKey(accountSchedule)){ + nextScheduleId.put(accountSchedule, 0); + } + + int newScheduleId = nextScheduleId.get(accountSchedule); + Schedule newSchedule = new Schedule(title, startTime, endTime, bookId, newScheduleId); + schedules.get(accountId).get(year).get(month).get(day).put(newScheduleId, newSchedule); + nextScheduleId.put(accountSchedule, newScheduleId + 1); + return newSchedule; } - public Schedule getScheduleId(String account_id, int year, int month, int day, int schedule_id){ - //if(schedules.containsKey(accountId) - - return schedules.get(account_id).get(schedule_id).get(year).get(month).get(day); + public Schedule getScheduleId(String accountId, int year, int month, int day, int scheduleId){ + return schedules.get(accountId).get(scheduleId).get(year).get(month).get(day); } - public void deleteSchedule(String account_id, int year, int month, int day, int schedule_id){} + public void deleteSchedule(String accountId, int year, int month, int day, int scheduleId){} - public void setScheduleStartTime(String account_id, int year, int month, int day, int schedule_id, int old_time, int new_time){} + public void setScheduleStartTime(String accountId, int year, int month, int day, int scheduleId, int oldTime, int newTime){} - public void setScheduleEndTime(String account_id, int year, int month, int day, int schedule_id, int old_time, int new_time){} + public void setScheduleEndTime(String accountId, int year, int month, int day, int scheduleId, int oldTime, int newTime){} - public void setSchedulesBook(){} + public void changeScheduleTitle(String accountId, int year, int month, int day, int scheduleId, String oldTitle, String newTitle){} + + public void setSchedulesBookId(String accountId, int year, int month, int day, int scheduleId, int newBookId){} }