作者 陈志颖

feat:增加领域事件

package subscriber
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type MessageServiceSubscriber struct {
TransactionContext *pgTransaction.TransactionContext
}
func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error {
return nil
}
func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string {
return []string{
//event.CONFERENCE_MESSAGE, // 日程预约消息通知
}
}
... ...
package factory
... ...
... ... @@ -5,3 +5,7 @@ import serviceGateway "gitlab.fjmaimaimai.com/allied-creation/allied-creation-co
func CreateUserServiceGateway(options map[string]interface{}) (serviceGateway.UserServiceGateway, error) {
return serviceGateway.NewHttplibUserServiceGateway(), nil
}
func CreateMessageServiceGateway(options map[string]interface{}) (serviceGateway.MessageServiceGateway, error) {
return serviceGateway.NewHttplibMessageServiceGateway(), nil
}
... ...
package service_gateway
import (
"strings"
"time"
)
type HttplibMessageServiceGateway struct {
httplibBaseServiceGateway
}
// PushMessage 推送消息
func (serviceGateway *HttplibMessageServiceGateway) PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/")
request := serviceGateway.createRequest(url, "post")
options := map[string]interface{}{}
_, _ = request.JSONBody(options)
response := make(map[string]interface{})
_ = request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibMessageServiceGateway() *HttplibMessageServiceGateway {
return &HttplibMessageServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
baseURL: "",
connectTimeout: 100 * time.Second,
readWriteTimeout: 30 * time.Second,
},
}
}
... ...
... ... @@ -25,13 +25,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId
if err1 != nil {
return nil, err1
}
//response := make(map[string]interface{})
//err2 := request.ToJSON(&response)
//if err2 != nil {
// return nil, err2
//}
//data, err := serviceGateway.responseHandle(response)
//return data, err
byteResult, err := request.Bytes()
if err != nil {
return nil, fmt.Errorf("获取获取用户失败:%w", err)
... ... @@ -84,14 +77,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (*t
"param": options,
})
}
//response := make(map[string]interface{})
//err2 := request.ToJSON(&response)
//if err2 != nil {
// return nil, err2
//}
//
//data, err := serviceGateway.responseHandle(response)
//return data, err
byteResult, err := request.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回企业失败:%w", err)
... ... @@ -139,13 +124,6 @@ func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64
if err1 != nil {
return nil, err1
}
//response := make(map[string]interface{})
//err2 := request.ToJSON(&response)
//if err2 != nil {
// return nil, err2
//}
//data, err := serviceGateway.responseHandle(response)
//return data, err
byteResult, err := request.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回组织失败:%w", err)
... ...
... ... @@ -11,3 +11,7 @@ type UserServiceGateway interface {
UserInMenu(companyId int64, userId int64, menuCode string) (bool, error)
UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error)
}
type MessageServiceGateway interface {
PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error)
}
... ...