正在显示
9 个修改的文件
包含
91 行增加
和
29 行删除
| @@ -69,7 +69,9 @@ spec: | @@ -69,7 +69,9 @@ spec: | ||
| 69 | - name: ERROR_BASE_CODE_MULTIPLE | 69 | - name: ERROR_BASE_CODE_MULTIPLE |
| 70 | value: "1000" | 70 | value: "1000" |
| 71 | - name: ABILITY_SERVICE_HOST | 71 | - name: ABILITY_SERVICE_HOST |
| 72 | - value: "https://ability-dev.fjmaimaimai.com" | 72 | + value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" |
| 73 | + - name: MMM_OPEN_API_SERVICE_HOST | ||
| 74 | + value: "http://mmm-open-api-dev.fjmaimaimai.com" | ||
| 73 | volumes: | 75 | volumes: |
| 74 | - name: accesslogs | 76 | - name: accesslogs |
| 75 | emptyDir: {} | 77 | emptyDir: {} |
| @@ -70,6 +70,8 @@ spec: | @@ -70,6 +70,8 @@ spec: | ||
| 70 | value: "1000" | 70 | value: "1000" |
| 71 | - name: ABILITY_SERVICE_HOST | 71 | - name: ABILITY_SERVICE_HOST |
| 72 | value: "https://ability.fjmaimaimai.com" | 72 | value: "https://ability.fjmaimaimai.com" |
| 73 | + - name: MMM_OPEN_API_SERVICE_HOST | ||
| 74 | + value: "https://public-interface.fjmaimaimai.com/openapi" | ||
| 73 | volumes: | 75 | volumes: |
| 74 | - name: accesslogs | 76 | - name: accesslogs |
| 75 | emptyDir: {} | 77 | emptyDir: {} |
| @@ -69,7 +69,9 @@ spec: | @@ -69,7 +69,9 @@ spec: | ||
| 69 | - name: ERROR_BASE_CODE_MULTIPLE | 69 | - name: ERROR_BASE_CODE_MULTIPLE |
| 70 | value: "1000" | 70 | value: "1000" |
| 71 | - name: ABILITY_SERVICE_HOST | 71 | - name: ABILITY_SERVICE_HOST |
| 72 | - value: "https://ability-test.fjmaimaimai.com" | 72 | + value: "https://suplus-worth-app-gateway-test.fjmaimaimai.com" |
| 73 | + - name: MMM_OPEN_API_SERVICE_HOST | ||
| 74 | + value: "http://mmm-open-api-test.fjmaimaimai.com" | ||
| 73 | volumes: | 75 | volumes: |
| 74 | - name: accesslogs | 76 | - name: accesslogs |
| 75 | emptyDir: {} | 77 | emptyDir: {} |
| 1 | +package subscriber | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
| 6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 7 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | ||
| 8 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event" | ||
| 10 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type MmmOpenApiServiceServiceSubscriber struct { | ||
| 14 | + TransactionContext *pgTransaction.TransactionContext | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (subscriber *MmmOpenApiServiceServiceSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error { | ||
| 18 | + mmmOpenApiServiceGateway, err := factory.CreateMmmOpenApiServiceGateway(nil) | ||
| 19 | + if err != nil { | ||
| 20 | + fmt.Println(err.Error()) | ||
| 21 | + return nil | ||
| 22 | + } | ||
| 23 | + switch domainEvent.EventType() { | ||
| 24 | + case event.TASK_RELEASED_EVENT: | ||
| 25 | + taskReleasedEvent := domainEvent.(*event.TaskReleased) | ||
| 26 | + var employeeRepository domain.EmployeeRepository | ||
| 27 | + if repository, err := repository.NewEmployeeRepository(subscriber.TransactionContext); err != nil { | ||
| 28 | + fmt.Println(err.Error()) | ||
| 29 | + return nil | ||
| 30 | + } else { | ||
| 31 | + employeeRepository = repository | ||
| 32 | + } | ||
| 33 | + uids := make([]int64, 0) | ||
| 34 | + if _, employees, err := employeeRepository.Find(map[string]interface{}{"companyId": taskReleasedEvent.CompanyId}); err != nil { | ||
| 35 | + fmt.Println(err.Error()) | ||
| 36 | + return nil | ||
| 37 | + } else { | ||
| 38 | + for _, employee := range employees { | ||
| 39 | + uids = append(uids, employee.EmployeeInfo.Uid) | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + title := fmt.Sprintf("%s发布了一个任务", taskReleasedEvent.Sponsor.EmployeeName) | ||
| 43 | + content := fmt.Sprintf("%s发布了一个任务", taskReleasedEvent.Sponsor.EmployeeName) | ||
| 44 | + transData := make(map[string]interface{}) | ||
| 45 | + transData["mmmType"] = "101" | ||
| 46 | + transData["mmmTitle"] = title | ||
| 47 | + transData["mmmContent"] = content | ||
| 48 | + transData["resourceId"] = taskReleasedEvent.TaskId | ||
| 49 | + ext := make(map[string]interface{}) | ||
| 50 | + ext["transData"] = transData | ||
| 51 | + data, err := mmmOpenApiServiceGateway.PushInfo(0, uids, title, content, ext) | ||
| 52 | + if err != nil { | ||
| 53 | + fmt.Println(err.Error()) | ||
| 54 | + return nil | ||
| 55 | + } | ||
| 56 | + fmt.Println(data) | ||
| 57 | + break | ||
| 58 | + } | ||
| 59 | + return nil | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +func (subscriber *MmmOpenApiServiceServiceSubscriber) SubscribedToEventTypes() []string { | ||
| 63 | + return [] string{ | ||
| 64 | + event.TASK_RELEASED_EVENT, | ||
| 65 | + } | ||
| 66 | +} |
| @@ -5,3 +5,7 @@ import serviceGateway "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastruct | @@ -5,3 +5,7 @@ import serviceGateway "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastruct | ||
| 5 | func CreateAbilityServiceGateway(options map[string]interface{}) (serviceGateway.AbilityServiceGateway, error) { | 5 | func CreateAbilityServiceGateway(options map[string]interface{}) (serviceGateway.AbilityServiceGateway, error) { |
| 6 | return serviceGateway.NewHttplibAbilityServiceGateway(), nil | 6 | return serviceGateway.NewHttplibAbilityServiceGateway(), nil |
| 7 | } | 7 | } |
| 8 | + | ||
| 9 | +func CreateMmmOpenApiServiceGateway(options map[string]interface{}) (serviceGateway.MmmOpenApiServiceGateway, error) { | ||
| 10 | + return serviceGateway.NewHttplibMmmOpenApiServiceGateway(), nil | ||
| 11 | +} |
| @@ -252,6 +252,9 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | @@ -252,6 +252,9 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | ||
| 252 | } else { | 252 | } else { |
| 253 | releaseTaskService = value | 253 | releaseTaskService = value |
| 254 | releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) | 254 | releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) |
| 255 | + releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{ | ||
| 256 | + TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 257 | + }) | ||
| 255 | } | 258 | } |
| 256 | if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil { | 259 | if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil { |
| 257 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 260 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
pkg/constant/ge_tui.go
已删除
100644 → 0
| 1 | -package constant | ||
| 2 | - | ||
| 3 | -import "os" | ||
| 4 | - | ||
| 5 | -var GETUI_APP_ID = "WgrbaaStTk7JElrXOCgUg6" | ||
| 6 | -var GETUI_APP_KEY = "FG5lbqVrHa5rS9NVfxNP7" | ||
| 7 | -var GETUI_APP_SECRET = "FW3jMNLJrRARYKv2iqA5H5" | ||
| 8 | - | ||
| 9 | -func init() { | ||
| 10 | - if os.Getenv("GETUI_APP_KEY") != "" { | ||
| 11 | - GETUI_APP_KEY = os.Getenv("GETUI_APP_KEY") | ||
| 12 | - } | ||
| 13 | - if os.Getenv("GETUI_APP_ID") != "" { | ||
| 14 | - GETUI_APP_ID = os.Getenv("GETUI_APP_ID") | ||
| 15 | - } | ||
| 16 | - if os.Getenv("GETUI_APP_SECRET") != "" { | ||
| 17 | - GETUI_APP_SECRET = os.Getenv("GETUI_APP_SECRET") | ||
| 18 | - } | ||
| 19 | -} |
| @@ -10,15 +10,13 @@ type HttplibMmmOpenApiServiceGateway struct { | @@ -10,15 +10,13 @@ type HttplibMmmOpenApiServiceGateway struct { | ||
| 10 | httplibBaseServiceGateway | 10 | httplibBaseServiceGateway |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | -func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, clientIds []string, title string, content string, ext map[string]interface{}) (map[string]interface{}, error) { | ||
| 14 | - url := strings.Join([]string{serviceGateway.baseURL, "push", "pushInfo"}, "/") | 13 | +func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error) { |
| 14 | + url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/") | ||
| 15 | request := serviceGateway.createRequest(url, "post") | 15 | request := serviceGateway.createRequest(url, "post") |
| 16 | options := make(map[string]interface{}) | 16 | options := make(map[string]interface{}) |
| 17 | - options["mmmType"] = 1 | ||
| 18 | - options["clientId"] = clientIds | ||
| 19 | - options["appKey"] = constant.GETUI_APP_KEY | ||
| 20 | - options["secret"] = constant.GETUI_APP_SECRET | ||
| 21 | - options["appId"] = constant.GETUI_APP_ID | 17 | + options["mmmType"] = msgType |
| 18 | + options["project"] = "worth" | ||
| 19 | + options["receivers"] = uids | ||
| 22 | options["title"] = title | 20 | options["title"] = title |
| 23 | options["content"] = content | 21 | options["content"] = content |
| 24 | options["ext"] = ext | 22 | options["ext"] = ext |
| @@ -29,7 +27,7 @@ func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, cli | @@ -29,7 +27,7 @@ func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, cli | ||
| 29 | return data, err | 27 | return data, err |
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | -func NewHttplibPushServiceGateway() *HttplibMmmOpenApiServiceGateway { | 30 | +func NewHttplibMmmOpenApiServiceGateway() *HttplibMmmOpenApiServiceGateway { |
| 33 | return &HttplibMmmOpenApiServiceGateway{ | 31 | return &HttplibMmmOpenApiServiceGateway{ |
| 34 | httplibBaseServiceGateway: httplibBaseServiceGateway{ | 32 | httplibBaseServiceGateway: httplibBaseServiceGateway{ |
| 35 | baseURL: constant.MMM_OPEN_API_SERVICE_HOST, | 33 | baseURL: constant.MMM_OPEN_API_SERVICE_HOST, |
| @@ -10,3 +10,7 @@ type AbilityServiceGateway interface { | @@ -10,3 +10,7 @@ type AbilityServiceGateway interface { | ||
| 10 | SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) | 10 | SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) |
| 11 | DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) | 11 | DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) |
| 12 | } | 12 | } |
| 13 | + | ||
| 14 | +type MmmOpenApiServiceGateway interface { | ||
| 15 | + PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error) | ||
| 16 | +} |
-
请 注册 或 登录 后发表评论