Skip to content

Commit

Permalink
add a list api for GET methods
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Dec 9, 2023
1 parent e2c4e45 commit 1d81ccb
Show file tree
Hide file tree
Showing 46 changed files with 1,290 additions and 257 deletions.
6 changes: 3 additions & 3 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Change log

- Sponge command ui service support docker deployment.
- Adjustment option code.

- Fix bug with naocs as service discovery.
- Add support for distributed transaction manager [DTM](https://github.com/dtm-labs/dtm).
- Add a list api interface for GET methods.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ build-sponge:
# build a sponge docker image, e.g. make image-build-sponge TAG=v1.5.8
image-build-sponge:
@echo "build a sponge docker image'"
@cd cmd/sponge/scripts && bash image-build.sh $(TAG)
@cd cmd/sponge/scripts && bash build-sponge-image.sh $(TAG)

# delete the templates code end

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

<br>

If you are developing a web or microservice with a simple CRUD API interface, you don't need to write a single line of golang code to compile and deploy to servers, dockers, k8s, and the complete service code is generated by sponge.
If you are developing a RESTful web or microservice with a simple CRUD API interface, you don't need to write a single line of golang code to compile and deploy to servers, dockers, k8s, and the complete service code is generated by sponge.

If you develop a generic web or microservice, you need to manually write code in addition to defining the data table, defining the api interface in the proto file, and filling in the specific business logic code in the generated template file. Other golang codes are generated by sponge.
If you develop a generic RESTful web or microservice, you need to manually write code in addition to defining the data table, defining the api interface in the proto file, and filling in the specific business logic code in the generated template file. Other golang codes are generated by sponge.

<br>

Expand Down Expand Up @@ -108,6 +108,10 @@ No specific business logic code is included.
- [7_community-single](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
- [8_community-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)

#### Distributed transaction examples

- [9_order-system](https://github.com/zhufuyi/sponge_examples/tree/main/9_order-grpc-distributed-transaction)

<br>

**If it's help to you, give it a star ⭐.**
Expand Down
523 changes: 348 additions & 175 deletions api/serverNameExample/v1/userExample.pb.go

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions api/serverNameExample/v1/userExample.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions api/serverNameExample/v1/userExample.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ service userExample {
};
}

// list userExample by last id
rpc ListByLastID(ListUserExampleByLastIDRequest) returns (ListUserExampleByLastIDReply) {
option (google.api.http) = {
get: "/api/v1/userExample/list"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "list of userExamples by last id",
description: "list of userExamples by last id",
//security: {
// security_requirement: {
// key: "BearerAuth";
// value: {}
// }
//}
};
}

// list of userExample by query parameters
rpc List(ListUserExampleRequest) returns (ListUserExampleReply) {
option (google.api.http) = {
Expand Down Expand Up @@ -282,6 +299,16 @@ message ListUserExampleByIDsReply {
repeated UserExample userExamples = 1;
}

message ListUserExampleByLastIDRequest {
uint64 lastID = 1 [(tagger.tags) = "form:\"lastID\""]; // last id
uint32 limit = 2 [(tagger.tags) = "form:\"limit\""]; // page size
string sort = 3 [(tagger.tags) = "form:\"sort\""]; // sort by column name of table, default is -id, the - sign indicates descending order.
}

message ListUserExampleByLastIDReply {
repeated UserExample userExamples = 1;
}

message ListUserExampleRequest {
types.Params params = 1 [(validate.rules).message.required = true];
}
Expand Down
Loading

0 comments on commit 1d81ccb

Please sign in to comment.