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
35
36
37
38
39
40
41
42
43
44
use df_fields::Field;
use json::{JsonValue, object};
use crate::{Action, Model};
use crate::tests::test::table::Table;
use crate::tests::test::test::TestAction;
pub struct TestModel {}
impl Model for TestModel {
fn table(&mut self) -> String {
"tests_test".to_string()
}
fn fields(&mut self) -> JsonValue {
let mut fields = object! {};
fields[self.primary_key()] = df_fields::str::Key::new(true, self.primary_key().as_str(), "ID", 20).field();
fields["str"] = df_fields::str::Str::new(true, "str", "字符串", 15, "").field();
fields["int"] = df_fields::int::Int::new(true, "int", "整数", 20, 0).field();
return fields;
}
fn title(&mut self) -> String {
"测试模型".to_string()
}
fn action(&mut self, name: &str) -> Box<dyn Action> {
match name {
"table" => Box::new(Table { model: TestModel {} }),
_ => Box::new(TestAction { model: TestModel {} })
}
}
}
pub mod test;
pub mod table;