The id checked by swagger is inconsistent with the database

1. Scene reproduction

The id of the data detected by swagger is different from the last few digits of the id of the data in the database. But the data checked out using postman is consistent with the database.

swagger display data:

 Database data:

2. Problem Analysis 

The id of the data is automatically generated by the snowflake algorithm, and the generated id is too long (here is 19 bits), resulting in data distortion.

Three, the solution

Solution one:

Modify the snowflake algorithm generation tool and set the length of the generated id. Generally, the generated length is 16 bits;

Solution two:

Add annotations on the id of the entity class:

@JsonFormat(shape = JsonFormat.Shape.STRING)

 

Guess you like

Origin blog.csdn.net/yy12345_6_/article/details/127241158