dictionary.go
1.4 KB
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
package domain
// 字典
type Dictionary struct {
// 字典编号 主键
DictionaryId int64 `json:"dictionaryId"`
// 字典编码
DictCode string `json:"dictCode"`
// 字典名称
DictName string `json:"dictName"`
// 备注信息
Desc string `json:"desc"`
// 是否可见【1:不可以】【2:可以】
IsShow int `json:"isShow"`
// 字典值列表
DictItems []*DictionaryItem `json:"dictItems"`
}
type DictionaryRepository interface {
Save(dictionary *Dictionary) (*Dictionary, error)
Remove(dictionary *Dictionary) (*Dictionary, error)
FindOne(queryOptions map[string]interface{}) (*Dictionary, error)
Find(queryOptions map[string]interface{}) (int64, []*Dictionary, error)
}
func (dictionary *Dictionary) Identify() interface{} {
if dictionary.DictionaryId == 0 {
return nil
}
return dictionary.DictionaryId
}
func (dictionary *Dictionary) Update(data map[string]interface{}) error {
if dictionaryId, ok := data["dictionaryId"]; ok {
dictionary.DictionaryId = dictionaryId.(int64)
}
if dictCode, ok := data["dictCode"]; ok {
dictionary.DictCode = dictCode.(string)
}
if dictName, ok := data["dictName"]; ok {
dictionary.DictName = dictName.(string)
}
if desc, ok := data["desc"]; ok {
dictionary.Desc = desc.(string)
}
if isShow, ok := data["isShow"]; ok {
dictionary.IsShow = isShow.(int)
}
if dictItems, ok := data["dictItems"]; ok {
dictionary.DictItems = dictItems.([]*DictionaryItem)
}
return nil
}