正在显示
6 个修改的文件
包含
56 行增加
和
22 行删除
1 | +package subscriber | ||
2 | + | ||
3 | +import ( | ||
4 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | +) | ||
7 | + | ||
8 | +type MessageServiceSubscriber struct { | ||
9 | + TransactionContext *pgTransaction.TransactionContext | ||
10 | +} | ||
11 | + | ||
12 | +func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error { | ||
13 | + return nil | ||
14 | +} | ||
15 | + | ||
16 | +func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string { | ||
17 | + return []string{ | ||
18 | + //event.CONFERENCE_MESSAGE, // 日程预约消息通知 | ||
19 | + } | ||
20 | +} |
pkg/application/factory/dao.go
0 → 100644
1 | +package factory |
@@ -5,3 +5,7 @@ import serviceGateway "gitlab.fjmaimaimai.com/allied-creation/allied-creation-co | @@ -5,3 +5,7 @@ import serviceGateway "gitlab.fjmaimaimai.com/allied-creation/allied-creation-co | ||
5 | func CreateUserServiceGateway(options map[string]interface{}) (serviceGateway.UserServiceGateway, error) { | 5 | func CreateUserServiceGateway(options map[string]interface{}) (serviceGateway.UserServiceGateway, error) { |
6 | return serviceGateway.NewHttplibUserServiceGateway(), nil | 6 | return serviceGateway.NewHttplibUserServiceGateway(), nil |
7 | } | 7 | } |
8 | + | ||
9 | +func CreateMessageServiceGateway(options map[string]interface{}) (serviceGateway.MessageServiceGateway, error) { | ||
10 | + return serviceGateway.NewHttplibMessageServiceGateway(), nil | ||
11 | +} |
1 | package service_gateway | 1 | package service_gateway |
2 | 2 | ||
3 | +import ( | ||
4 | + "strings" | ||
5 | + "time" | ||
6 | +) | ||
7 | + | ||
3 | type HttplibMessageServiceGateway struct { | 8 | type HttplibMessageServiceGateway struct { |
4 | httplibBaseServiceGateway | 9 | httplibBaseServiceGateway |
5 | } | 10 | } |
11 | + | ||
12 | +// PushMessage 推送消息 | ||
13 | +func (serviceGateway *HttplibMessageServiceGateway) PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) { | ||
14 | + url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/") | ||
15 | + request := serviceGateway.createRequest(url, "post") | ||
16 | + options := map[string]interface{}{} | ||
17 | + _, _ = request.JSONBody(options) | ||
18 | + response := make(map[string]interface{}) | ||
19 | + _ = request.ToJSON(&response) | ||
20 | + data, err := serviceGateway.responseHandle(response) | ||
21 | + return data, err | ||
22 | +} | ||
23 | + | ||
24 | +func NewHttplibMessageServiceGateway() *HttplibMessageServiceGateway { | ||
25 | + return &HttplibMessageServiceGateway{ | ||
26 | + httplibBaseServiceGateway: httplibBaseServiceGateway{ | ||
27 | + baseURL: "", | ||
28 | + connectTimeout: 100 * time.Second, | ||
29 | + readWriteTimeout: 30 * time.Second, | ||
30 | + }, | ||
31 | + } | ||
32 | +} |
@@ -25,13 +25,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId | @@ -25,13 +25,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId | ||
25 | if err1 != nil { | 25 | if err1 != nil { |
26 | return nil, err1 | 26 | return nil, err1 |
27 | } | 27 | } |
28 | - //response := make(map[string]interface{}) | ||
29 | - //err2 := request.ToJSON(&response) | ||
30 | - //if err2 != nil { | ||
31 | - // return nil, err2 | ||
32 | - //} | ||
33 | - //data, err := serviceGateway.responseHandle(response) | ||
34 | - //return data, err | ||
35 | byteResult, err := request.Bytes() | 28 | byteResult, err := request.Bytes() |
36 | if err != nil { | 29 | if err != nil { |
37 | return nil, fmt.Errorf("获取获取用户失败:%w", err) | 30 | return nil, fmt.Errorf("获取获取用户失败:%w", err) |
@@ -84,14 +77,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (*t | @@ -84,14 +77,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (*t | ||
84 | "param": options, | 77 | "param": options, |
85 | }) | 78 | }) |
86 | } | 79 | } |
87 | - //response := make(map[string]interface{}) | ||
88 | - //err2 := request.ToJSON(&response) | ||
89 | - //if err2 != nil { | ||
90 | - // return nil, err2 | ||
91 | - //} | ||
92 | - // | ||
93 | - //data, err := serviceGateway.responseHandle(response) | ||
94 | - //return data, err | ||
95 | byteResult, err := request.Bytes() | 80 | byteResult, err := request.Bytes() |
96 | if err != nil { | 81 | if err != nil { |
97 | return nil, fmt.Errorf("获取返回企业失败:%w", err) | 82 | return nil, fmt.Errorf("获取返回企业失败:%w", err) |
@@ -139,13 +124,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64 | @@ -139,13 +124,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64 | ||
139 | if err1 != nil { | 124 | if err1 != nil { |
140 | return nil, err1 | 125 | return nil, err1 |
141 | } | 126 | } |
142 | - //response := make(map[string]interface{}) | ||
143 | - //err2 := request.ToJSON(&response) | ||
144 | - //if err2 != nil { | ||
145 | - // return nil, err2 | ||
146 | - //} | ||
147 | - //data, err := serviceGateway.responseHandle(response) | ||
148 | - //return data, err | ||
149 | byteResult, err := request.Bytes() | 127 | byteResult, err := request.Bytes() |
150 | if err != nil { | 128 | if err != nil { |
151 | return nil, fmt.Errorf("获取返回组织失败:%w", err) | 129 | return nil, fmt.Errorf("获取返回组织失败:%w", err) |
@@ -11,3 +11,7 @@ type UserServiceGateway interface { | @@ -11,3 +11,7 @@ type UserServiceGateway interface { | ||
11 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) | 11 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) |
12 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) | 12 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) |
13 | } | 13 | } |
14 | + | ||
15 | +type MessageServiceGateway interface { | ||
16 | + PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) | ||
17 | +} |
-
请 注册 或 登录 后发表评论