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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
use crate::;
use ;
use ;
use Params;
use BaseModel;
use crateBaseModel;
pub const TABLE_NAME:&str = "test_user";
pub const FIELDS: = ;
pub const ALIAS:&str = "testUser";
// impl model::BaseModel for TestUser {
//
// fn get_table_name(&self) -> &str {
// return TABLE_NAME;
// }
//
// fn get_alias(&self) -> &str {
// return ALIAS;
// }
//
// fn get_fields_count(&self) -> u16{
// return FIELDS.len().try_into().unwrap();
// }
//
// fn get_field_sql(&self, alias: &str) -> String {
// return get_field_sql(alias);
// }
//
// fn get_field_sql_not_pk(&self, alias: &str) -> String {
// let mut columns = String::from("");
// for c in &FIELDS[1..] {
// if "" != columns {
// columns.push_str(", ");
// }
// if "" != alias {
// columns.push_str(&format!("{}.{}" , alias, c));
// } else {
// columns.push_str(&format!("{}" , c));
// }
// }
// return columns;
// }
//
// fn get_params_insert(&self) -> (r2d2_mysql::mysql::Params, String, String) {
// let mut columns = String::from("");
// let mut keys = String::from("");
//
// for c in &FIELDS[1..] {
// if "" != columns {
// columns.push_str(", ");
// keys.push_str(", ");
// }
// columns.push_str(&format!("{}" , c));
// keys.push_str(&format!(":{}" , c));
// }
//
// return (params! {
// "created_at" => self.created_at,
// "updated_at" => self.updated_at,
// "user_name" => self.user_name.to_string(),
// "state" => self.state,
// }, columns, keys);
// }
//
// fn get_params_update_by_pk(&self) -> (Params, String, String) {
// let mut columns = String::from("");
//
// for c in &FIELDS[2..] {
// if "" != columns {
// columns.push_str(", ");
// }
// columns.push_str(&format!("{}=:{}" , c, c));
// }
//
// return (params! {
// "updated_at" => self.updated_at,
// "user_name" => self.user_name.to_string(),
// "state" => self.state,
// "id" => self.id,
// }, columns, String::from(format!("{}=:{}", FIELDS[0], FIELDS[0])))
// }
//
// fn set_pk(&mut self, pk: u64) {
// self.id = pk;
// }
//
// fn set_created_at(&mut self, at: u64) {
// self.created_at = at;
// }
//
// fn set_updated_at(&mut self, at: u64) {
// self.updated_at = at;
// }
//
// }
/// get_field_sql 获取字段列 sql
/// pot 罐子 -> 把 mysql-row 按指定偏移 offset 装入结构体