notice_setting.go
5.2 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package service
import (
"strconv"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/noticesetting/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/noticesetting/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
)
// 推送消息配置
type NoticeSettingService struct {
}
//NoticeSettingList 推送消息配置列表
func (noticeSettingService *NoticeSettingService) NoticeSettingList(noticeSettingListQuery *query.NoticeSettingListQuery) (int64, interface{}, error) {
if err := noticeSettingListQuery.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingListQuery.Operator,
)
result, err := creationBasicGateway.NoticeSettingSearch(allied_creation_basic.ReqNoticeSettingSearch{
PageIndex: noticeSettingListQuery.PageNumber,
PageSize: noticeSettingListQuery.PageSize,
CompanyId: noticeSettingListQuery.Operator.CompanyId,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result.Count, result.NoticeSettings, nil
}
//NoticeSettingProfile 推送消息配置需求的参数候选项
func (noticeSettingService *NoticeSettingService) NoticeSettingProfile(noticeSettingProfileQuery *query.NoticeSettingProfileQuery) (interface{}, error) {
if err := noticeSettingProfileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingProfileQuery.Operator,
)
result, err := creationBasicGateway.NoticeSettingProfile(allied_creation_basic.ReqNoticeSettingProfile{})
return result, err
}
// NoticeSettingUpdate 更新配置
func (noticeSettingService *NoticeSettingService) NoticeSettingUpdate(noticeSettingUpdateCommand *command.NoticeSettingUpdateCommand) (interface{}, error) {
if err := noticeSettingUpdateCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingUpdateCommand.Operator,
)
noticeSettingID, _ := strconv.Atoi(noticeSettingUpdateCommand.NoticeSettingId)
_, err := creationBasicGateway.NoticeSettingUpdate(allied_creation_basic.ReqNoticeSettingUpdate{
NoticeSettingID: noticeSettingID,
CompanyID: int(noticeSettingUpdateCommand.Operator.CompanyId),
Content: noticeSettingUpdateCommand.Content,
IsPush: noticeSettingUpdateCommand.IsPush,
Module: noticeSettingUpdateCommand.Module,
ModuleAction: noticeSettingUpdateCommand.ModuleAction,
OrganizationID: int(noticeSettingUpdateCommand.Operator.OrgId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return noticeSettingUpdateCommand, nil
}
// NoticeSettingUpdate 添加配置
func (noticeSettingService *NoticeSettingService) NoticeSettingAdd(noticeSettingAddCommand *command.NoticeSettingAddCommand) (interface{}, error) {
if err := noticeSettingAddCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingAddCommand.Operator,
)
result, err := creationBasicGateway.NoticeSettingAdd(allied_creation_basic.ReqNoticeSettingAdd{
CompanyID: int(noticeSettingAddCommand.Operator.CompanyId),
Content: noticeSettingAddCommand.Content,
IsPush: noticeSettingAddCommand.IsPush,
Module: noticeSettingAddCommand.Module,
ModuleAction: noticeSettingAddCommand.ModuleAction,
OrganizationID: int(noticeSettingAddCommand.Operator.OrgId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
data := struct {
NoticeSettingId int `json:"noticeSettingId"`
command.NoticeSettingAddCommand
}{
NoticeSettingId: result.NoticeSettingID,
NoticeSettingAddCommand: *noticeSettingAddCommand,
}
return data, nil
}
// NoticeSettingGet 获取配置
func (noticeSettingService *NoticeSettingService) NoticeSettingGet(noticeSettingGetQuery *query.NoticeSettingGetQuery) (interface{}, error) {
if err := noticeSettingGetQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingGetQuery.Operator,
)
noticeSettingID, _ := strconv.Atoi(noticeSettingGetQuery.NoticeSettingId)
result, err := creationBasicGateway.NoticeSettingGet(allied_creation_basic.ReqNoticeSettingGet{
NoticeSettingID: noticeSettingID,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService {
newNoticeSettingService := &NoticeSettingService{}
return newNoticeSettingService
}