1919import static apijson .framework .APIJSONConstant .USER_ ;
2020import static apijson .framework .APIJSONConstant .USER_ID ;
2121
22+ import java .util .Arrays ;
23+ import java .util .HashMap ;
24+ import java .util .List ;
25+ import java .util .Map ;
26+
2227import com .alibaba .fastjson .annotation .JSONField ;
2328
2429import apijson .RequestMethod ;
30+ import apijson .StringUtil ;
31+ import apijson .column .ColumnUtil ;
2532import apijson .framework .APIJSONSQLConfig ;
2633import apijson .orm .AbstractSQLConfig ;
2734
@@ -96,6 +103,34 @@ public String getUserIdKey(String database, String schema, String table) {
96103 RAW_MAP .put ("substring_index(substring_index(content,'.',1),'.',-1) AS subContent" , "" ); // APIAuto 不支持 ',可以用 Postman 测
97104 RAW_MAP .put ("commentWhereItem1" ,"(`Comment`.`userId` = 38710 AND `Comment`.`momentId` = 470)" );
98105 RAW_MAP .put ("to_days(now())-to_days(`date`)<=7" ,"" ); // 给 @having 使用
106+
107+
108+ // 取消注释支持 !key 反选字段 和 字段名映射,需要先依赖插件 https://github.com/APIJSON/apijson-column
109+
110+ // 反选字段配置
111+ Map <String , List <String >> tableColumnMap = new HashMap <>();
112+ tableColumnMap .put ("User" , Arrays .asList (StringUtil .split ("id,sex,name,tag,head,contactIdList,pictureList,date" )));
113+ // 需要对应方法传参也是这样拼接才行,例如 ColumnUtil.compatInputColumn(column, getSQLDatabase() + "-" + getSQLSchema() + "-" + getTable(), getMethod());
114+ tableColumnMap .put ("MYSQL-sys-Privacy" , Arrays .asList (StringUtil .split ("id,certified,phone,balance,_password,_payPassword" )));
115+ ColumnUtil .VERSIONED_TABLE_COLUMN_MAP .put (null , tableColumnMap );
116+
117+ // 字段名映射配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
118+ Map <String , Map <String , String >> tableKeyColumnMap = new HashMap <>();
119+
120+ Map <String , String > userKeyColumnMap = new HashMap <>();
121+ userKeyColumnMap .put ("gender" , "sex" );
122+ userKeyColumnMap .put ("createTime" , "date" );
123+ tableKeyColumnMap .put ("User" , userKeyColumnMap );
124+
125+ Map <String , String > privacyKeyColumnMap = new HashMap <>();
126+ privacyKeyColumnMap .put ("rest" , "balance" );
127+ // 需要对应方法传参也是这样拼接才行,例如 ColumnUtil.compatInputKey(super.getKey(key), getSQLDatabase() + "-" + getSQLSchema() + "-" + getTable(), getMethod());
128+ tableKeyColumnMap .put ("MYSQL-sys-Privacy" , privacyKeyColumnMap );
129+
130+ ColumnUtil .VERSIONED_KEY_COLUMN_MAP .put (null , tableKeyColumnMap );
131+ // 字段名映射配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
132+
133+ ColumnUtil .init ();
99134 }
100135
101136
@@ -120,7 +155,7 @@ public String getDBVersion() {
120155 }
121156 return null ;
122157 }
123-
158+
124159 @ JSONField (serialize = false ) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
125160 @ Override
126161 public String getDBUri () {
@@ -143,7 +178,7 @@ public String getDBUri() {
143178 }
144179 return null ;
145180 }
146-
181+
147182 @ JSONField (serialize = false ) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
148183 @ Override
149184 public String getDBAccount () {
@@ -164,7 +199,7 @@ public String getDBAccount() {
164199 }
165200 return null ;
166201 }
167-
202+
168203 @ JSONField (serialize = false ) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
169204 @ Override
170205 public String getDBPassword () {
@@ -225,4 +260,14 @@ public String getDBPassword() {
225260 // return false;
226261 // }
227262
263+
264+ // 取消注释支持 !key 反选字段 和 字段名映射,需要先依赖插件 https://github.com/APIJSON/apijson-column
265+ @ Override
266+ public AbstractSQLConfig setColumn (List <String > column ) {
267+ return super .setColumn (ColumnUtil .compatInputColumn (column , getTable (), getMethod ()));
268+ }
269+ @ Override
270+ public String getKey (String key ) {
271+ return ColumnUtil .compatInputKey (super .getKey (key ), getTable (), getMethod ());
272+ }
228273}
0 commit comments