-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db1486f
commit 56f799b
Showing
12 changed files
with
184 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Gogen Application | ||
|
||
Call `gogen application myapp` will | ||
|
||
* create a folder and file application | ||
* binding all together the controller usecase and gateway |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Gogen Controller | ||
|
||
Call `gogen controller restapi` will | ||
|
||
* Create a controller folder | ||
* Collect all the fields from InportRequest and InportResponse | ||
* create an handler and router based on gogenrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Gogen Domain | ||
|
||
Calling `gogen domain yourdomainname` will | ||
|
||
* Provide all those files | ||
|
||
``` | ||
├── Dockerfile | ||
├── README.md | ||
├── config.json | ||
├── config.sample.json | ||
├── docker-compose.yml | ||
├── domain_yourdomainname | ||
│ └── README.md | ||
├── go.mod | ||
└── gitignore | ||
``` | ||
|
||
* Generate unique random secret key for your application in `config.json` | ||
* Copy the basic template for controller, gateway and crud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Gogen Gateway | ||
|
||
* Read the Outport and collect all must have method | ||
* Read the existing Gateway and collect all existing method | ||
* Create a gateway folder and file then | ||
* Create all non-existing must have method on Gateway based on gogenrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Gogen Repository | ||
|
||
Call `gogen repository SaveOrder Order RunOrderCreate` will | ||
|
||
* Create an entity Order (if not exist) | ||
``` | ||
└── domain_yourdomainname | ||
└── model | ||
├── entity | ||
│ └── order.go | ||
└── vo | ||
└── order_id.go | ||
``` | ||
|
||
* Create repository SaveOrderRepo (if not exist) | ||
``` | ||
└── domain_yourdomainname | ||
└── model | ||
└── repository | ||
└── repository.go | ||
``` | ||
|
||
* Inject code into Outport | ||
``` | ||
type Outport interface { | ||
repository.SaveOrderRepo | ||
} | ||
``` | ||
|
||
* Inject code into Interactor. It will replace the `//!` flag | ||
``` | ||
func (r *runOrderCreateInteractor) Execute(ctx context.Context, req InportRequest) (*InportResponse, error) { | ||
res := &InportResponse{} | ||
// code your usecase definition here ... | ||
orderObj, err := entity.NewOrder(entity.OrderCreateRequest{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = r.outport.SaveOrder(ctx, orderObj) | ||
if err != nil { | ||
return nil, err | ||
} | ||
//! | ||
return res, nil | ||
} | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Gogen Service | ||
|
||
Call `gogen service PublishOrder RunOrderCreate` will | ||
|
||
* Create service `PublishOrderService` (if not exist) | ||
``` | ||
└── domain_yourdomainname | ||
└── model | ||
└── service | ||
└── service.go | ||
``` | ||
|
||
* Inject code into Outport | ||
``` | ||
type Outport interface { | ||
service.PublishOrderService | ||
} | ||
``` | ||
|
||
* Inject code into Interactor. It will replace the `//!` flag | ||
``` | ||
func (r *runOrderCreateInteractor) Execute(ctx context.Context, req InportRequest) (*InportResponse, error) { | ||
res := &InportResponse{} | ||
// code your usecase definition here ... | ||
publishOrderResponse, err := r.outport.PublishOrder(ctx, service.PublishOrderServiceRequest{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
_ = publishOrderResponse | ||
//! | ||
return res, nil | ||
} | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Gogen Usecase | ||
|
||
Call `gogen usecase RunProductCreate` will | ||
|
||
* Create file Inport, Interactor and Outport | ||
|
||
``` | ||
└── domain_yourdomainname | ||
└── usecase | ||
└── runordercreate | ||
├── README.md | ||
├── inport.go | ||
├── interactor.go | ||
└── outport.go | ||
``` | ||
|
||
* There are specialization for Inport. | ||
|
||
if using prefix `GetAll` then InportRequest and InportResponse will have | ||
```go | ||
type InportRequest struct { | ||
Page int | ||
Size int | ||
} | ||
|
||
type InportResponse struct { | ||
Count int64 | ||
Items []any | ||
} | ||
``` | ||
otherwise it will be empty | ||
```go | ||
type InportRequest struct { | ||
|
||
} | ||
|
||
type InportResponse struct { | ||
|
||
} | ||
``` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
utils/templates/usecase/getall/domain_${domainname}/usecase/${usecasename}/inport._go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package {{LowerCase .UsecaseName}} | ||
|
||
import ( | ||
"context" | ||
"{{.PackagePath}}/shared/gogen" | ||
) | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
utils/templates/usecase/run/domain_${domainname}/usecase/${usecasename}/inport._go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters