1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use df_db::db::Request;
use df_fields::Field;
use json::{array, JsonValue, object};
use crate::{Action, Model, Response, Tools};
use crate::tests::test::TestModel;

pub struct Table {
    pub model: TestModel,
}

impl Action for Table {
    fn extend(&mut self) -> Vec<&str> {
        vec!["db", "cache", "kafka"]
    }
    fn title(&mut self) -> String { "测试动作".to_string() }
    fn name(&mut self) -> String { "tests.test.table".to_string() }
    fn params(&mut self) -> JsonValue {
        let mut params = object! {};
        params["page"] = df_fields::int::Int::new(true, "page", "页数", 15, 1).field();
        params["limit"] = df_fields::int::Int::new(true, "limit", "记录数", 10, 10).field();
        params["where"] = df_fields::text::Json::new(false, "where", "条件", object! {}).field();
        return params;
    }
    fn index(&mut self, _header: JsonValue, request: JsonValue, tools: Tools) -> Response {
        let table = self.model.tables("int,str", request.clone(), tools);
        let data = object! {
            data:table,
            btn_all:object! {},
            btn_one:object! {},
            btn_id:object! {}
        };
        self.success(data.clone(), "列表")
    }
}