@@ -109,34 +109,47 @@ public static boolean isTableArray(String key) {
109109 public static String KEY_USER_ID = "userId" ;
110110 public static String KEY_USER_ID_IN = KEY_USER_ID + "{}" ;
111111
112+ default String getIdKey () {
113+ return KEY_ID ;
114+ }
115+ default String getIdInKey () {
116+ return KEY_ID_IN ;
117+ }
118+ default String getUserIdKey () {
119+ return KEY_USER_ID ;
120+ }
121+ default String getUserIdInKey () {
122+ return KEY_USER_ID_IN ;
123+ }
124+
112125 /**set "id":id in Table layer
113126 * @param id
114127 * @return
115128 */
116129 default JSONMap <M , L > setId (Long id ) {
117- return puts (KEY_ID , id );
130+ return puts (getIdKey () , id );
118131 }
119132 /**set "id{}":[] in Table layer
120133 * @param list
121134 * @return
122135 */
123136 default JSONMap <M , L > setIdIn (List <Object > list ) {
124- return puts (KEY_ID_IN , list );
137+ return puts (getIdInKey () , list );
125138 }
126139
127140 /**set "userId":userId in Table layer
128141 * @param id
129142 * @return
130143 */
131144 default JSONMap <M , L > setUserId (Long id ) {
132- return puts (KEY_USER_ID , id );
145+ return puts (getUserIdKey () , id );
133146 }
134147 /**set "userId{}":[] in Table layer
135148 * @param list
136149 * @return
137150 */
138151 default JSONMap <M , L > setUserIdIn (List <Object > list ) {
139- return puts (KEY_USER_ID_IN , list );
152+ return puts (getUserIdInKey () , list );
140153 }
141154
142155
@@ -150,36 +163,37 @@ default JSONMap<M, L> setUserIdIn(List<Object> list) {
150163
151164
152165 //@key关键字都放这个类 <<<<<<<<<<<<<<<<<<<<<<
153- String KEY_TRY = "@try" ; //尝试,忽略异常
154- String KEY_CATCH = "@catch" ; //TODO 捕捉到异常后,处理方式 null-不处理;DEFAULT-返回默认值;ORIGIN-返回请求里的原始值
155- String KEY_DROP = "@drop" ; //丢弃,不返回,TODO 应该通过 fastjson 的 ignore 之类的机制来处理,避免导致下面的对象也不返回
156- // String KEY_KEEP = "@keep"; //一定会返回,为 null 或 空对象时,会使用默认值(非空),解决其它对象因为不关联的第一个对为空导致也不返回
157- String KEY_DEFULT = "@default" ; //TODO 自定义默认值 { "@default":true },@default 可完全替代 @keep
158- String KEY_NULL = "@null" ; //值为 null 的键值对 "@null":"tag,pictureList",允许 is NULL 条件判断, SET tag = NULL 修改值为 NULL 等
159- String KEY_CAST = "@cast" ; //类型转换 cast(date AS DATE)
160-
161- String KEY_ROLE = "@role" ; //角色,拥有对某些数据的某些操作的权限
162- String KEY_DATABASE = "@database" ; //数据库类型,默认为MySQL
163- String KEY_DATASOURCE = "@datasource" ; //数据源
164- String KEY_NAMESPACE = "@namespace" ; //命名空间,Table 在非默认 namespace 内时需要声明
165- String KEY_CATALOG = "@catalog" ; //目录,Table 在非默认 catalog 内时需要声明
166- String KEY_SCHEMA = "@schema" ; //数据库,Table 在非默认 schema 内时需要声明
167- String KEY_EXPLAIN = "@explain" ; //分析 true/false
168- String KEY_CACHE = "@cache" ; //缓存 RAM/ROM/ALL
169- String KEY_COLUMN = "@column" ; //查询的Table字段或SQL函数
170- String KEY_FROM = "@from" ; //FROM语句
171- String KEY_COMBINE = "@combine" ; //条件组合,每个条件key前面可以放 &,|,!逻辑关系 "id!{},&sex,!name&$"
172- String KEY_GROUP = "@group" ; //分组方式
173- String KEY_HAVING = "@having" ; //聚合函数条件,一般和@group一起用
174- String KEY_HAVING_AND = "@having&" ; //聚合函数条件,一般和@group一起用
175- String KEY_SAMPLE = "@sample" ; //取样方式
176- String KEY_LATEST = "@latest" ; //最近方式
177- String KEY_PARTITION = "@partition" ; //分区方式
178- String KEY_FILL = "@fill" ; //填充方式
179- String KEY_ORDER = "@order" ; //排序方式
166+ String KEY_TRY = "@try" ; // 尝试,忽略异常
167+ String KEY_CATCH = "@catch" ; // TODO 捕捉到异常后,处理方式 null-不处理;DEFAULT-返回默认值;ORIGIN-返回请求里的原始值
168+ String KEY_DROP = "@drop" ; // 丢弃,不返回,TODO 应该通过 fastjson 的 ignore 之类的机制来处理,避免导致下面的对象也不返回
169+ // String KEY_KEEP = "@keep"; // 一定会返回,为 null 或 空对象时,会使用默认值(非空),解决其它对象因为不关联的第一个对为空导致也不返回
170+ String KEY_DEFAULT = "@default" ; // TODO 自定义默认值 { "@default":true },@default 可完全替代 @keep
171+ String KEY_NULL = "@null" ; // 值为 null 的键值对 "@null":"tag,pictureList",允许 is NULL 条件判断, SET tag = NULL 修改值为 NULL 等
172+ String KEY_CAST = "@cast" ; // 类型转换 cast(date AS DATE)
173+
174+ String KEY_ROLE = "@role" ; // 角色,拥有对某些数据的某些操作的权限
175+ String KEY_DATABASE = "@database" ; // 数据库类型,默认为MySQL
176+ String KEY_DATASOURCE = "@datasource" ; // 数据源
177+ String KEY_NAMESPACE = "@namespace" ; // 命名空间,Table 在非默认 namespace 内时需要声明
178+ String KEY_CATALOG = "@catalog" ; // 目录,Table 在非默认 catalog 内时需要声明
179+ String KEY_SCHEMA = "@schema" ; // 数据库,Table 在非默认 schema 内时需要声明
180+ String KEY_EXPLAIN = "@explain" ; // 分析 true/false
181+ String KEY_CACHE = "@cache" ; // 缓存 RAM/ROM/ALL
182+ String KEY_COLUMN = "@column" ; // 查询的 Table 字段或 SQL 函数
183+ String KEY_FROM = "@from" ; // FROM语句
184+ String KEY_COMBINE = "@combine" ; // 条件组合,每个条件 key 前面可以放 &,|,! 逻辑关系 "id!{},&sex,!name&$"
185+ String KEY_GROUP = "@group" ; // 分组方式
186+ String KEY_HAVING = "@having" ; // 聚合函数条件,一般和 @group 一起用
187+ String KEY_HAVING_AND = "@having&" ; // 聚合函数条件,一般和 @group 一起用
188+ String KEY_SAMPLE = "@sample" ; // 取样方式
189+ String KEY_LATEST = "@latest" ; // 最近方式
190+ String KEY_PARTITION = "@partition" ; // 分区方式
191+ String KEY_FILL = "@fill" ; // 填充方式
192+ String KEY_ORDER = "@order" ; // 排序方式
180193 String KEY_KEY = "@key" ; // key 映射,year:left(date,4);name_tag:(name,tag)
181194 String KEY_RAW = "@raw" ; // 自定义原始 SQL 片段
182- String KEY_JSON = "@json" ; //SQL Server 把字段转为 JSON 输出
195+ String KEY_JSON = "@json" ; // 把字段转为 JSON 输出
196+ String KEY_STRING = "@string" ; // 把字段转为 String 输入
183197 String KEY_METHOD = "@method" ; // json 对象配置操作方法
184198 String KEY_GET = "@get" ; // json 对象配置操作方法
185199 String KEY_GETS = "@gets" ; // json 对象配置操作方法
@@ -214,6 +228,7 @@ default JSONMap<M, L> setUserIdIn(List<Object> list) {
214228 KEY_KEY ,
215229 KEY_RAW ,
216230 KEY_JSON ,
231+ KEY_STRING ,
217232 KEY_METHOD ,
218233 KEY_GET ,
219234 KEY_GETS ,
@@ -255,7 +270,7 @@ default JSONMap<M, L> setDrop(Boolean drop) {
255270 * @return this
256271 */
257272 default JSONMap <M , L > setDefault (Boolean hasDefault ) {
258- return puts (KEY_DEFULT , hasDefault );
273+ return puts (KEY_DEFAULT , hasDefault );
259274 }
260275
261276
@@ -525,6 +540,14 @@ default JSONMap<M, L> setJson(String keys) {
525540 return puts (KEY_JSON , keys );
526541 }
527542
543+ /**set keys to cast to string
544+ * @param keys "key0,key1,key2..."
545+ * @return
546+ */
547+ default JSONMap <M , L > setString (String keys ) {
548+ return puts (KEY_STRING , keys );
549+ }
550+
528551 //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
529552
530553
0 commit comments