notice_setting.go
2.6 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
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
package domain
import "time"
// 是否推送 【是:1】【否:2】
const (
NoticeSettingIsPush = 1
NoticeSettingIsNotPush = 2
)
// 编排消息通知内容
type NoticeSetting struct {
// 消息id
NoticeSettingId int64 `json:"noticeSettingId"`
// 公司id
CompanyId int64 `json:"companyId"`
// 内容模板
Content string `json:"content"`
// 是否推送 【是:1】【否:2】
IsPush int `json:"isPush"`
// 消息对应的业务模块
Module string `json:"module"`
ModuleName string `json:"moduleName"`
// 业务环节
ModuleAction string `json:"moduleAction"`
ModuleActionName string `json:"moduleActionName"`
// 组织id
OrgId int64 `json:"orgId"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
}
//OrgId+ModuleAction 做唯一索引
type NoticeSettingRepository interface {
Save(noticeSetting *NoticeSetting) (*NoticeSetting, error)
Remove(noticeSetting *NoticeSetting) (*NoticeSetting, error)
FindOne(queryOptions map[string]interface{}) (*NoticeSetting, error)
Find(queryOptions map[string]interface{}) (int64, []*NoticeSetting, error)
}
func (noticeSetting *NoticeSetting) Identify() interface{} {
if noticeSetting.NoticeSettingId == 0 {
return nil
}
return noticeSetting.NoticeSettingId
}
func (noticeSetting *NoticeSetting) Update(data map[string]interface{}) error {
if companyId, ok := data["companyId"]; ok {
noticeSetting.CompanyId = companyId.(int64)
}
if content, ok := data["content"]; ok {
noticeSetting.Content = content.(string)
}
if isPush, ok := data["isPush"]; ok {
noticeSetting.IsPush = isPush.(int)
}
if module, ok := data["module"]; ok {
noticeSetting.Module = module.(string)
}
if moduleName, ok := data["moduleName"]; ok {
noticeSetting.ModuleName = moduleName.(string)
}
if moduleAction, ok := data["moduleAction"]; ok {
noticeSetting.ModuleAction = moduleAction.(string)
}
if moduleActionName, ok := data["moduleActionName"]; ok {
noticeSetting.ModuleActionName = moduleActionName.(string)
}
if noticeSettingId, ok := data["noticeSettingId"]; ok {
noticeSetting.NoticeSettingId = noticeSettingId.(int64)
}
if organizationId, ok := data["orgId"]; ok {
noticeSetting.OrgId = organizationId.(int64)
}
if createdAt, ok := data["createdAt"]; ok {
noticeSetting.CreatedAt = createdAt.(time.Time)
}
if deletedAt, ok := data["deletedAt"]; ok {
noticeSetting.DeletedAt = deletedAt.(time.Time)
}
if updatedAt, ok := data["updatedAt"]; ok {
noticeSetting.UpdatedAt = updatedAt.(time.Time)
}
return nil
}