diff --git a/apps/develop/gen/gen.go b/apps/develop/gen/gen.go
index cdacf3b..35dec89 100644
--- a/apps/develop/gen/gen.go
+++ b/apps/develop/gen/gen.go
@@ -241,7 +241,7 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable
}
} else if s.IsTimeObject(dataType) {
//字段为时间类型
- column.GoType = "time.Time"
+ column.GoType = "Time"
column.HtmlType = "datetime"
} else if s.IsNumberObject(dataType) {
//字段为数字类型
diff --git a/resource/template/go/api.template b/resource/template/go/api.template
index 92b87b8..c319f2a 100644
--- a/resource/template/go/api.template
+++ b/resource/template/go/api.template
@@ -23,11 +23,19 @@ type {{.ClassName}}Api struct {
// @Router /{{.PackageName}}/{{.BusinessName}}/list [get]
// @Security
func (p *{{.ClassName}}Api) Get{{.ClassName}}List(rc *ctx.ReqCtx) {
-
+ data := entity.{{.ClassName}}{}
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
+ {{- range $index, $column := .Columns -}}
+ {{- if eq $column.IsRequired "1" -}}
+ {{- if eq $column.GoType "string" }}
+ data.{{$column.GoField}} = rc.GinCtx.Query("{{$column.JsonField}}")
+ {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") -}}
+ data.{{$column.GoField}} = ginx.QueryInt(rc.GinCtx, "{{$column.JsonField}}", 0)
+ {{- end -}}
+ {{- end -}}
+ {{- end }}
- data := entity.{{.ClassName}}{}
list, total := p.{{.ClassName}}App.FindListPage(pageNum, pageSize, data)
rc.ResData = map[string]interface{}{
diff --git a/resource/template/go/entity.template b/resource/template/go/entity.template
index b627590..5d0e4c3 100644
--- a/resource/template/go/entity.template
+++ b/resource/template/go/entity.template
@@ -4,9 +4,14 @@
// 生成人:{{.FunctionAuthor}}
// ==========================================================================
package entity
-{{$hasGTime:=true}}
-{{if $hasGTime}}import "time"{{end}}
+{{$hasGTime:=false}}
+{{- range $index, $column := .Columns -}}
+{{- if eq $column.GoType "Time" -}}
+{{$hasGTime = true}}
+{{- end -}}
+{{- end -}}
+{{if $hasGTime -}}import "time"{{- end }}
type {{.ClassName}} struct {
diff --git a/resource/template/go/service.template b/resource/template/go/service.template
index f8063ed..0253d00 100644
--- a/resource/template/go/service.template
+++ b/resource/template/go/service.template
@@ -51,10 +51,26 @@ func (m *{{.BusinessName}}ModelImpl) FindListPage(page, pageSize int, data entit
offset := pageSize * (page - 1)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
- if data.{{.PkGoField}} != 0 {
- db = db.Where("{{.PkColumn}} = ?", data.{{.PkGoField}})
- }
-
+ {{- range $index, $column := .Columns -}}
+ {{- if eq $column.IsQuery "1" -}}
+ {{ if eq $column.QueryType "LIKE" }}
+ if data.{{$column.GoField}} != "" {
+ db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
+ }
+ {{- end -}}
+ {{- if eq $column.QueryType "EQ" -}}
+ {{- if eq $column.GoType "string" }}
+ if data.{{$column.GoField}} != "" {
+ m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
+ }
+ {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
+ if data.{{$column.GoField}} != 0 {
+ m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
+ }
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+ {{- end}}
db.Where("delete_time IS NULL")
err := db.Count(&total).Error
err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error
@@ -66,10 +82,26 @@ func (m *{{.BusinessName}}ModelImpl) FindList(data entity.{{$model}}) *[]entity.
list := make([]entity.{{$model}}, 0)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
- if data.{{.PkGoField}} != 0 {
- db = db.Where("{{.PkColumn}} = ?", data.{{.PkGoField}})
- }
-
+ {{- range $index, $column := .Columns -}}
+ {{- if eq $column.IsQuery "1" -}}
+ {{- if eq $column.QueryType "LIKE" }}
+ if data.{{$column.GoField}} != "" {
+ db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
+ }
+ {{- end -}}
+ {{- if eq $column.QueryType "EQ" -}}
+ {{- if eq $column.GoType "string" }}
+ if data.{{$column.GoField}} != "" {
+ db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
+ }
+ {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
+ if data.{{$column.GoField}} != 0 {
+ db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
+ }
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+ {{- end}}
db.Where("delete_time IS NULL")
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询{{.TableComment}}列表失败")
return &list
diff --git a/resource/template/vue/edit-vue.template b/resource/template/vue/edit-vue.template
index a7af81b..27c3c04 100644
--- a/resource/template/vue/edit-vue.template
+++ b/resource/template/vue/edit-vue.template
@@ -10,29 +10,62 @@
ref="ruleFormRef"
label-width="80px"
>
-
-
-
-
-
-
-
-
-
-
- {{"{{"}} dict.dictLabel {{"}}"}}
-
+ {{- range $index, $column := .Columns -}}
+ {{- if and (eq $column.IsInsert "1") (ne $column.IsPk "1") -}}
+ {{- if eq $column.HtmlType "input" }}
+ el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
+
+
+ {{- else if eq $column.HtmlType "select" }}
+ {{if ne $column.DictType ""}}
+ el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
+
+ {{"{{"}} dict.dictLabel {{"}}"}}
+
+
+ {{- end }}
+ {{- else if eq $column.HtmlType "radio" }}
+ {{if ne $column.DictType ""}}
+
+
+ {{"{{"}} dict.dictLabel {{"}}"}}
-
-
-
+
+ {{- end }}
+ {{- else if eq $column.HtmlType "datetime" }}
+
+
+
+
+ {{- else if eq $column.HtmlType "textarea" -}}
+
+
+
+ {{- else if eq $column.HtmlType "checkbox" }}
+
+
+ {{"{{"}} dict.dictLabel {{"}}"}}
+
+
+ {{- end -}}
+ {{- end -}}
+ {{- end }}