# QmData-API
在2.1.x版本之后,增加where条件和orderby条件自定义传入,对应的API也会有相应的重载方法。
# 通用自动查询列表
autoSelectList
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table) |
where | where的SQL语句,不需要前置 WHERE 命令。 |
orderBy | orderBy的SQL语句,不需要前置的 ORDER BY 命令。注意当实体类中标注@OrderBy时,优先使用参数列表的orderBy进行查询。 |
Class | 对应表的实体类的Class |
说明
根据实体类字段自动构建查询条件,返回对象集合。
# 通用查询单条记录
autoSelectOne
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table) |
where | where的SQL语句,不需要前置 WHERE 命令。 |
orderBy | orderBy的SQL语句,不需要前置的 ORDER BY 命令。注意当实体类中标注@OrderBy时,优先使用参数列表的orderBy进行查询。 |
Class | 对应表的实体类的Class |
说明
根据实体类字段自动构建查询条件,返回对象。
# 通用插入记录
autoInsert
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table和@Id) |
说明
根据实体类字段自动构建插入SQL,返回影响行数。
# 通用插入记录(返回主键)
autoInsertGetPrimaryKey
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table和@Id) |
说明
根据实体类字段自动构建插入SQL,返回ResultInsert
对象,ResultInsert
对象包含影响行数和主键。
# 通用修改记录
autoUpdate
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table和@Id) |
where | where的SQL语句,不需要前置 WHERE 命令。注意它的前置条件一定会有主键。 |
说明
根据实体类字段自动构建更新SQL,返回影响行数。
注意:该更新只会通过主键进行更新,如果主键为空,或者实体类中没有带上@Id的注解,则会直接抛出异常。
# 通用删除记录
autoDelete
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table) |
where | where的SQL语句,不需要前置 WHERE 命令。 |
说明
根据实体类字段自动构建删除SQL,返回影响行数。
# 通用查询记录数
autoSelectCount
参数列表
参数 | 说明 |
---|---|
entity | 对应表的实体类(必须带有@Table) |
where | where的SQL语句,不需要前置 WHERE 命令。 |
Class | 对应表的实体类的Class |
说明
根据实体类字段自动构建查询SQL,返回记录数。
# API-接口源码
public interface QmData {
/**
* 通用查询列表
*
* @param entity 对应表的实体类
* @param clamm 对应表的实体类的Class (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> List<M> autoSelectList(Q entity, Class<M> clamm);
/**
* 通用查询单条记录
*
* @param entity 实体类
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> M autoSelectOne(Q entity, Class<M> clamm);
/**
* 通用插入记录
*
* @param entity 对应表的实体类 (以该对象作表名解析,必须带有@Id)
* @return 影响行数
*/
<Q> int autoInsert(Q entity);
/**
* 通用插入记录 (返回主键)
*
* @param entity 对应表的实体类 (以该对象作表名解析,必须带有@Id)
* @return ResultInsert 返回带新增主键id的对象
*/
<Q> ResultInsert autoInsertGetPrimaryKey(Q entity);
/**
* 通用修改记录
*
* @param entity 对应表的实体类 (以该对象作表名解析,必须带有@Id)
* @return 影响行数
*/
<Q> int autoUpdate(Q entity);
/**
* 通用删除记录
*
* @param entity 对应表的实体类 (以该对象作表名解析)
* @return 影响行数
*/
<Q> int autoDelete(Q entity);
/**
* 通用查询记录数
*
* @param entity 对应表的实体类
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 影响行数
*/
<Q, M> Long autoSelectCount(Q entity, Class<M> clamm);
/**
* 通用修改记录
*
* @param entity 对应表的实体类 (以该对象作表名解析,必须带有@Id)
* @param where 条件sql
* @return 影响行数
*/
<Q> int autoUpdate(Q entity, String where);
/**
* 通用删除记录
*
* @param entity 对应表的实体类 (以该对象作表名解析)
* @param where 条件sql
* @return 影响行数
*/
<Q> int autoDelete(Q entity, String where);
// -------------where orderby 重载 --------------------
/**
* 通用查询记录数
*
* @param entity 对应表的实体类
* @param whereSql 条件sql
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 影响行数
*/
<Q, M> Long autoSelectCount(Q entity, String whereSql, Class<M> clamm);
/**
* 通用查询列表
*
* @param entity 对应表的实体类
* @param where 条件sql
* @param orderBy 排序sql
* @param clamm 对应表的实体类的Class (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> List<M> autoSelectList(Q entity, String where, String orderBy, Class<M> clamm);
/**
* 通用查询列表
*
* @param entity 对应表的实体类
* @param where 条件sql
* @param clamm 对应表的实体类的Class (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> List<M> autoSelectList(Q entity, String where, Class<M> clamm);
/**
* 通用查询列表
*
* @param where 条件sql
* @param clamm 对应表的实体类的Class (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<M> List<M> autoSelectList(String where, Class<M> clamm);
/**
* 通用查询单条记录
*
* @param entity 实体类
* @param where 条件sql
* @param orderBy 排序sql
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> M autoSelectOne(Q entity, String where, String orderBy, Class<M> clamm);
/**
* 通用查询单条记录
*
* @param entity 实体类
* @param where 条件sql
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<Q, M> M autoSelectOne(Q entity, String where, Class<M> clamm);
/**
* 通用查询单条记录
*
* @param where 条件sql
* @param clamm 实体类class对象 (以该对象作表名解析)
* @return 根据参数指定的类型进行嵌套数据
*/
<M> M autoSelectOne(String where, Class<M> clamm);
}
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
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
← 实体类注解