修复优化自动代码中对bool类型搜索字段的支持

This commit is contained in:
hansonyu183
2020-06-20 13:01:08 +08:00
parent fe3256175d
commit 937239b7ba
3 changed files with 35 additions and 3 deletions
+7 -2
View File
@@ -7,6 +7,11 @@ import (
// 如果含有time.Time 请自行import time包
type {{.StructName}} struct {
gorm.Model {{range .Fields}}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"`{{ end }}
gorm.Model {{- range .Fields}}
{{- if eq .FieldType "bool" }}
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"`
{{- else }}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"`
{{- end }} {{- end }}
}
}
+1 -1
View File
@@ -71,7 +71,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "bool" }}
if info.{{.FieldName}} != 0 {
if info.{{.FieldName}} != nil {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "int" }}