feature:自动化代码增加数据源配置功能

This commit is contained in:
pixelmaxQM
2024-04-27 21:48:24 +08:00
parent d9a43ea1d6
commit ff8344d671
4 changed files with 8 additions and 2 deletions
@@ -140,8 +140,11 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis
{{- if .HasDataSource }}
func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}DataSource() (res map[string][]map[string]any, err error) {
res = make(map[string][]map[string]any)
{{range $key, $value := .DataSourceMap}}
{{$db}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&res["{{$key}}"])
{{$key}} := make([]map[string]any, 0)
{{$db}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&{{$key}})
res["{{$key}}"] = {{$key}}
{{- end }}
return
}