Skip to content

Commit 63499a4

Browse files
committed
feature(1.2.8): 调整 internal 目录结构
1 parent 4980337 commit 63499a4

File tree

159 files changed

+1295
-1810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+1295
-1810
lines changed

assets/templates/generator/generator_handler.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<header class="card-header"><div class="card-title"> 生成控制器方法 </div></header>
1717
<div class="card-body">
1818
<div class="form-group">
19-
<label for="handlerName">handler 名称,例如:<code>user_handler</code></label>
19+
<label for="handlerName">API handler 名称,例如:<code>user</code><small>user 为 internal/api 目录下的文件夹名称</small></label>
2020
<input type="text" class="form-control" id="handlerName" placeholder="请输入 handler 名称">
2121
</div>
2222

cmd/gormgen/pkg/template.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"fmt"
2424
"time"
2525
26-
"github.com/xinliangnote/go-gin-api/internal/api/repository/db_repo"
26+
"github.com/xinliangnote/go-gin-api/internal/repository/mysql"
2727
2828
"github.com/pkg/errors"
2929
"gorm.io/gorm"
@@ -135,7 +135,7 @@ func (qb *{{.QueryBuilderName}}) Offset(offset int) *{{.QueryBuilderName}} {
135135
136136
{{$queryBuilderName := .QueryBuilderName}}
137137
{{range .OptionFields}}
138-
func (qb *{{$queryBuilderName}}) Where{{call $.Helpers.Titelize .FieldName}}(p db_repo.Predicate, value {{.FieldType}}) *{{$queryBuilderName}} {
138+
func (qb *{{$queryBuilderName}}) Where{{call $.Helpers.Titelize .FieldName}}(p mysql.Predicate, value {{.FieldType}}) *{{$queryBuilderName}} {
139139
qb.where = append(qb.where, struct {
140140
prefix string
141141
value interface{}

cmd/handlergen/README.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

cmd/handlergen/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func init() {
2525

2626
func main() {
2727
fs := token.NewFileSet()
28-
filePath := fmt.Sprintf("./internal/api/controller/%s", handlerName)
28+
filePath := fmt.Sprintf("./internal/api/%s", handlerName)
2929
parsedFile, err := decorator.ParseFile(fs, filePath+"/handler.go", nil, 0)
3030
if err != nil {
3131
log.Fatalf("parsing package: %s: %s\n", filePath, err)
@@ -59,7 +59,7 @@ func main() {
5959
continue
6060
}
6161

62-
filepath := "./internal/api/controller/" + handlerName
62+
filepath := "./internal/api/" + handlerName
6363
filename := fmt.Sprintf("%s/func_%s.go", filepath, strings.ToLower(v.Names[0].String()))
6464
funcFile, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0766)
6565
if err != nil {
@@ -89,7 +89,7 @@ func main() {
8989
funcContent += fmt.Sprintf("// @Description%s \n", nameArr[1])
9090
// Tags
9191
funcContent += fmt.Sprintf("%s \n", v.Decorations().Start.All()[1])
92-
funcContent += fmt.Sprintf("// @Accept json \n")
92+
funcContent += fmt.Sprintf("// @Accept multipart/form-data \n")
9393
funcContent += fmt.Sprintf("// @Produce json \n")
9494
funcContent += fmt.Sprintf("// @Param Request body %sRequest true \"请求信息\" \n", Lcfirst(v.Names[0].String()))
9595
funcContent += fmt.Sprintf("// @Success 200 {object} %sResponse \n", Lcfirst(v.Names[0].String()))

cmd/mysqlmd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func main() {
7575

7676
for _, table := range tables {
7777

78-
filepath := "./internal/api/repository/db_repo/" + table.Name + "_repo"
78+
filepath := "./internal/repository/mysql/" + table.Name
7979
_ = os.Mkdir(filepath, 0766)
8080
fmt.Println("create dir : ", filepath)
8181

@@ -85,17 +85,17 @@ func main() {
8585
fmt.Printf("markdown file error %v\n", err.Error())
8686
return
8787
}
88-
fmt.Println(" └── file : ", table.Name+"_repo/gen_table.md")
88+
fmt.Println(" └── file : ", table.Name+"/gen_table.md")
8989

9090
modelName := fmt.Sprintf("%s/gen_model.go", filepath)
9191
modelFile, err := os.OpenFile(modelName, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0766)
9292
if err != nil {
9393
fmt.Printf("create and open model file error %v\n", err.Error())
9494
return
9595
}
96-
fmt.Println(" └── file : ", table.Name+"_repo/gen_model.go")
96+
fmt.Println(" └── file : ", table.Name+"/gen_model.go")
9797

98-
modelContent := fmt.Sprintf("package %s%s\n", table.Name, "_repo")
98+
modelContent := fmt.Sprintf("package %s\n", table.Name)
9999
modelContent += fmt.Sprintf(`import "time"`)
100100
modelContent += fmt.Sprintf("\n\n// %s %s \n", capitalize(table.Name), table.Comment.String)
101101
modelContent += fmt.Sprintf("//go:generate gormgen -structs %s -input . \n", capitalize(table.Name))

0 commit comments

Comments
 (0)