正在显示
10 个修改的文件
包含
2 行增加
和
374 行删除
@@ -6,17 +6,9 @@ const SERVICE_NAME = "partner" | @@ -6,17 +6,9 @@ const SERVICE_NAME = "partner" | ||
6 | 6 | ||
7 | var LOG_LEVEL = "debug" | 7 | var LOG_LEVEL = "debug" |
8 | var LOG_File = "app.log" | 8 | var LOG_File = "app.log" |
9 | -var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | ||
10 | -var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" | ||
11 | 9 | ||
12 | func init() { | 10 | func init() { |
13 | if os.Getenv("LOG_LEVEL") != "" { | 11 | if os.Getenv("LOG_LEVEL") != "" { |
14 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 12 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
15 | } | 13 | } |
16 | - if os.Getenv("ABILITY_SERVICE_HOST") != "" { | ||
17 | - ABILITY_SERVICE_HOST = os.Getenv("ABILITY_SERVICE_HOST") | ||
18 | - } | ||
19 | - if os.Getenv("MMM_OPEN_API_SERVICE_HOST") != "" { | ||
20 | - MMM_OPEN_API_SERVICE_HOST = os.Getenv("MMM_OPEN_API_SERVICE_HOST") | ||
21 | - } | ||
22 | } | 14 | } |
@@ -17,7 +17,7 @@ type AdminUser struct { | @@ -17,7 +17,7 @@ type AdminUser struct { | ||
17 | //创建时间 | 17 | //创建时间 |
18 | CreateAt string `json:"create_at"` | 18 | CreateAt string `json:"create_at"` |
19 | //用户权限 | 19 | //用户权限 |
20 | - Permission []string `json:"permission"` | 20 | + Permission []AdminPermission `json:"permission"` |
21 | } | 21 | } |
22 | 22 | ||
23 | type AdminUserFindQuery struct { | 23 | type AdminUserFindQuery struct { |
pkg/domain/event/taskRobed.go
已删除
100644 → 0
1 | -package event | ||
2 | - | ||
3 | -//import ( | ||
4 | -// coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
5 | -// "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | ||
6 | -//) | ||
7 | -// | ||
8 | -//const TASK_ROBED_EVENT = "task-robed-event" | ||
9 | -// | ||
10 | -//type TaskRobed struct { | ||
11 | -// coreDomain.BaseEvent | ||
12 | -// // 任务ID | ||
13 | -// TaskId int64 `json:"taskId"` | ||
14 | -// // 公司ID | ||
15 | -// CompanyId int64 `json:"companyId"` | ||
16 | -// // 任务名称 | ||
17 | -// TaskName string `json:"taskName"` | ||
18 | -// // 任务类型Type | ||
19 | -// TaskType int `json:"taskType"` | ||
20 | -// // 任务发起者 | ||
21 | -// Sponsor *domain.EmployeeInfo `json:"sponsor"` | ||
22 | -// // 任务状态 | ||
23 | -// TaskStatus int `json:"taskStatus"` | ||
24 | -// // 引用资源 | ||
25 | -// ReferenceResource *domain.ReferenceResource `json:"referenceResource"` | ||
26 | -// // 抢单任务信息 | ||
27 | -// RobInfo *domain.RobInfo `json:"robInfo"` | ||
28 | -//} | ||
29 | -// | ||
30 | -//func (event *TaskRobed) EventType() string { | ||
31 | -// return TASK_ROBED_EVENT | ||
32 | -//} |
pkg/domain/service/rob_task.go
已删除
100644 → 0
1 | -package service | ||
2 | - | ||
3 | -//import ( | ||
4 | -// coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
5 | -// "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | ||
6 | -//) | ||
7 | -// | ||
8 | -//type RobTaskService interface { | ||
9 | -// coreDomain.DomainEventPublisher | ||
10 | -// Rob(taskId int64, receiverUid int64) (*domain.Task, error) | ||
11 | -//} |
1 | -package domain_service | ||
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/domain" | ||
8 | -// "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event" | ||
9 | -// "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
10 | -// "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" | ||
11 | -// "time" | ||
12 | -//) | ||
13 | -// | ||
14 | -//type RobTaskService struct { | ||
15 | -// coreDomain.BaseEventPublisher | ||
16 | -// transactionContext *pgTransaction.TransactionContext | ||
17 | -//} | ||
18 | -// | ||
19 | -//func (service *RobTaskService) Rob(taskId int64, receiverUid int64) (*domain.Task, error) { | ||
20 | -// var employeeRepository domain.EmployeeRepository | ||
21 | -// var taskRepository domain.TaskRepository | ||
22 | -// var taskDao *dao.TaskDao | ||
23 | -// if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { | ||
24 | -// return nil, err | ||
25 | -// } else { | ||
26 | -// employeeRepository = repository | ||
27 | -// } | ||
28 | -// if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil { | ||
29 | -// return nil, err | ||
30 | -// } else { | ||
31 | -// taskRepository = repository | ||
32 | -// } | ||
33 | -// if dao, err := dao.NewTaskDao(service.transactionContext); err != nil { | ||
34 | -// return nil, err | ||
35 | -// } else { | ||
36 | -// taskDao = dao | ||
37 | -// } | ||
38 | -// receiver, err := employeeRepository.FindOne(map[string]interface{}{ | ||
39 | -// "uid": receiverUid, | ||
40 | -// }) | ||
41 | -// if err != nil { | ||
42 | -// return nil, err | ||
43 | -// } | ||
44 | -// if receiver == nil { | ||
45 | -// return nil, fmt.Errorf("无效的领取人") | ||
46 | -// } | ||
47 | -// task, err := taskRepository.FindOne(map[string]interface{}{ | ||
48 | -// "taskId": taskId, | ||
49 | -// }) | ||
50 | -// if err != nil { | ||
51 | -// return nil, err | ||
52 | -// } | ||
53 | -// if task == nil { | ||
54 | -// return nil, fmt.Errorf("无效的任务") | ||
55 | -// } | ||
56 | -// if receiver.EmployeeInfo.Uid == task.Sponsor.Uid { | ||
57 | -// return nil, fmt.Errorf("无法领取自己发布的任务") | ||
58 | -// } | ||
59 | -// if task.RobInfo != nil && task.RobInfo.Receiver != nil { | ||
60 | -// return nil, fmt.Errorf("任务已经被人领取") | ||
61 | -// } | ||
62 | -// if err := task.Rob(receiver.EmployeeInfo); err != nil { | ||
63 | -// return nil, err | ||
64 | -// } | ||
65 | -// if err := taskDao.AddRobInfo(taskId, receiver.EmployeeInfo); err != nil { | ||
66 | -// return nil, fmt.Errorf("抢单失败,任务可能已经被人领取") | ||
67 | -// } | ||
68 | -// if task, err := taskRepository.Save(task); err != nil { | ||
69 | -// return nil, err | ||
70 | -// } else { | ||
71 | -// taskRobedEvent := new(event.TaskRobed) | ||
72 | -// taskRobedEvent.OccurredOn = time.Now() | ||
73 | -// taskRobedEvent.TaskId = task.TaskId | ||
74 | -// taskRobedEvent.CompanyId = task.CompanyId | ||
75 | -// taskRobedEvent.TaskName = task.TaskName | ||
76 | -// taskRobedEvent.TaskType = task.TaskType | ||
77 | -// taskRobedEvent.Sponsor = task.Sponsor | ||
78 | -// taskRobedEvent.TaskStatus = task.TaskStatus | ||
79 | -// taskRobedEvent.ReferenceResource = task.ReferenceResource | ||
80 | -// taskRobedEvent.RobInfo = task.RobInfo | ||
81 | -// if err := service.Publish(taskRobedEvent); err != nil { | ||
82 | -// return nil, err | ||
83 | -// } | ||
84 | -// return task, nil | ||
85 | -// } | ||
86 | -//} | ||
87 | -// | ||
88 | -//func NewRobTaskService(transactionContext *pgTransaction.TransactionContext) (*RobTaskService, error) { | ||
89 | -// if transactionContext == nil { | ||
90 | -// return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
91 | -// } else { | ||
92 | -// return &RobTaskService{ | ||
93 | -// transactionContext: transactionContext, | ||
94 | -// }, nil | ||
95 | -// } | ||
96 | -//} |
1 | -package service_gateway | ||
2 | - | ||
3 | -import ( | ||
4 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
5 | - "strings" | ||
6 | - "time" | ||
7 | -) | ||
8 | - | ||
9 | -type HttplibAbilityServiceGateway struct { | ||
10 | - httplibBaseServiceGateway | ||
11 | -} | ||
12 | - | ||
13 | -func (serviceGateway *HttplibAbilityServiceGateway) CommitQuestionQuotes(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) { | ||
14 | - url := strings.Join([]string{serviceGateway.baseURL, "task/commitQuestionQuotes"}, "/") | ||
15 | - request := serviceGateway.createRequest(url, "post") | ||
16 | - options := make(map[string]interface{}) | ||
17 | - options["uid"] = uid | ||
18 | - options["taskId"] = taskId | ||
19 | - options["serials"] = serials | ||
20 | - request.JSONBody(options) | ||
21 | - response := make(map[string]interface{}) | ||
22 | - request.ToJSON(&response) | ||
23 | - data, err := serviceGateway.responseHandle(response) | ||
24 | - return data, err | ||
25 | -} | ||
26 | - | ||
27 | -func (serviceGateway *HttplibAbilityServiceGateway) CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error) { | ||
28 | - url := strings.Join([]string{serviceGateway.baseURL, "task/commitQuestionSolution"}, "/") | ||
29 | - request := serviceGateway.createRequest(url, "post") | ||
30 | - options := make(map[string]interface{}) | ||
31 | - options["qid"] = qid | ||
32 | - options["uid"] = uid | ||
33 | - options["solveUid"] = solveUid | ||
34 | - options["content"] = content | ||
35 | - options["scoreSolve"] = scoreSolve | ||
36 | - options["imgs"] = imgs | ||
37 | - options["partners"] = partners | ||
38 | - request.JSONBody(options) | ||
39 | - response := make(map[string]interface{}) | ||
40 | - request.ToJSON(&response) | ||
41 | - data, err := serviceGateway.responseHandle(response) | ||
42 | - return data, err | ||
43 | -} | ||
44 | - | ||
45 | -func (serviceGateway *HttplibAbilityServiceGateway) CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error) { | ||
46 | - url := strings.Join([]string{serviceGateway.baseURL, "task/closeTaskCallback"}, "/") | ||
47 | - request := serviceGateway.createRequest(url, "post") | ||
48 | - options := make(map[string]interface{}) | ||
49 | - options["taskId"] = taskId | ||
50 | - options["referenceResourceIds"] = referenceResourceIds | ||
51 | - request.JSONBody(options) | ||
52 | - response := make(map[string]interface{}) | ||
53 | - request.ToJSON(&response) | ||
54 | - data, err := serviceGateway.responseHandle(response) | ||
55 | - return data, err | ||
56 | -} | ||
57 | - | ||
58 | -func (serviceGateway *HttplibAbilityServiceGateway) ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (map[string]interface{}, error) { | ||
59 | - url := strings.Join([]string{serviceGateway.baseURL, "task/receiverTaskCallback"}, "/") | ||
60 | - request := serviceGateway.createRequest(url, "post") | ||
61 | - options := make(map[string]interface{}) | ||
62 | - options["uid"] = uid | ||
63 | - options["taskId"] = taskId | ||
64 | - options["referenceResourceIds"] = referenceResourceIds | ||
65 | - options["operator_id"] = operatorId | ||
66 | - options["operator_time"] = operatorTime | ||
67 | - request.JSONBody(options) | ||
68 | - response := make(map[string]interface{}) | ||
69 | - request.ToJSON(&response) | ||
70 | - data, err := serviceGateway.responseHandle(response) | ||
71 | - return data, err | ||
72 | -} | ||
73 | - | ||
74 | -func (serviceGateway *HttplibAbilityServiceGateway) SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) { | ||
75 | - url := strings.Join([]string{serviceGateway.baseURL, "task/saveTaskCallback"}, "/") | ||
76 | - request := serviceGateway.createRequest(url, "post") | ||
77 | - options := make(map[string]interface{}) | ||
78 | - options["uid"] = uid | ||
79 | - options["taskId"] = taskId | ||
80 | - options["serials"] = serials | ||
81 | - request.JSONBody(options) | ||
82 | - response := make(map[string]interface{}) | ||
83 | - request.ToJSON(&response) | ||
84 | - data, err := serviceGateway.responseHandle(response) | ||
85 | - return data, err | ||
86 | -} | ||
87 | - | ||
88 | -func (serviceGateway *HttplibAbilityServiceGateway) DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) { | ||
89 | - url := strings.Join([]string{serviceGateway.baseURL, "task/deleteTaskCallback"}, "/") | ||
90 | - request := serviceGateway.createRequest(url, "post") | ||
91 | - options := make(map[string]interface{}) | ||
92 | - options["uid"] = uid | ||
93 | - options["taskId"] = taskId | ||
94 | - options["serials"] = serials | ||
95 | - request.JSONBody(options) | ||
96 | - response := make(map[string]interface{}) | ||
97 | - request.ToJSON(&response) | ||
98 | - data, err := serviceGateway.responseHandle(response) | ||
99 | - return data, err | ||
100 | -} | ||
101 | - | ||
102 | -func NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway { | ||
103 | - return &HttplibAbilityServiceGateway{ | ||
104 | - httplibBaseServiceGateway: httplibBaseServiceGateway{ | ||
105 | - baseURL: constant.ABILITY_SERVICE_HOST, | ||
106 | - connectTimeout: 100 * time.Second, | ||
107 | - readWriteTimeout: 30 * time.Second, | ||
108 | - }, | ||
109 | - } | ||
110 | -} |
1 | -package service_gateway | ||
2 | - | ||
3 | -import ( | ||
4 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
5 | - "strings" | ||
6 | - "time" | ||
7 | -) | ||
8 | - | ||
9 | -type HttplibMmmOpenApiServiceGateway struct { | ||
10 | - httplibBaseServiceGateway | ||
11 | -} | ||
12 | - | ||
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") | ||
16 | - options := make(map[string]interface{}) | ||
17 | - options["mmmType"] = msgType | ||
18 | - options["project"] = "worth" | ||
19 | - options["receivers"] = uids | ||
20 | - options["title"] = title | ||
21 | - options["content"] = content | ||
22 | - options["ext"] = ext | ||
23 | - request.JSONBody(options) | ||
24 | - response := make(map[string]interface{}) | ||
25 | - request.ToJSON(&response) | ||
26 | - data, err := serviceGateway.responseHandle(response) | ||
27 | - return data, err | ||
28 | -} | ||
29 | - | ||
30 | -func NewHttplibMmmOpenApiServiceGateway() *HttplibMmmOpenApiServiceGateway { | ||
31 | - return &HttplibMmmOpenApiServiceGateway{ | ||
32 | - httplibBaseServiceGateway: httplibBaseServiceGateway{ | ||
33 | - baseURL: constant.MMM_OPEN_API_SERVICE_HOST, | ||
34 | - connectTimeout: 100 * time.Second, | ||
35 | - readWriteTimeout: 30 * time.Second, | ||
36 | - }, | ||
37 | - } | ||
38 | -} |
1 | -package service_gateway | ||
2 | - | ||
3 | -import ( | ||
4 | - "encoding/json" | ||
5 | - "fmt" | ||
6 | - "github.com/astaxie/beego/httplib" | ||
7 | - "strconv" | ||
8 | - "strings" | ||
9 | - "time" | ||
10 | -) | ||
11 | - | ||
12 | -type httplibBaseServiceGateway struct { | ||
13 | - baseURL string | ||
14 | - connectTimeout time.Duration | ||
15 | - readWriteTimeout time.Duration | ||
16 | -} | ||
17 | - | ||
18 | -func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, method string) *httplib.BeegoHTTPRequest { | ||
19 | - var request *httplib.BeegoHTTPRequest | ||
20 | - switch method { | ||
21 | - case "get": | ||
22 | - request = httplib.Get(url) | ||
23 | - break | ||
24 | - case "post": | ||
25 | - request = httplib.Post(url) | ||
26 | - break | ||
27 | - case "put": | ||
28 | - request = httplib.Put(url) | ||
29 | - break | ||
30 | - case "delete": | ||
31 | - request = httplib.Delete(url) | ||
32 | - break | ||
33 | - case "head": | ||
34 | - request = httplib.Head(url) | ||
35 | - break | ||
36 | - default: | ||
37 | - request = httplib.Get(url) | ||
38 | - } | ||
39 | - return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout) | ||
40 | -} | ||
41 | - | ||
42 | -func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[string]interface{}) (map[string]interface{}, error) { | ||
43 | - data := make(map[string]interface{}) | ||
44 | - var err error | ||
45 | - if code, ok := response["code"]; ok { | ||
46 | - code := code.(float64) | ||
47 | - if code == 0 { | ||
48 | - data = response["data"].(map[string]interface{}) | ||
49 | - } else { | ||
50 | - msg := response["msg"].(string) | ||
51 | - err = fmt.Errorf(strings.Join([]string{strconv.FormatFloat(code, 'f', -1, 64), msg}, " ")) | ||
52 | - } | ||
53 | - } else { | ||
54 | - jsonBytes, marshalErr := json.Marshal(response) | ||
55 | - if marshalErr != nil { | ||
56 | - err = marshalErr | ||
57 | - } | ||
58 | - err = fmt.Errorf("无法解析的网关服务数据返回格式:%s", string(jsonBytes)) | ||
59 | - } | ||
60 | - return data, err | ||
61 | -} |
1 | -package service_gateway | ||
2 | - | ||
3 | -import "time" | ||
4 | - | ||
5 | -type AbilityServiceGateway interface { | ||
6 | - CommitQuestionQuotes(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) | ||
7 | - CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error) | ||
8 | - CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error) | ||
9 | - ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (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) | ||
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 | -} |
-
请 注册 或 登录 后发表评论