dictionary_item.go
927 字节
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
package domain
// 字典明细项
type DictionaryItem struct {
// 项编码
ItemCode string `json:"itemCode"`
// 项标签
ItemLabel string `json:"itemLabel"`
// 值
ItemValue string `json:"itemValue"`
// 是否可见【1:不可以】【2:可以】
IsShow int `json:"isShow"`
// 显示序号
Sort int `json:"sort"`
}
type DictionaryItemShow int
const (
DictionaryItemIsShow int = 1 //不可见
DictionaryItemNotShow int = 2 //可见
)
func (show DictionaryItemShow) Valid() bool {
var ok bool
switch int(show) {
case DictionaryItemNotShow:
ok = true
case DictionaryItemIsShow:
ok = true
default:
ok = false
}
return ok
}
//明细项排序
type DictionaryItems []DictionaryItem
func (a DictionaryItems) Len() int { return len(a) }
func (a DictionaryItems) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a DictionaryItems) Less(i, j int) bool { return a[i].Sort < a[j].Sort }