Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] long类型返回给前端精度丢失问题 #737

Open
lindaifeng opened this issue Jun 12, 2024 · 3 comments
Open

[Bug] long类型返回给前端精度丢失问题 #737

lindaifeng opened this issue Jun 12, 2024 · 3 comments

Comments

@lindaifeng
Copy link

APIJSON Version/APIJSON 版本号

apijson6.3

Database Type & Version/数据库类型及版本号

mysql8.0.2

Environment/环境信息

- JDK/基础库: jdk17
- OS/系统: macos

APIAuto Screenshots/APIAuto 请求与结果完整截屏

前端反馈long类型精度丢失,想要转成字符串

Current Behavior/问题描述

在使用post方法添加数据时,id为雪花算法,返回id为long类型,自测没问题
前端反馈long类型精度丢失,如果想要转成字符串该怎么处理,实体类可在id上加@JsonSerialize(using = ToStringSerializer.class),而通用接口并未添加实体类,有没有提供此类方法进行转换
响应结果期望字符串类型非long类型:"id": "1800770831988789248"
{
    "DataSourceDefine": {
        "ok": true,
        "code": 200,
        "msg": "success",
        "count": 1,
        "id": 1800770831988789248
    }
    ....
}

Expected Behavior/期望结果

No response

Any additional comments?/其它补充说明?

No response

@lindaifeng
Copy link
Author

apijson目前是支持通过前端传入特定数据格式后端解析成sql语句来实现操作数据库的,是否支持前端传入sql语句的方式进行数据查询呢

@TommyLemon
Copy link
Collaborator

DemoSQLExecutor 重写 getValue,判断字段名和类型来处理。
或者直接升级 APIJSON 7.0+,ORM 库已经处理了
https://github.com/Tencent/APIJSON/releases/tag/7.0.0

@TommyLemon
Copy link
Collaborator

apijson目前是支持通过前端传入特定数据格式后端解析成sql语句来实现操作数据库的,是否支持前端传入sql语句的方式进行数据查询呢

APIJSON 不会支持这种不可控的危险操作,目前支持后端在 RAW_MAP 预先配置 SQL 片段给前端传参 @raw 指定 key 中使用,仅推荐在其它功能符都不能很好地支持时才考虑这个方案:
#588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants