use bd2::prost::Message;
use bd2::proto::proto_net::{
    Notify, SkyWayScheduleDbInfo, SkyWayScheduleInfoRequest, SkyWayScheduleInfoResponse,
};
use common::packet_code::PacketCodeType;
use crypto::network::GameResponse;
use sqlx::SqlitePool;
use tracing::info;

pub async fn handle(_pool: &SqlitePool, _uid: i64, req: SkyWayScheduleInfoRequest) -> GameResponse {
    info!("Handling SkyWayScheduleInfoRequest: {:?}", req);

    let schedule_info: Vec<SkyWayScheduleDbInfo> = vec![
        SkyWayScheduleDbInfo {
            day: vec![2, 4, 5, 6, 0],
            group_id: Some(1),
            bonus_rate: Some(100),
        },
        SkyWayScheduleDbInfo {
            day: vec![1, 3, 5, 6, 0],
            group_id: Some(2),
            bonus_rate: Some(100),
        },
        SkyWayScheduleDbInfo {
            day: vec![],
            group_id: Some(3),
            bonus_rate: Some(0),
        },
        SkyWayScheduleDbInfo {
            day: vec![],
            group_id: Some(4),
            bonus_rate: Some(0),
        },
        SkyWayScheduleDbInfo {
            day: vec![],
            group_id: Some(5),
            bonus_rate: Some(0),
        },
        SkyWayScheduleDbInfo {
            day: vec![],
            group_id: Some(6),
            bonus_rate: Some(0),
        },
        SkyWayScheduleDbInfo {
            day: vec![],
            group_id: Some(7),
            bonus_rate: Some(0),
        },
    ];

    let response = SkyWayScheduleInfoResponse { schedule_info };

    let resp_bytes = response.encode_to_vec();

    let notify = Notify {
        achievement_update_info: vec![],
        mission_update_info: vec![],
        event_mission_update_info: vec![],
        active_login_event: vec![1, 2, 625, 626, 627],
        active_contents_info: vec![],
        ll_type: Some("".to_string()),
        is_purchasing_disabled: Some(false),
        maintenance_start_date: Some(1688646600000),
        notice_last_seq: Some(8818),
        ..Default::default()
    };

    let (route, code) = PacketCodeType::SkyWayScheduleInfo.info();
    GameResponse::success(route, &resp_bytes, code).with_notify(&notify)
}
