APIJSON返回datetime类型字段的值该怎么去掉时间后面的毫秒单位
Description
@TommyLemon 麻烦看一下这个怎么处理
MySQL 可以用 date_format, "@column": "date_format(date,'%Y-%m-%d %h:%i:%s'):date" // 大部分情况下可以去掉引号,会自动识别是字段名还是值
其它数据库的可以网上搜下 数据库类型 + 时间格式化
谢谢,我先试试
APIJSON 支持 SQL 的各种表达式、函数、关键词 等,可以结合 APIJSON 语法中的 @column, key{}, @having, @raw 等来灵活使用 https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java#L175-L765
@TommyLemon 您好,可以在后端代码进行统一处理吗?
如果使用"@column"的话,必须把所有字段全部填入,不然这个地方无法返回所有数据,只能返回时间的数据,有什么好方法吗
DemoSQLExecutor 重写 getValue,判断是 update_time, create_time 等字段,就用 SimpleDateFormat 处理下格式。 或者依赖 apijson-cloumn,可以传 "date_format(date,'%Y-%m-%d %h:%i:%s'):date;!date" // !date 表示除了 date 其它都返回 https://github.com/APIJSON/apijson-column
谢谢