// use anyhow::Context;
// use neon_rs::core::ctx::wrap;
// use repo::{dao::demo, schema::model};
use serde::{Deserialize, Serialize};
use validator::Validate;

use infra::{
    core::AppState,
    status::{ApiResult, api_ok::ApiOK},
};

#[derive(Debug, Validate, Deserialize, Serialize)]
pub struct ReqHello {
    #[validate(length(min = 1, message = "required"))]
    pub name: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct RespHello {
    pub message: String,
}

pub async fn hello(_ctx: &AppState, req: ReqHello) -> ApiResult<RespHello> {
    // let ret = demo::get_by_id::<model::Demo>(ctx, 1, None)
    //     .await
    //     .with_context(|| wrap("demo::get_by_id failed"))?;

    let resp = RespHello {
        message: format!("Hello, {}!", req.name),
    };
    Ok(ApiOK(Some(resp)))
}
