Home > Back-end >  Spring framework of cloud services provide a restful API, at the same time provide interfaces to oth
Spring framework of cloud services provide a restful API, at the same time provide interfaces to oth

Time:09-25

Recently has been studying the spring cloud services framework, transfer data between micro service using a restful, the question is: if an interface of the micro service foreign provide restful API (mobile), the same API for other services to provide data, so how json format design can achieve the reuse?
For example, to the mobile terminal design json is generally as follows: {" the resultCode ": 0," data ": {" username" : "ABC", "id" : 1}, "MSG" : ""}; And for other micro service format for: {" username ":" ABC ", "id" : 1}

CodePudding user response:

1, @ can release the service method also the Rest interface
2, return the data Controller interface can be returned by the HTTP status status data, so can move to other service with the interface data format is the same: {" username ":" ABC ", "id" : 1}
Don't need "the resultCode" : 0

CodePudding user response:

reference 1st floor dong_19890208 response:
1, @ can release the service method also the Rest interface
2, return the data Controller interface can be returned by the HTTP status status data, so can move to other service with the interface data format is the same: {" username ":" ABC ", "id" : 1}
Don't need "the resultCode" : 0

Well, the first thing I do it, the second point, I consulted other external API interface, found most similar to the resultCode, MSG this field, convenient interface are given call failure related to the business of the error code, and I do android before, this design is convenient mobile terminal by a generic class

CodePudding user response:

  • Related