Newer
Older
CitrusServer / src / main / java / org / ntlab / citrusserver / resources / ScheduleRest.java
package org.ntlab.citrusserver.resources;

import org.ntlab.citrusserver.entities.Schedule;
import org.ntlab.citrusserver.repositories.AccountManager;
import org.ntlab.citrusserver.repositories.ScheduleManager;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Path("/accounts")
@Component

public class ScheduleRest {
    private final ScheduleManager scheduleManager;
    private final AccountManager accountManager;

    @Autowired
    public ScheduleRest(ScheduleManager sm, AccountManager ac){
        scheduleManager = sm;
        accountManager = ac;
    }

    //@Path("/{account_id}/schedule")
    //@GET//登録されたスケジュールのidを返す
    //@Produces(MediaType.APPLICATION_JSON)

    //@Path("/{account_id}/schedule/{year}")
    //@GET//登録されたスケジュールのidを年単位で返す
    //@Produces(MediaType.APPLICATION_JSON)

    //@Path("/{account_id}/schedule/{year}/{month}")
    //@GET//登録されたスケジュールのidを月単位で返す
    //@Produces(MediaType.APPLICATION_JSON)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}")
    //@GET//登録されたスケジュールのidを日ごとで返す
    //@Produces(MediaType.APPLICATION_JSON)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}")
    //@POST//スケジュールの新規作成
    //@Produces(MediaType.APPLICATION_JSON)


    @Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}")
    @GET//スケジュールの情報を返す
    @Produces(MediaType.APPLICATION_JSON)
    public Schedule getScheduleInfo(@PathParam("account_id") String account_id, @PathParam("year") Integer year,
                                    @PathParam("month") Integer month, @PathParam("day") Integer day,
                                    @PathParam("schedule_id") Integer schedule_id, @QueryParam("token") String token) {
        if(accountManager.checkToken(account_id,token)) {
            Schedule schedule = scheduleManager.getScheduleId(account_id, year, month, day, schedule_id);//token後でつける
            return schedule;
        }
        return null;
    }

    //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}")
    //@DELETE//特定のスケジュールを削除する
    //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/start_time")
    //@PUT//スケジュールの開始時刻の新規作成・変更
    //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/end_time")
    //@PUT//スケジュールの終了時刻の新規作成・変更
    //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/title")
    //@PUT//スケジュールのタイトルの変更
    //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)

    //@Path("/{account_id}/schedule/{year}/{month}/{day}/{schedule_id}/book_id")
    //@PUT//スケジュールの所属している本の新規設定・変更
    //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
}