From 532d282509e28c2572daa5ca0fa1d5175827d47f Mon Sep 17 00:00:00 2001 From: "Feng.YJ" <32027253+huiyifyj@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93=20tag=20=E5=AD=97=E6=AE=B5=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BB=A5=E5=8F=8A=E5=85=B6=E5=AE=83=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E5=92=8C=E5=B0=BE=E9=83=A8=E7=A9=BA=E6=A0=BC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1968)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复生成的结构体 tag 字段错误 * 移除字段注释多余尾部空格 * 文件模板注释 `@accept` 保持规范 --- server/resource/function/api.go.tpl | 6 +++--- server/resource/function/api.js.tpl | 6 +++--- server/resource/package/server/api/api.go.tpl | 18 ++++++++--------- .../package/server/model/model.go.tpl | 20 +++++++++---------- server/resource/package/web/api/api.js.tpl | 16 +++++++-------- .../plugin/server/api/api.go.template | 18 ++++++++--------- .../plugin/server/model/model.go.template | 18 ++++++++--------- .../resource/plugin/web/api/api.js.template | 18 ++++++++--------- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/server/resource/function/api.go.tpl b/server/resource/function/api.go.tpl index 1d276cff63..4b5bd666ae 100644 --- a/server/resource/function/api.go.tpl +++ b/server/resource/function/api.go.tpl @@ -2,7 +2,7 @@ // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -22,7 +22,7 @@ func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) { // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "成功" // @Success 200 {object} response.Response{data=object,msg=string} "成功" @@ -37,4 +37,4 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api){{.FuncName}}(c *gin.Context) { } response.OkWithData("返回数据",c) } -{{end}} \ No newline at end of file +{{end}} diff --git a/server/resource/function/api.js.tpl b/server/resource/function/api.js.tpl index 5cc491fe32..a07b102307 100644 --- a/server/resource/function/api.js.tpl +++ b/server/resource/function/api.js.tpl @@ -2,7 +2,7 @@ // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -18,7 +18,7 @@ export const {{.Router}} = () => { // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -29,4 +29,4 @@ export const {{.Router}} = () => { }) } -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/server/resource/package/server/api/api.go.tpl b/server/resource/package/server/api/api.go.tpl index 15826bce37..83b364decf 100644 --- a/server/resource/package/server/api/api.go.tpl +++ b/server/resource/package/server/api/api.go.tpl @@ -27,7 +27,7 @@ type {{.StructName}}Api struct {} // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "创建{{.Description}}" // @Success 200 {object} response.Response{msg=string} "创建成功" @@ -55,7 +55,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Create{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "删除{{.Description}}" // @Success 200 {object} response.Response{msg=string} "删除成功" @@ -78,7 +78,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{msg=string} "批量删除成功" // @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete] @@ -100,7 +100,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}ByIds(c *gi // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "更新{{.Description}}" // @Success 200 {object} response.Response{msg=string} "更新成功" @@ -128,7 +128,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.PrimaryField.FieldType}} true "用id查询{{.Description}}" // @Success 200 {object} response.Response{data={{.Package}}.{{.StructName}},msg=string} "查询成功" @@ -149,7 +149,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Conte // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" // @Router /{{.Abbreviation}}/get{{.StructName}}List [get] @@ -167,7 +167,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Co // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" @@ -198,7 +198,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Co // Get{{.StructName}}DataSource 获取{{.StructName}}的数据源 // @Tags {{.StructName}} // @Summary 获取{{.StructName}}的数据源 -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "查询成功" // @Router /{{.Abbreviation}}/get{{.StructName}}DataSource [get] @@ -219,7 +219,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}DataSource(c * // Get{{.StructName}}Public 不需要鉴权的{{.Description}}接口 // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/get{{.StructName}}Public [get] diff --git a/server/resource/package/server/model/model.go.tpl b/server/resource/package/server/model/model.go.tpl index 82f33dab8c..3114b9cc0b 100644 --- a/server/resource/package/server/model/model.go.tpl +++ b/server/resource/package/server/model/model.go.tpl @@ -8,18 +8,18 @@ {{- else if eq .FieldType "video" }} {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "file" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "pictures" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "richtext" }} {{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "json" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` {{- else if eq .FieldType "array" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else }} {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` -{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}} {{ end }} +{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} {{- end }} {{ else }} @@ -54,18 +54,18 @@ type {{.StructName}} struct { {{- else if eq .FieldType "video" }} {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "file" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "pictures" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "richtext" }} {{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "json" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` {{- else if eq .FieldType "array" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else }} {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` - {{- end }} {{ if .FieldDesc }}//{{.FieldDesc}} {{ end }} + {{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} {{- end }} {{- if .AutoCreateResource }} CreatedBy uint `gorm:"column:created_by;comment:创建者"` diff --git a/server/resource/package/web/api/api.js.tpl b/server/resource/package/web/api/api.js.tpl index 94085baa11..a41ef6f27a 100644 --- a/server/resource/package/web/api/api.js.tpl +++ b/server/resource/package/web/api/api.js.tpl @@ -4,7 +4,7 @@ import service from '@/utils/request' // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "创建{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" @@ -20,7 +20,7 @@ export const create{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -36,7 +36,7 @@ export const delete{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body request.IdsReq true "批量删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -52,7 +52,7 @@ export const delete{{.StructName}}ByIds = (params) => { // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "更新{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" @@ -68,7 +68,7 @@ export const update{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query model.{{.StructName}} true "用id查询{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" @@ -84,7 +84,7 @@ export const find{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query request.PageInfo true "分页获取{{.Description}}列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" @@ -101,7 +101,7 @@ export const get{{.StructName}}List = (params) => { // @Tags {{.StructName}} // @Summary 获取数据源 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /{{.Abbreviation}}/find{{.StructName}}DataSource [get] @@ -117,7 +117,7 @@ export const get{{.StructName}}DataSource = () => { // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" diff --git a/server/resource/plugin/server/api/api.go.template b/server/resource/plugin/server/api/api.go.template index bd6a5f27a6..a5ee38c6a0 100644 --- a/server/resource/plugin/server/api/api.go.template +++ b/server/resource/plugin/server/api/api.go.template @@ -27,7 +27,7 @@ type {{.Abbreviation}} struct {} // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "创建{{.Description}}" // @Success 200 {object} response.Response{msg=string} "创建成功" @@ -55,7 +55,7 @@ func (a *{{.Abbreviation}}) Create{{.StructName}}(c *gin.Context) { // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "删除{{.Description}}" // @Success 200 {object} response.Response{msg=string} "删除成功" @@ -78,7 +78,7 @@ func (a *{{.Abbreviation}}) Delete{{.StructName}}(c *gin.Context) { // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{msg=string} "批量删除成功" // @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete] @@ -100,7 +100,7 @@ func (a *{{.Abbreviation}}) Delete{{.StructName}}ByIds(c *gin.Context) { // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "更新{{.Description}}" // @Success 200 {object} response.Response{msg=string} "更新成功" @@ -128,7 +128,7 @@ func (a *{{.Abbreviation}}) Update{{.StructName}}(c *gin.Context) { // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query model.{{.StructName}} true "用id查询{{.Description}}" // @Success 200 {object} response.Response{data=model.{{.StructName}},msg=string} "查询成功" @@ -149,7 +149,7 @@ func (a *{{.Abbreviation}}) Find{{.StructName}}(c *gin.Context) { // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" // @Router /{{.Abbreviation}}/get{{.StructName}}List [get] @@ -167,7 +167,7 @@ func (a *{{.Abbreviation}}) Get{{.StructName}}List(c *gin.Context) { // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" @@ -198,7 +198,7 @@ func (a *{{.Abbreviation}}) Get{{.StructName}}List(c *gin.Context) { // Get{{.StructName}}DataSource 获取{{.StructName}}的数据源 // @Tags {{.StructName}} // @Summary 获取{{.StructName}}的数据源 -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "查询成功" // @Router /{{.Abbreviation}}/get{{.StructName}}DataSource [get] @@ -217,7 +217,7 @@ func (a *{{.Abbreviation}}) Get{{.StructName}}DataSource(c *gin.Context) { // Get{{.StructName}}Public 不需要鉴权的{{.Description}}接口 // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/get{{.StructName}}Public [get] diff --git a/server/resource/plugin/server/model/model.go.template b/server/resource/plugin/server/model/model.go.template index 2f1d35dd13..0483771614 100644 --- a/server/resource/plugin/server/model/model.go.template +++ b/server/resource/plugin/server/model/model.go.template @@ -8,18 +8,18 @@ {{- else if eq .FieldType "video" }} {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "file" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "pictures" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "richtext" }} {{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "json" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` {{- else if eq .FieldType "array" }} -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` +{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else }} {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` -{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}} {{ end }} +{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} {{- end }} {{ else }} @@ -53,15 +53,15 @@ type {{.StructName}} struct { {{- else if eq .FieldType "video" }} {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "file" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "pictures" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else if eq .FieldType "richtext" }} {{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}` {{- else if eq .FieldType "json" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` {{- else if eq .FieldType "array" }} - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"` + {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` {{- else }} {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}` {{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} diff --git a/server/resource/plugin/web/api/api.js.template b/server/resource/plugin/web/api/api.js.template index 208f386e40..0462fde8b7 100644 --- a/server/resource/plugin/web/api/api.js.template +++ b/server/resource/plugin/web/api/api.js.template @@ -3,7 +3,7 @@ import service from '@/utils/request' // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "创建{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" @@ -19,7 +19,7 @@ export const create{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -35,7 +35,7 @@ export const delete{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body request.IdsReq true "批量删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -51,7 +51,7 @@ export const delete{{.StructName}}ByIds = (params) => { // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "更新{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" @@ -67,7 +67,7 @@ export const update{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query model.{{.StructName}} true "用id查询{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" @@ -83,7 +83,7 @@ export const find{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query request.PageInfo true "分页获取{{.Description}}列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" @@ -100,7 +100,7 @@ export const get{{.StructName}}List = (params) => { // @Tags {{.StructName}} // @Summary 获取数据源 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /{{.Abbreviation}}/find{{.StructName}}DataSource [get] @@ -114,7 +114,7 @@ export const get{{.StructName}}DataSource = () => { {{- end}} // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" @@ -124,4 +124,4 @@ export const get{{.StructName}}Public = () => { url: '/{{.Abbreviation}}/get{{.StructName}}Public', method: 'get', }) -} \ No newline at end of file +}