use df_fields::Field;
use json::{JsonValue, object};
use crate::plugin::{{plugin}}::{{model_a}}::{{model}};
use df_plugin::{Action, Response};

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

impl Action for {{action}} {
    fn title(&mut self) -> &'static str { "{{title}}" }
    fn name(&mut self) -> &'static str { "{{api}}" }
    fn token(&mut self) -> bool { true }
    fn params(&mut self) -> JsonValue { return self.model.table_fields(); }
    fn index(&mut self, _header: JsonValue, request: JsonValue) -> Response {
        let mut data = self.model.tables(request.clone(),
                                             vec!["id"],
                                             vec![],
                                             vec![],
            );
            data["btn_all"] = array![];
            data["btn_ids"] = array![];
            data["btn_one"] = array![];
        return self.success(data, "成功");
    }
}