...
|
...
|
@@ -12,6 +12,10 @@ import ( |
|
|
"time"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
ResponseOk int = 0
|
|
|
)
|
|
|
|
|
|
//请求企业平台的接口
|
|
|
type IBusinessAdminParam interface {
|
|
|
Format() []byte
|
...
|
...
|
@@ -72,7 +76,9 @@ type CommResponse struct { |
|
|
}
|
|
|
|
|
|
func (resp CommResponse) IsOK() bool {
|
|
|
|
|
|
if resp.Code != ResponseOk {
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
|
...
|
...
|
@@ -120,3 +126,50 @@ func GetuserAuthDo(userid int64) (ResponseGetUserAuth, error) { |
|
|
}
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
//RequestGetUserCompany 从企业平台获取用户的公司
|
|
|
type RequestGetUserCompany struct {
|
|
|
Phone string `json:"phone"`
|
|
|
platformId string `json:"platformId"`
|
|
|
}
|
|
|
|
|
|
type ResponseGetUserCompany struct {
|
|
|
CommResponse
|
|
|
Data struct {
|
|
|
Company []struct {
|
|
|
Id int64 `json:"id"`
|
|
|
Name string `json:"name"`
|
|
|
Logo string `json:"logo"`
|
|
|
} `json:"company"`
|
|
|
} `json:"data"`
|
|
|
}
|
|
|
|
|
|
func (r RequestGetUserCompany) Format() []byte {
|
|
|
r.platformId = "18"
|
|
|
var bt []byte
|
|
|
bt, _ = json.Marshal(r)
|
|
|
return bt
|
|
|
}
|
|
|
|
|
|
func (r RequestGetUserCompany) GetPath() (string, string) {
|
|
|
return "/companies/user-company", "POST"
|
|
|
}
|
|
|
|
|
|
func GetUserCompanyDo(phone string) (ResponseGetUserCompany, error) {
|
|
|
param := RequestGetUserCompany{
|
|
|
Phone: phone,
|
|
|
}
|
|
|
var resp ResponseGetUserCompany
|
|
|
uclient := NewBusinessAdminClient()
|
|
|
btBody, err := uclient.Call(param)
|
|
|
if err != nil {
|
|
|
log.Error("向企业平台发送请求失败 err:%s", err)
|
|
|
return resp, errors.New("向企业平台发送请求失败")
|
|
|
}
|
|
|
err = json.Unmarshal(btBody, &resp)
|
|
|
if err != nil {
|
|
|
log.Error("解析企业平台响应失败 err:%s", err)
|
|
|
return resp, errors.New("解析企业平台响应失败")
|
|
|
}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|