httplib_user_service_gateway.go
1.9 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
package service_gateway
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
"strings"
"time"
)
type HttplibUserServiceGateway struct {
httplibBaseServiceGateway
}
func (serviceGateway *HttplibUserServiceGateway) GetUser(uid int64) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, ""}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["uid"] = uid
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, ""}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["companyId"] = companyId
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func (serviceGateway *HttplibUserServiceGateway) GetOrganization(organizationId int64) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, ""}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["orgId"] = organizationId
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibUserServiceGateway() *HttplibUserServiceGateway {
return &HttplibUserServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
baseURL: constant.USER_MODULE_HOST,
connectTimeout: 100 * time.Second,
readWriteTimeout: 30 * time.Second,
},
}
}