http_partner01_service_gateway.go
2.3 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package gateway
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/tiptok/gocomm/gs"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01-gateway/pkg/constant"
"net/http"
)
const (
AuthsLogin = "AuthsLogin"
AuthsLoginByCompany = "loginByCompany"
AuthsAccessToken = "AuthsAccessToken"
AuthsRefreshToken = "AuthsRefreshToken"
AuthsSendSmsCode = "AuthsSendSmsCode"
AuthsRevoke = "AuthsRevoke"
AuthsChangePhonePassword = "AuthsChangePhonePassword"
)
const (
CompanyGet = "CompanyGet"
CompanyCreate = "CompanyCreate"
CompanyRemove = "CompanyRemove"
CompanyList = "CompanyList"
CompanyUpdate = "CompanyUpdate"
)
var Partner01Service *HttpPartner01ServiceGateway
func init() {
Partner01Service = &HttpPartner01ServiceGateway{gs.NewManagerService(constant.PARTER01_GATEWAY_ADDRESS, Routers())}
Partner01Service.WithDebugModel(true)
}
type HttpPartner01ServiceGateway struct {
*gs.GatewayService
}
func Routers() []gs.Router {
routers := []gs.Router{
{AuthsLogin, "/auths/login", http.MethodPost},
{AuthsLoginByCompany, "/auths/loginByCompany", http.MethodPost},
{AuthsAccessToken, "/auths/accessToken", http.MethodPost},
{AuthsRefreshToken, "/auths/refreshToken", http.MethodPost},
{AuthsSendSmsCode, "/auths/sendSmsCode", http.MethodPost},
{AuthsRevoke, "/auths/revoke", http.MethodPost},
{AuthsChangePhonePassword, "/auths/changePhonePassword", http.MethodPost},
{CompanyGet, "/companies/:companyId", http.MethodGet},
{CompanyRemove, "/companies/:companyId", http.MethodDelete},
{CompanyUpdate, "/companies/:companyId", http.MethodPut},
{CompanyCreate, "/companies/", http.MethodPost},
{CompanyList, "/companies/", http.MethodGet},
}
return routers
}
func (service *HttpPartner01ServiceGateway) CompanyCreate(jsonObject interface{}) (interface{}, error) {
data, err := service.Invoke(CompanyCreate, gs.WithJsonObject(jsonObject))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return data.Data, nil
}
func (service *HttpPartner01ServiceGateway) CompanyGet(pathParam interface{}) (interface{}, error) {
data, err := service.Invoke(CompanyGet, gs.WithPathParam(pathParam))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return data.Data, nil
}