br-plugin 1.6.8

This is an Plugin
Documentation
use crate::plugin::{{plugin}}::{{model_a}}::{{model}};
use json::JsonValue;
use br_plugin::Response;
use br_plugin::action::Action;
use crate::plugin::check_auth;

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 params(&mut self) -> JsonValue { return self.model.table_tree_fields(); }
    fn index(&mut self, header: JsonValue, request: JsonValue) -> Response {
        let org_org = header["custom"]["org_org"].as_str().unwrap_or("");
        request["where"].push(vec!["org_org", "=", org_org]).unwrap();

        let mut data = self.model.table_tree(
            header.clone(),
            request.clone(),
            ("sort", false),
            "name",
            vec!["time_add", "time_put", "time_del"],
            vec!["name"],
        );

        let btn_all: Vec<JsonValue> = vec![];
        let btn_ids: Vec<JsonValue> = vec![];
        let btn_one: Vec<JsonValue> = vec![];


        let btn_all = check_auth(btn_all, header.clone());
        let btn_ids = check_auth(btn_ids, header.clone());
        let btn_one = check_auth(btn_one, header.clone());

        data["btn_all"] = btn_all.into();
        data["btn_ids"] = btn_ids.into();
        data["btn_one"] = btn_one.into();

        return self.success(data, "成功");
    }
}