mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
ormat🥚 :优化生成模版
This commit is contained in:
@@ -2,12 +2,11 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
//"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/{{.PackageName}}/models"
|
||||
common "go-admin/common/models"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/tools"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/logger"
|
||||
"go-admin/common/apis"
|
||||
)
|
||||
|
||||
type {{.ClassName}}Search struct {
|
||||
@@ -17,7 +16,6 @@ type {{.ClassName}}Search struct {
|
||||
{{$z := .IsQuery}}
|
||||
{{- if ($z) -}}
|
||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}" comment:"{{.ColumnComment}}"`
|
||||
|
||||
{{ end -}}
|
||||
{{- end }}
|
||||
}
|
||||
@@ -27,7 +25,7 @@ func (m *{{.ClassName}}Search) GetNeedSearch() interface{} {
|
||||
}
|
||||
|
||||
func (m *{{.ClassName}}Search) Bind(ctx *gin.Context) error {
|
||||
log := logger.GetRequestLogger(ctx)
|
||||
log := apis.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
@@ -45,16 +43,14 @@ type {{.ClassName}}Control struct {
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
|
||||
{{- else }}
|
||||
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{end -}}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) Bind(ctx *gin.Context) error {
|
||||
log := logger.GetRequestLogger(ctx)
|
||||
log := apis.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
@@ -77,8 +73,6 @@ func (s *{{.ClassName}}Control) Generate() (*models.{{.ClassName}}, error) {
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
|
||||
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}}: s.{{.GoField}},
|
||||
@@ -105,7 +99,7 @@ func (s *{{.ClassName}}ById) GetId() interface{} {
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) Bind(ctx *gin.Context) error {
|
||||
log := logger.GetRequestLogger(ctx)
|
||||
log := apis.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
@@ -120,4 +114,4 @@ func (s *{{.ClassName}}ById) Bind(ctx *gin.Context) error {
|
||||
|
||||
func (s *{{.ClassName}}ById) SetUpdateBy(id int) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user