shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package com.iplatform.model.po;
 
import com.walker.jdbc.BaseMapper;
import com.walker.jdbc.ResultSetUtils;
import com.walker.jdbc.SqlAndParameters;
import com.walker.jdbc.sqlgen.DeleteBuilder;
import com.walker.jdbc.sqlgen.InsertBuilder;
import com.walker.jdbc.sqlgen.SelectBuilder;
import com.walker.jdbc.sqlgen.UpdateBuilder;
import com.walker.jdbc.util.StringUtils;
 
import org.springframework.jdbc.core.RowMapper;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
 
/**
 * 表名:SDC_META_TABLE *
 * @author genrator
 */
public class Sdc_meta_table_mapper extends Sdc_meta_table implements BaseMapper<Sdc_meta_table> {
    // 序列化版本号
    private static final long serialVersionUID = 1L;
 
    public static final RowMapper<Sdc_meta_table> ROW_MAPPER = new Sdc_meta_tableRowMapper();
 
    // 主键
    public static final String ID = "id";
    // 普通属性
    public static final String CREATE_TIME = "create_time";
    public static final String STORE_ID = "store_id";
    public static final String DB_ID = "db_id";
    public static final String TABLE_NAME = "table_name";
    public static final String ROW_COUNT = "row_count";
    public static final String SUMMARY = "summary";
 
    /**
     * 默认构造函数
     */
    public Sdc_meta_table_mapper(Sdc_meta_table sdc_meta_table) {
        if (sdc_meta_table == null) {
            throw new IllegalArgumentException("po参数不允许为空!");
        }
        //主键
        if (sdc_meta_table.isset_id) {
            this.setId(sdc_meta_table.getId());
        }
        //普通属性
        if (sdc_meta_table.isset_create_time) {
            this.setCreate_time(sdc_meta_table.getCreate_time());
        }
        if (sdc_meta_table.isset_store_id) {
            this.setStore_id(sdc_meta_table.getStore_id());
        }
        if (sdc_meta_table.isset_db_id) {
            this.setDb_id(sdc_meta_table.getDb_id());
        }
        if (sdc_meta_table.isset_table_name) {
            this.setTable_name(sdc_meta_table.getTable_name());
        }
        if (sdc_meta_table.isset_row_count) {
            this.setRow_count(sdc_meta_table.getRow_count());
        }
        if (sdc_meta_table.isset_summary) {
            this.setSummary(sdc_meta_table.getSummary());
        }
        // 去掉,2022-09-07
        // this.setDatabaseName_(sdc_meta_table.getDatabaseName_());
    }
 
    /**
     * 获取表名
     */
    @Override
    public String getTableName_() {
        String tableName = "sdc_meta_table";
        /**
        if (StringUtils.isNotEmpty(this.getDatabaseName_())) {
            return this.getDatabaseName_() + "." + tableName;
        } else {
            return tableName;
        }
        */
        return tableName;
    }
 
    /**
     * 获取主键名称
     */
    @Override
    public String getPkName_() {
        return ID;
    }
 
    /**
     * 获取主键值
     */
    @Override
    public Object getPkValue_() {
        return this.getId();
    }
 
    /**
     * 获取插入语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getInsertSql_() {
        InsertBuilder ib = new InsertBuilder(this.getTableName_());
        ib.set(ID, this.getId());
        ib.set(CREATE_TIME, this.getCreate_time(), this.isset_create_time);
        ib.set(STORE_ID, this.getStore_id(), this.isset_store_id);
        ib.set(DB_ID, this.getDb_id(), this.isset_db_id);
        ib.set(TABLE_NAME, this.getTable_name(), this.isset_table_name);
        ib.set(ROW_COUNT, this.getRow_count(), this.isset_row_count);
        ib.set(SUMMARY, this.getSummary(), this.isset_summary);
        return ib.genMapSql();
    }
 
    /**
     * 获取更新语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getUpdateSql_() {
        UpdateBuilder ub = new UpdateBuilder(this.getTableName_());
        ub.set(CREATE_TIME, this.getCreate_time(), this.isset_create_time);
        ub.set(STORE_ID, this.getStore_id(), this.isset_store_id);
        ub.set(DB_ID, this.getDb_id(), this.isset_db_id);
        ub.set(TABLE_NAME, this.getTable_name(), this.isset_table_name);
        ub.set(ROW_COUNT, this.getRow_count(), this.isset_row_count);
        ub.set(SUMMARY, this.getSummary(), this.isset_summary);
        ub.where(this.getPkName_(), this.getPkValue_());
        return ub.genMapSql();
    }
 
    /**
     * 获取更新语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getUpdateSql_(String where, Map<String, Object> parameters) {
        UpdateBuilder ub = new UpdateBuilder(this.getTableName_());
        ub.set(CREATE_TIME, this.getCreate_time(), this.isset_create_time);
        ub.set(STORE_ID, this.getStore_id(), this.isset_store_id);
        ub.set(DB_ID, this.getDb_id(), this.isset_db_id);
        ub.set(TABLE_NAME, this.getTable_name(), this.isset_table_name);
        ub.set(ROW_COUNT, this.getRow_count(), this.isset_row_count);
        ub.set(SUMMARY, this.getSummary(), this.isset_summary);
 
        return ub.genMapSql(where, parameters);
    }
 
    /**
     * 获取更新语句和参数
     */
    @Override
    public SqlAndParameters<Object[]> getUpdateSql_(String where, Object[] parameters) {
        UpdateBuilder ub = new UpdateBuilder(this.getTableName_());
        ub.set(CREATE_TIME, this.getCreate_time(), this.isset_create_time);
        ub.set(STORE_ID, this.getStore_id(), this.isset_store_id);
        ub.set(DB_ID, this.getDb_id(), this.isset_db_id);
        ub.set(TABLE_NAME, this.getTable_name(), this.isset_table_name);
        ub.set(ROW_COUNT, this.getRow_count(), this.isset_row_count);
        ub.set(SUMMARY, this.getSummary(), this.isset_summary);
 
        return ub.genArraySql(where, parameters);
    }
 
    /**
     * 获取删除语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getDeleteSql_() {
        DeleteBuilder db = new DeleteBuilder(this.getTableName_());
        db.where(this.getPkName_(), this.getPkValue_());
        return db.genMapSql();
    }
 
    /**
     * 获取删除语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getDeleteSql_(String where, Map<String, Object> parameters) {
        DeleteBuilder db = new DeleteBuilder(this.getTableName_());
        return db.genMapSql(where, parameters);
    }
 
    /**
     * 获取删除语句和参数
     */
    @Override
    public SqlAndParameters<Object[]> getDeleteSql_(String where, Object[] parameters) {
        DeleteBuilder db = new DeleteBuilder(this.getTableName_());
        return db.genArraySql(where, parameters);
    }
 
    /**
     * 获取单行查询语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getSingleSql_() {
        SelectBuilder sb = new SelectBuilder(this.getTableName_());
        sb.where(this.getPkName_(), this.getPkValue_());
        return sb.genMapSql();
    }
 
 
    /**
     * 获取查询语句和参数
     */
    @Override
    public SqlAndParameters<Map<String, Object>> getSelectSql_(String where, Map<String, Object> parameters) {
        return new SqlAndParameters<>("select id, create_time, store_id, db_id, table_name, row_count, summary from " + this.getTableName_() + " " + where, parameters);
    }
 
    /**
     * 获取查询语句和参数
     */
    @Override
    public SqlAndParameters<Object[]> getSelectSql_(String where, Object[] parameters) {
        return new SqlAndParameters<>("select id, create_time, store_id, db_id, table_name, row_count, summary from " + this.getTableName_() + " " + where, parameters);
    }
 
    /**
     * 将resultset的一行转化为po
     */
    @Override
    public Sdc_meta_table mapRow(ResultSet rs, int i) throws SQLException {
        return ROW_MAPPER.mapRow(rs, i);
    }
 
    /**
     * 克隆
     */
    public Sdc_meta_table toSdc_meta_table() {
        return super.$clone();
    }
}
 
/**
 * sdc_meta_table RowMapper
 *
 * @author genrator
 */
class Sdc_meta_tableRowMapper implements RowMapper<Sdc_meta_table> {
 
    @Override
    public Sdc_meta_table mapRow(ResultSet rs, int i) throws SQLException {
        ResultSetUtils resultSetUtils = new ResultSetUtils();
        Sdc_meta_table sdc_meta_table = new Sdc_meta_table();
        Integer columnIndex;
        //主键
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.ID);
        if (columnIndex > 0) {
            sdc_meta_table.setId(rs.getLong(columnIndex));
        }
        //普通属性
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.CREATE_TIME);
        if (columnIndex > 0) {
            if (rs.getBigDecimal(columnIndex) == null) {
                sdc_meta_table.setCreate_time(null);
            } else {
                sdc_meta_table.setCreate_time(rs.getLong(columnIndex));
            }
        }
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.STORE_ID);
        if (columnIndex > 0) {
            sdc_meta_table.setStore_id(rs.getString(columnIndex));
        }
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.DB_ID);
        if (columnIndex > 0) {
            if (rs.getBigDecimal(columnIndex) == null) {
                sdc_meta_table.setDb_id(null);
            } else {
                sdc_meta_table.setDb_id(rs.getLong(columnIndex));
            }
        }
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.TABLE_NAME);
        if (columnIndex > 0) {
            sdc_meta_table.setTable_name(rs.getString(columnIndex));
        }
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.ROW_COUNT);
        if (columnIndex > 0) {
            if (rs.getBigDecimal(columnIndex) == null) {
                sdc_meta_table.setRow_count(null);
            } else {
                sdc_meta_table.setRow_count(rs.getLong(columnIndex));
            }
        }
        columnIndex = resultSetUtils.findColumn(rs, Sdc_meta_table_mapper.SUMMARY);
        if (columnIndex > 0) {
            sdc_meta_table.setSummary(rs.getString(columnIndex));
        }
        return sdc_meta_table;
    }
}