mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-29 12:31:11 +00:00
fix🐛: treat a column saved with isQuery "0" as not queryable
The config page saves an unticked query box as "0", and the DTO and API templates tested IsQuery with a bare if, which is true for any non-empty string. A column ticked and then unticked became a filter of the generated list request and a documented query parameter anyway. They now require "1", as the TypeScript and Vue templates already do.
This commit is contained in:
@@ -10,8 +10,8 @@ import (
|
||||
{{- range .Columns -}}{{- if .Pk -}}{{- $pkType = .GoType -}}{{- if and (eq .GoField "Id") (eq .GoType "int") -}}{{- $embed = true -}}{{- end -}}{{- end -}}{{- end -}}
|
||||
{{- $bb := false -}}
|
||||
{{- range .Columns -}}
|
||||
{{- $z := .IsQuery -}}
|
||||
{{- if ($z) -}}
|
||||
{{- /* "1" exactly: the config page saves an unticked box as "0", which a bare if reads as true. */ -}}
|
||||
{{- if eq .IsQuery "1" -}}
|
||||
{{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -36,8 +36,7 @@ type {{.ClassName}}GetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
{{$z := .IsQuery}}
|
||||
{{- if ($z) }}
|
||||
{{- if eq .IsQuery "1" }}
|
||||
{{.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 }}
|
||||
|
||||
@@ -24,8 +24,7 @@ type {{.ClassName}} struct {
|
||||
// @Tags {{.TableComment}}
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
{{$z := .IsQuery}}
|
||||
{{- if ($z) }}
|
||||
{{- if eq .IsQuery "1" }}
|
||||
// @Param {{.JsonField}} query {{.GoType}} false "{{.ColumnComment}}"
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user