forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
110 lines (92 loc) · 1.82 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package types
import (
"github.com/chenhg5/go-admin/modules/auth"
"github.com/chenhg5/go-admin/modules/menu"
"html/template"
)
type Component interface {
GetContent(interface{}) string
}
type Attribute struct {
Name string
Content string
}
var Default = &Attribute{
"Default",
"",
}
func (compo *Attribute) GetContent(value interface{}) string {
return compo.Content + value.(string)
}
type Page struct {
User auth.User
Menu menu.Menu
Panel Panel
System SystemInfo
AssertRootUrl string
Title string
Logo template.HTML
MiniLogo template.HTML
}
type SystemInfo struct {
Version string
}
// 表单列
type FormStruct struct {
Field string
TypeName string
Head string
Default string
Editable bool
FormType string
Value string
Options []map[string]string
ExcuFun FieldValueFun
}
type RowModel struct {
ID int64
Value string
}
// 数据过滤函数
type FieldValueFun func(value RowModel) interface{}
// 展示列
type FieldStruct struct {
ExcuFun FieldValueFun
Field string
TypeName string
Head string
Sortable bool
}
func (field *FieldStruct) SetHead(head string) *FieldStruct {
(*field).Head = head
return field
}
func (field *FieldStruct) SetTypeName(typeName string) *FieldStruct {
(*field).TypeName = typeName
return field
}
func (field *FieldStruct) SetField(fieldName string) *FieldStruct {
(*field).Field = fieldName
return field
}
// 展示面板
type InfoPanel struct {
FieldList []FieldStruct
Table string
Title string
Description string
}
// 表单面板
type FormPanel struct {
FormList []FormStruct
Table string
Title string
Description string
}
type Panel struct {
Content template.HTML
Title string
Description string
Url string
}
type GetPanel func() Panel