use json::{JsonValue, object};
use br_addon::action::{Action, InterfaceType};
use br_addon::module::Module;
use br_addon::request::Request;
use br_addon::ApiResponse;

pub struct {{action}} {
    pub module: {{model}},
}

impl Action for {{action}} {
    fn title(&self) -> &'static str { "{{title}}" }
    fn tags(&self) -> &'static [&'static str] {&[]}
    fn auth(&self) -> bool { false }
    fn params(&mut self) -> JsonValue {
        self.params_table_select(object! {})
    }
    fn index(&mut self, request: Request) -> ApiResponse {
        let table_name = self.module._table_name();
        let table_info = self.table_select(request.body.clone(), table_name, vec!["name", "code"]);
        ApiResponse::success(table_info, "获取成功")
    }
}