|
2 | 2 | // 在结构体中新增如下字段
|
3 | 3 | {{- range .Fields}}
|
4 | 4 | {{- if eq .FieldType "enum" }}
|
5 |
| -{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:enum({{.DataTypeLong}});" {{- if .Require }} binding:"required"{{- end -}}` |
| 5 | +{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}` |
6 | 6 | {{- else if eq .FieldType "picture" }}
|
7 |
| -{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 7 | +{{.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 -}}` |
8 | 8 | {{- else if eq .FieldType "video" }}
|
9 |
| -{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 9 | +{{.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 -}}` |
10 | 10 | {{- else if eq .FieldType "file" }}
|
11 |
| -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 11 | +{{.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"` |
12 | 12 | {{- else if eq .FieldType "pictures" }}
|
13 |
| -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 13 | +{{.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"` |
14 | 14 | {{- else if eq .FieldType "richtext" }}
|
15 |
| -{{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end -}}` |
| 15 | +{{.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 -}}` |
16 | 16 | {{- else if eq .FieldType "json" }}
|
17 |
| -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` |
| 17 | +{{.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"` |
18 | 18 | {{- else if eq .FieldType "array" }}
|
19 |
| -{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 19 | +{{.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"` |
20 | 20 | {{- else }}
|
21 |
| -{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 21 | +{{.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 -}}` |
22 | 22 | {{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }}
|
23 | 23 | {{- end }}
|
24 | 24 |
|
@@ -47,23 +47,23 @@ type {{.StructName}} struct {
|
47 | 47 | {{- end }}
|
48 | 48 | {{- range .Fields}}
|
49 | 49 | {{- if eq .FieldType "enum" }}
|
50 |
| - {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:enum({{.DataTypeLong}});" {{- if .Require }} binding:"required"{{- end -}}` |
| 50 | + {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}` |
51 | 51 | {{- else if eq .FieldType "picture" }}
|
52 |
| - {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 52 | + {{.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 -}}` |
53 | 53 | {{- else if eq .FieldType "video" }}
|
54 |
| - {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 54 | + {{.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 -}}` |
55 | 55 | {{- else if eq .FieldType "file" }}
|
56 |
| - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 56 | + {{.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"` |
57 | 57 | {{- else if eq .FieldType "pictures" }}
|
58 |
| - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 58 | + {{.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"` |
59 | 59 | {{- else if eq .FieldType "richtext" }}
|
60 |
| - {{.FieldName}} *string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end -}}` |
| 60 | + {{.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 -}}` |
61 | 61 | {{- else if eq .FieldType "json" }}
|
62 |
| - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"object"` |
| 62 | + {{.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"` |
63 | 63 | {{- else if eq .FieldType "array" }}
|
64 |
| - {{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};type:text;" {{- if .Require }} binding:"required"{{- end }} swaggertype:"array,object"` |
| 64 | + {{.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"` |
65 | 65 | {{- else }}
|
66 |
| - {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{ formatGormTag .FieldIndexType .PrimaryKey .DefaultValue .ColumnName .Comment .DataTypeLong }};" {{- if .Require }} binding:"required"{{- end -}}` |
| 66 | + {{.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 -}}` |
67 | 67 | {{- end }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }}
|
68 | 68 | {{- end }}
|
69 | 69 | {{- if .AutoCreateResource }}
|
|
0 commit comments