比如创建一个菜单,我想由后端赋值创建时间和创建人,请问怎么操作?
ImagineL opened this issue · 3 comments
ImagineL commented
TommyLemon commented
如果每个接口逻辑不一样,可以在你已经做到的基础上新增
"gmt_create@":"/Application/gmt_create"
当然需要保证
"gmt_create()":"getNow()"
先执行,所以可以用优先级更高的标识:
"gmt_create-()":"getNow()"
最终是
{
"Application": {
"name": "测试应用",
"appkey": "kdyh",
"type": 2,
"gmt_create-()": "getNow()",
"gmt_create@": "/Application/gmt_create"
},
"tag": "Application"
}
或者干脆把远程函数写在 Application 上方
{
"gmt_create-()": "getNow()",
"Application": {
"name": "测试应用",
"appkey": "kdyh",
"type": 2,
"gmt_create@": "gmt_create"
},
"tag": "Application"
}
如果是要统一处理,可以:
在重写 DemoObjectParser 重写 newSQLConfig,把从 Controller 经过 DemoParser 传过来的 gmt_create, create_time, creator_id 等 put 进去
https://github.com/APIJSON/APIJSON-Demo/blob/316b4411eec25a4fd1137fd69fb1de1171e75a57/APIJSON-Java-Server/APIJSONFinal/src/main/java/apijson/demo/DemoObjectParser.java
@Override
public SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List<Join> joinList, boolean isProcedure) throws Exception {
if (request != null && method == RequestMethod.POST) {
request.put("gmt_create", System.currentTimeInMillis());
}
return super.newSQLConfig(method, table, alias, request, joinList, isProcedure);
}
ImagineL commented
超级感谢~~~感谢大佬回复,一会就去试试~谢谢
ImagineL commented
非常灵活的框架~