From de33e527fcd4bdcef0d913df9c0899432a10a7e5 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sun, 27 Sep 2026 16:07:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=90=9B:=20treat=20a=20column=20saved?= =?UTF-8?q?=20with=20isQuery=20"0"=20as=20not=20queryable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- template/v4/dto.go.template | 7 +++---- template/v4/no_actions/apis.go.template | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/template/v4/dto.go.template b/template/v4/dto.go.template index 7619b066..10d6eb74 100644 --- a/template/v4/dto.go.template +++ b/template/v4/dto.go.template @@ -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 }} diff --git a/template/v4/no_actions/apis.go.template b/template/v4/no_actions/apis.go.template index a0825963..adfc9c99 100644 --- a/template/v4/no_actions/apis.go.template +++ b/template/v4/no_actions/apis.go.template @@ -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 }}