The front end cannot recognize the snowflake algorithm id solution

The front end cannot recognize the snowflake algorithm id solution

1. Questions

When the id generated by the snowflake algorithm is used as the primary key, because its length is 19 digits, and the front-end JS can generally handle 16 digits, if it is not processed, the front-end will cause precision

2. Back-end solution

Simply change the id type to String, use the annotations of the Jackson package, and add the annotation @JsonSerialize to the corresponding entity class primary key attribute

@JsonSerialize(using = ToStringSerializer.class)
@TableId
private Long id;

3. Front-end solutions

The front end uses the json-bigint module for processing, generally using axios data requests

npm instal

Guess you like

Origin blog.csdn.net/xu990128638/article/details/130040740