use json::{JsonValue, object};
use crate::plugin::{{plugin}}::{{model_a}}::{{model}};
use br_plugin::Response;
use br_plugin::action::Action;
use br_plugin::model::Model;

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

impl Action for {{action}} {
    fn author(&mut self) -> &'static str {
        return "";
    }
    fn title(&mut self) -> &'static str { "{{title}}" }
    fn api(&mut self) -> &'static str { "{{api}}" }
    fn token(&mut self) -> bool { true }
    fn auth(&mut self) -> bool { false }
    fn params(&mut self) -> JsonValue {
        return self.model.table_select_fields();
    }
    fn index(&mut self, _header: JsonValue, request: JsonValue) -> Response {
        let list = self.model.table_select(request.clone(), vec!["name", "code"], vec![
            vec![]
        ]);
        return self.success(list, "ok");
    }
}