|
|
@@ -13,10 +13,10 @@ import (
|
|
|
)
|
|
|
|
|
|
// curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:10000/test/v1/class/create"
|
|
|
-// curl -X PUT -H "Content-Type: application/json" -d '{"id":"faa5452038204246971c48e5b0d775af", "name":"test-new"}' "http://localhost:10000/test/v1/class/update"
|
|
|
+// curl -X PUT -H "Content-Type: application/json" -d '{"id":"47748950c1c74e8c9cd9dc913996fc8b", "name":"test-new"}' "http://localhost:10000/test/v1/class/update"
|
|
|
// curl -X GET "http://localhost:10000/test/v1/class/query?name=test-new&pageNo=0&pageSize=1"
|
|
|
-// curl -X GET "http://localhost:10000/test/v1/class/get?id=faa5452038204246971c48e5b0d775af"
|
|
|
-// curl -X DELETE "http://localhost:10000/test/v1/class/faa5452038204246971c48e5b0d775af/delete"
|
|
|
+// curl -X GET "http://localhost:10000/test/v1/class/get?id=47748950c1c74e8c9cd9dc913996fc8b"
|
|
|
+// curl -X DELETE "http://localhost:10000/test/v1/class/47748950c1c74e8c9cd9dc913996fc8b/delete"
|
|
|
|
|
|
type CreateClassJsonBody struct {
|
|
|
Name string `json:"name" binding:"required" assign:"toField:Name"`
|
|
|
@@ -68,15 +68,7 @@ func main() {
|
|
|
Path: "/class/create",
|
|
|
ResponseFunc: binding.SendIDResponse[string],
|
|
|
DTO: &CreateClassJsonBody{},
|
|
|
- FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
|
- class := new(Class)
|
|
|
- err := binding.AssignDTOToDomainObject(dto, class)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- return []domain.Object{class}, nil
|
|
|
- },
|
|
|
+ Objects: []domain.Object{&Class{}},
|
|
|
ServiceFunc: func(c *api.Context, dto binding.DTO, objects []domain.Object) (string, error) {
|
|
|
e := domain.ToConcreteObject[*Class](objects[0])
|
|
|
e.ID = strutils.SimpleUUID()
|
|
|
@@ -90,13 +82,7 @@ func main() {
|
|
|
Path: "/class/:id/delete",
|
|
|
ResponseFunc: binding.SendMsgResponse,
|
|
|
DTO: &DeleteClassPathParams{},
|
|
|
- FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
|
- return []domain.Object{
|
|
|
- &Class{
|
|
|
- ID: binding.Field[string](dto, "ID"),
|
|
|
- },
|
|
|
- }, nil
|
|
|
- },
|
|
|
+ Objects: []domain.Object{&Class{}},
|
|
|
ServiceFunc: func(c *api.Context, dto binding.DTO, objects []domain.Object) (any, error) {
|
|
|
id := domain.Field[string](objects[0], "ID")
|
|
|
delete(classMap, id)
|
|
|
@@ -136,16 +122,7 @@ func main() {
|
|
|
Path: "/class/query",
|
|
|
ResponseFunc: binding.SendInfosResponse[ClassInfo],
|
|
|
DTO: &QueryClassesQueryParams{},
|
|
|
- FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
|
- class := new(Class)
|
|
|
- err := binding.AssignDTOToDomainObject(dto, class)
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- return []domain.Object{class}, nil
|
|
|
- },
|
|
|
+ Objects: []domain.Object{&Class{}},
|
|
|
ServiceFunc: func(c *api.Context, dto binding.DTO, objects []domain.Object) (binding.InfosData[ClassInfo], error) {
|
|
|
name := domain.Field[string](objects[0], "Name")
|
|
|
|
|
|
@@ -211,15 +188,7 @@ func main() {
|
|
|
Path: "/class/get",
|
|
|
ResponseFunc: binding.SendInfoResponse[*ClassInfo],
|
|
|
DTO: &GetClassQueryParams{},
|
|
|
- FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
|
- class := new(Class)
|
|
|
- err := binding.AssignDTOToDomainObject(dto, class)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- return []domain.Object{class}, nil
|
|
|
- },
|
|
|
+ Objects: []domain.Object{&Class{}},
|
|
|
ServiceFunc: func(c *api.Context, dto binding.DTO, objects []domain.Object) (*ClassInfo, error) {
|
|
|
id := domain.Field[string](objects[0], "ID")
|
|
|
|