use json::{array, JsonValue};
use crate::{Action, Model, Response};
use crate::test::test::TestTest;

pub struct TestTestTable {
    pub model: TestTest,
}

impl Action for TestTestTable {
    fn title(&mut self) -> &'static str { "列表" }
    fn name(&mut self) -> &'static str { "test.test.table" }
    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(
            header.clone(),
            request.clone(),
            vec!["id", "file"],
            vec![],
            vec![],
        );
        data["btn_all"] = array![];
        data["btn_ids"] = array![];
        data["btn_one"] = array![];
        return self.success(data, "成功");
    }
}