Skip to content

Commit ad5afbe

Browse files
author
piexlMax(奇淼
committed
feat: 调整模板方法位置,清空现有方法
1 parent 379f5fe commit ad5afbe

File tree

6 files changed

+54
-39
lines changed

6 files changed

+54
-39
lines changed

Diff for: server/resource/plugin/server/model/model.go.template

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
// 在结构体中新增如下字段
33
{{- range .Fields}}
44
{{- if eq .FieldType "enum" }}
5-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:enum({{.DataTypeLong}});" {{- if .Require }} binding:"required"{{- end -}}`
5+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}`
66
{{- else if eq .FieldType "picture" }}
7-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
7+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
88
{{- else if eq .FieldType "video" }}
9-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
9+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
1010
{{- else if eq .FieldType "file" }}
11-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
11+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
1212
{{- else if eq .FieldType "pictures" }}
13-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
13+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
1414
{{- else if eq .FieldType "richtext" }}
15-
{{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end -}}`
15+
{{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}`
1616
{{- else if eq .FieldType "json" }}
17-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"`
17+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"`
1818
{{- else if eq .FieldType "array" }}
19-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
19+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
2020
{{- else }}
21-
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
21+
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
2222
{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }}
2323
{{- end }}
2424

@@ -47,23 +47,23 @@ type {{.StructName}} struct {
4747
{{- end }}
4848
{{- range .Fields}}
4949
{{- if eq .FieldType "enum" }}
50-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:enum({{.DataTypeLong}});" {{- if .Require }} binding:"required"{{- end -}}`
50+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}`
5151
{{- else if eq .FieldType "picture" }}
52-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
52+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
5353
{{- else if eq .FieldType "video" }}
54-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
54+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
5555
{{- else if eq .FieldType "file" }}
56-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
56+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
5757
{{- else if eq .FieldType "pictures" }}
58-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
58+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
5959
{{- else if eq .FieldType "richtext" }}
60-
{{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end -}}`
60+
{{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}`
6161
{{- else if eq .FieldType "json" }}
62-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"`
62+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"`
6363
{{- else if eq .FieldType "array" }}
64-
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
64+
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"`
6565
{{- else }}
66-
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}`
66+
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
6767
{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }}
6868
{{- end }}
6969
{{- if .AutoCreateResource }}

Diff for: server/resource/plugin/server/model/request/request.go.template

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
{{- range .Fields}}
44
{{- if ne .FieldSearchType ""}}
55
{{- if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
6-
Start{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag (print "start" .FieldName) false }}`
7-
End{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag (print "end" .FieldName) false }}`
6+
Start{{.FieldName}} *{{.FieldType}} `json:"start{{.FieldName}}" form:"start{{.FieldName}}"`
7+
End{{.FieldName}} *{{.FieldType}} `json:"end{{.FieldName}}" form:"end{{.FieldName}}"`
88
{{- else }}
99
{{- if or (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "pictures") (eq .FieldType "video") (eq .FieldType "json") }}
10-
{{.FieldName}} string `{{ formatFieldTag .FieldJson false }}`
10+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
1111
{{- else }}
12-
{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag .FieldJson false }}`
12+
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
1313
{{- end }}
1414
{{- end }}
1515
{{- end}}
@@ -36,13 +36,13 @@ type {{.StructName}}Search struct{
3636
{{- range .Fields}}
3737
{{- if ne .FieldSearchType ""}}
3838
{{- if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
39-
Start{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag (print "start" .FieldName) false }}`
40-
End{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag (print "end" .FieldName) false }}`
39+
Start{{.FieldName}} *{{.FieldType}} `json:"start{{.FieldName}}" form:"start{{.FieldName}}"`
40+
End{{.FieldName}} *{{.FieldType}} `json:"end{{.FieldName}}" form:"end{{.FieldName}}"`
4141
{{- else }}
4242
{{- if or (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "pictures") (eq .FieldType "video") (eq .FieldType "json") }}
43-
{{.FieldName}} string `{{ formatFieldTag .FieldJson false }}`
43+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
4444
{{- else }}
45-
{{.FieldName}} *{{.FieldType}} `{{ formatFieldTag .FieldJson false }}`
45+
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
4646
{{- end }}
4747
{{- end }}
4848
{{- end}}

Diff for: server/resource/plugin/server/service/service.go.template

+22-8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@
1111
{{- range .Fields}}
1212
{{- if .FieldSearchType}}
1313
{{- if or (eq .FieldType "enum") (eq .FieldType "pictures") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "json") }}
14-
{{ formatSearchCondition .ColumnName .FieldSearchType .FieldName .FieldType }}
15-
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
16-
{{ formatBetweenCondition .ColumnName .FieldSearchType .FieldName }}
17-
{{- else}}
18-
{{ formatSearchCondition .ColumnName .FieldSearchType .FieldName .FieldType }}
14+
if info.{{.FieldName}} != "" {
15+
{{- if or (eq .FieldType "enum") }}
16+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}*info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
17+
{{- else}}
18+
// 数据类型为复杂类型,请根据业务需求自行实现复杂类型的查询业务
19+
{{- end}}
20+
}
21+
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
22+
if info.Start{{.FieldName}} != nil && info.End{{.FieldName}} != nil {
23+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ? AND ? ",info.Start{{.FieldName}},info.End{{.FieldName}})
24+
}
25+
{{- else}}
26+
if info.{{.FieldName}} != nil{{- if eq .FieldType "string" }} && *info.{{.FieldName}} != ""{{- end }} {
27+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}*info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
28+
}
1929
{{- end }}
2030
{{- end }}
2131
{{- end }}
@@ -180,15 +190,19 @@ func (s *{{.Abbreviation}}) Get{{.StructName}}InfoList(ctx context.Context, info
180190
{{- if or (eq .FieldType "enum") (eq .FieldType "pictures") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "json") }}
181191
if info.{{.FieldName}} != "" {
182192
{{- if or (eq .FieldType "enum")}}
183-
{{ formatLikeCondition .ColumnName .FieldName }}
193+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}*info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
184194
{{- else}}
185195
// 数据类型为复杂类型,请根据业务需求自行实现复杂类型的查询业务
186196
{{- end}}
187197
}
188198
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
189-
{{ formatBetweenCondition .ColumnName .FieldSearchType .FieldName }}
199+
if info.Start{{.FieldName}} != nil && info.End{{.FieldName}} != nil {
200+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ? AND ? ",info.Start{{.FieldName}},info.End{{.FieldName}})
201+
}
190202
{{- else}}
191-
{{ formatSearchCondition .ColumnName .FieldSearchType .FieldName .FieldType }}
203+
if info.{{.FieldName}} != nil{{- if eq .FieldType "string" }} && *info.{{.FieldName}} != ""{{- end }} {
204+
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}*info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
205+
}
192206
{{- end }}
193207
{{- end }}
194208
{{- end }}

Diff for: server/service/system/auto_code_package.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
1010
"github.com/flipped-aurora/gin-vue-admin/server/utils"
1111
"github.com/flipped-aurora/gin-vue-admin/server/utils/ast"
12+
"github.com/flipped-aurora/gin-vue-admin/server/utils/autocode"
1213
"github.com/pkg/errors"
1314
"go/token"
1415
"gorm.io/gorm"
@@ -58,7 +59,7 @@ func (s *autoCodePackage) Create(ctx context.Context, info *request.SysAutoCodeP
5859
}
5960
for key, value := range creates { // key 为 模版绝对路径
6061
var files *template.Template
61-
files, err = template.New(filepath.Base(key)).Funcs(utils.GetTemplateFuncMap()).ParseFiles(key)
62+
files, err = template.New(filepath.Base(key)).Funcs(autocode.GetTemplateFuncMap()).ParseFiles(key)
6263
if err != nil {
6364
return errors.Wrapf(err, "[filepath:%s]读取模版文件失败!", key)
6465
}

0 commit comments

Comments
 (0)