Merge branch 'dev' of github.com:wenjianzhang/go-admin into table/dev
Conflicts: template/v2/dto.go.template template/v2/model.go.template
This commit is contained in:
commit
ca4ed89536
15 files changed
+61
-48
No files matched your search
+24
-24
@@ -2,46 +2,46 @@ import request from '@/utils/request'
|
||||
|
||||
// 查询{{.ClassName}}列表
|
||||
export function list{{.ClassName}}(query) {
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询{{.ClassName}}详细
|
||||
export function get{{.ClassName}} ({{.PkJsonField}}) {
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}/' + {{.PkJsonField}},
|
||||
method: 'get'
|
||||
})
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}/' + {{.PkJsonField}},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 新增{{.ClassName}}
|
||||
export function add{{.ClassName}}(data) {
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改{{.ClassName}}
|
||||
export function update{{.ClassName}}(data) {
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}/'+data.{{.PkJsonField}},
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}/'+data.{{.PkJsonField}},
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除{{.ClassName}}
|
||||
export function del{{.ClassName}}(data) {
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
return request({
|
||||
url: '/api/v1/{{.ModuleName}}',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/common/dto"
|
||||
orm "go-admin/common/global"
|
||||
@@ -29,7 +29,8 @@ type {{.ClassName}} struct {
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"`
|
||||
{{end -}}
|
||||
{{- end }}
|
||||
DataScope string `json:"dataScope" gorm:"-"`
|
||||
Params string `json:"params" gorm:"-"`
|
||||
@@ -50,11 +51,11 @@ func (e *{{.ClassName}}) GetId() interface{} {
|
||||
}
|
||||
|
||||
func (e *{{.ClassName}}) SetCreateBy(createBy uint) {
|
||||
e.CreateBy = strconv.Itoa(int(createBy))
|
||||
e.CreateBy = createBy
|
||||
}
|
||||
|
||||
func (e *{{.ClassName}}) SetUpdateBy(updateBy uint) {
|
||||
e.UpdateBy = strconv.Itoa(int(updateBy))
|
||||
e.UpdateBy = updateBy
|
||||
}
|
||||
|
||||
// 创建{{.ClassName}}
|
||||
|
||||
@@ -2,10 +2,11 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type {{.ClassName}}Search struct {
|
||||
@@ -49,6 +50,10 @@ type {{.ClassName}}Control struct {
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" }}
|
||||
|
||||
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
||||
{{- else if eq .GoField "UpdateBy" }}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
|
||||
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
@@ -56,6 +61,9 @@ type {{.ClassName}}Control struct {
|
||||
|
||||
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- else }}
|
||||
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
||||
{{end -}}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"` {{end -}}
|
||||
{{- end }}
|
||||
}
|
||||
@@ -74,7 +82,7 @@ func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
{{ range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
Model: gorm.Model{ID: s.Id},
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
@@ -83,7 +91,8 @@ func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
CreateBy: s.CreateBy,
|
||||
UpdateBy: s.UpdateBy,
|
||||
},
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}}: s.{{.GoField}},
|
||||
{{- end }}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
{{- if eq .IsActions 2 -}}
|
||||
|
||||
"go-admin/common/dto"
|
||||
@@ -8,7 +10,6 @@ import (
|
||||
orm "go-admin/common/global"
|
||||
{{ end }}
|
||||
"go-admin/common/models"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
@@ -40,7 +41,7 @@ func (e *{{.ClassName}}) Generate() models.ActiveRecord {
|
||||
}
|
||||
|
||||
func (e *{{.ClassName}}) GetId() interface{} {
|
||||
return e.ID
|
||||
return e.{{.PkGoField}}
|
||||
}
|
||||
|
||||
func (e *{{.ClassName}}) SetCreateBy(createBy uint) {
|
||||
|
||||
@@ -378,7 +378,7 @@
|
||||
{{- end -}}
|
||||
// 文件
|
||||
{{range .Columns}}
|
||||
{{- if ne .HtmlType "file" -}}
|
||||
{{- if eq .HtmlType "file" -}}
|
||||
fileShow{{.GoField}}: function() {
|
||||
this.fileOpen = true
|
||||
this.fileIndex = '{{.JsonField}}'
|
||||
|
||||
Reference in new issue
Block a user