Newer
Older
CitrusServer / src / main / java / org / ntlab / citrusserver / resources / ScheduleRest.java
  1. package org.ntlab.citrusserver.resources;
  2.  
  3. import org.ntlab.citrusserver.entities.Schedule;
  4. import org.ntlab.citrusserver.repositories.AccountManager;
  5. import org.ntlab.citrusserver.repositories.ScheduleManager;
  6. import jakarta.ws.rs.*;
  7. import jakarta.ws.rs.core.MediaType;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Component;
  10.  
  11. @Path("/accounts")
  12. @Component
  13.  
  14. public class ScheduleRest {
  15. private final ScheduleManager scheduleManager;
  16. private final AccountManager accountManager;
  17.  
  18. @Autowired
  19. public ScheduleRest(ScheduleManager sm, AccountManager ac){
  20. scheduleManager = sm;
  21. accountManager = ac;
  22. }
  23.  
  24. //@Path("/{account_id}/schedule")
  25. //@GET//登録されたスケジュールのidを返す
  26. //@Produces(MediaType.APPLICATION_JSON)
  27.  
  28. //@Path("/{account_id}/schedule/{year}")
  29. //@GET//登録されたスケジュールのidを年単位で返す
  30. //@Produces(MediaType.APPLICATION_JSON)
  31.  
  32. //@Path("/{account_id}/schedule/{year}/{month}")
  33. //@GET//登録されたスケジュールのidを月単位で返す
  34. //@Produces(MediaType.APPLICATION_JSON)
  35.  
  36. //@Path("/{account_id}/schedule/{year}/{month}/{day}")
  37. //@GET//登録されたスケジュールのidを日ごとで返す
  38. //@Produces(MediaType.APPLICATION_JSON)
  39.  
  40. //@Path("/{account_id}/schedule/{year}/{month}/{day}")
  41. //@POST//スケジュールの新規作成
  42. //@Produces(MediaType.APPLICATION_JSON)
  43.  
  44.  
  45. @Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}")
  46. @GET//スケジュールの情報を返す
  47. @Produces(MediaType.APPLICATION_JSON)
  48. public Schedule getScheduleInfo(@PathParam("account_id") String account_id, @PathParam("year") Integer year,
  49. @PathParam("month") Integer month, @PathParam("day") Integer day,
  50. @PathParam("schedule_id") Integer schedule_id, @QueryParam("token") String token) {
  51. if(accountManager.checkToken(account_id,token)) {
  52. Schedule schedule = scheduleManager.getScheduleId(account_id, year, month, day, schedule_id);//token後でつける
  53. return schedule;
  54. }
  55. return null;
  56. }
  57.  
  58. //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}")
  59. //@DELETE//特定のスケジュールを削除する
  60. //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  61.  
  62. //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/start_time")
  63. //@PUT//スケジュールの開始時刻の新規作成・変更
  64. //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  65.  
  66. //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/end_time")
  67. //@PUT//スケジュールの終了時刻の新規作成・変更
  68. //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  69.  
  70. //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/title")
  71. //@PUT//スケジュールのタイトルの変更
  72. //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  73.  
  74. //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/book_id")
  75. //@PUT//スケジュールの所属している本の新規設定・変更
  76. //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  77. }