Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func InitProject(input InitProjectInput) (string, error) {
DevEnvironment: "dev",
TestEnvironment: "test",
GoVersion: "1.24",
GoDeps: deps.Init(input.ModuleName),
GoDeps: deps.Init(input.ModuleName, ""),
}
)
for _, dir := range initialFiles {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ gomancer gen Client name:string dob:time:optional status:enum/active/deactivated
}
log.Debug("input generated", "input", input)

goDeps, inCreation := deps.Init(input.ModuleInfo.Name), deps.InCreation(input.ModuleInfo.Name, input.PackageEntityName)
goDeps, inCreation := deps.Init(input.ModuleInfo.Name, input.LowerNoSpaceCase), deps.InCreation(input.ModuleInfo.Name, input.PackageEntityName)

if err := models.GenerateModel(input, goDeps); err != nil {
log.Error(err)
Expand Down
6 changes: 3 additions & 3 deletions controllers/echoimpl/fixtures/web_controller.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
validate "github.com/gookit/validate"
i18n "github.com/invopop/ctxi18n/i18n"
http "net/http"
posttestpages "github.com/user/project_name/cmd/service/controllers/posttestpages"
posttestpages "github.com/user/project_name/cmd/service/controllers/posttestpages"
toast "github.com/user/project_name/core/coretpls/toast"
validator "github.com/user/project_name/core/validator"

Expand Down Expand Up @@ -45,9 +45,9 @@ func (c *PostTestWebController) SetUpRoutes(group *echo.Group) {
// Creates a user
postTestGroup.POST("", c.SaveHandler)
// Patch user
postTestGroup.PATCH("/:id", c.SaveHandler)
postTestGroup.PATCH("/:id", c.PartialUpdateByIdHandler)
// Updates all user
postTestGroup.PUT("/:id", c.PartialUpdateByIdHandler)
postTestGroup.PUT("/:id", c.SaveHandler)
// Deletes a user
postTestGroup.DELETE("/:id", c.DeleteByIdHandler)
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/echoimpl/templates/web_controller.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
{{.GoDeps.GookitValidate.GenerateImportString}}
{{.GoDeps.I18n.GenerateImportString}}
{{.GoDeps.Std.Net.Http.GenerateImportString}}
{{$pagesPackage}} "{{print .GoDeps.Project.Cmd.Controllers.Path "/" $pagesPackage}}"
{{.GoDeps.Project.Cmd.Controllers.ModelPages.GenerateImportString}}
{{.GoDeps.Project.Core.CoreTpls.Toast.GenerateImportString}}
{{.GoDeps.Project.Core.Validator.GenerateImportString}}

Expand Down Expand Up @@ -45,9 +45,9 @@ func (c *{{.PascalCase}}WebController) SetUpRoutes(group *echo.Group) {
// Creates a user
{{.CamelCase}}Group.POST("", c.SaveHandler)
// Patch user
{{.CamelCase}}Group.PATCH("/:id", c.SaveHandler)
{{.CamelCase}}Group.PATCH("/:id", c.PartialUpdateByIdHandler)
// Updates all user
{{.CamelCase}}Group.PUT("/:id", c.PartialUpdateByIdHandler)
{{.CamelCase}}Group.PUT("/:id", c.SaveHandler)
// Deletes a user
{{.CamelCase}}Group.DELETE("/:id", c.DeleteByIdHandler)
}
Expand Down
7 changes: 6 additions & 1 deletion deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"path"
)

func Init(moduleName string) Container {
func Init(moduleName, lowerNoSpaceCase string) Container {
modelPagesPackageName := fmt.Sprintf("%spages", lowerNoSpaceCase)
return Container{
Echo: Echo{
Dependency: Dependency{
Expand Down Expand Up @@ -194,6 +195,10 @@ func Init(moduleName string) Container {
Path: buildPath(moduleName, "cmd", "service", "controllers"),
Alias: "controllers",
},
ModelPages: Dependency{
Path: buildPath(moduleName, "cmd", "service", "controllers", modelPagesPackageName),
Alias: modelPagesPackageName,
},
InitPages: Dependency{
Path: buildPath(moduleName, "cmd", "service", "controllers", "initpages"),
Alias: "initpages",
Expand Down
6 changes: 5 additions & 1 deletion deps/deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var _ = Describe("Deps", func() {
var container deps.Container

BeforeEach(func() {
container = deps.Init(testfixtures.ModelBinaryIdSuccess.ModuleInfo.Name)
container = deps.Init(testfixtures.ModelBinaryIdSuccess.ModuleInfo.Name, testfixtures.ModelBinaryIdSuccess.TransformedText.LowerNoSpaceCase)
})

Describe("InCreation", func() {
Expand Down Expand Up @@ -311,6 +311,10 @@ var _ = Describe("Deps", func() {
Expect(container.Project.Cmd.Service.Controllers.Path).To(Equal(testfixtures.TestPath + "/cmd/service/controllers"))
container.Project.Cmd.Service.Controllers.ImportAlias(file)

Expect(container.Project.Cmd.Service.Controllers.ModelPages.Alias).To(Equal("posttestpages"))
Expect(container.Project.Cmd.Service.Controllers.ModelPages.Path).To(Equal(testfixtures.TestPath + "/cmd/service/controllers/posttestpages"))
container.Project.Cmd.Service.Controllers.ModelPages.ImportAlias(file)

Expect(container.Project.Cmd.Service.Controllers.InitPages.Alias).To(Equal("initpages"))
Expect(container.Project.Cmd.Service.Controllers.InitPages.Path).To(Equal(testfixtures.TestPath + "/cmd/service/controllers/initpages"))
container.Project.Cmd.Service.Controllers.ImportAlias(file)
Expand Down
3 changes: 2 additions & 1 deletion deps/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type (
}
Controllers struct {
Dependency
InitPages Dependency
InitPages Dependency
ModelPages Dependency
}

Components struct {
Expand Down
2 changes: 1 addition & 1 deletion testfixtures/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,6 @@ var (
},
}

ModelSuccessDepsContainer = deps.Init(ModelBinaryIdSuccess.ModuleInfo.Name)
ModelSuccessDepsContainer = deps.Init(ModelBinaryIdSuccess.ModuleInfo.Name, ModelBinaryIdSuccess.TransformedText.LowerNoSpaceCase)
ModelSuccessDepInCreation = deps.InCreation(ModelBinaryIdSuccess.ModuleInfo.Name, ModelBinaryIdSuccess.PackageEntityName)
)
Loading