eapi
This commit is contained in:
parent
e50a565e80
commit
c726d792bd
|
|
@ -8,10 +8,23 @@ import (
|
|||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
const (
|
||||
LoginTypePassword = "password"
|
||||
LoginTypeVerify = "verify"
|
||||
)
|
||||
|
||||
type StaffCode struct {
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
type StaffInfo struct {
|
||||
|
||||
type LoginReq struct {
|
||||
Type string `json:"type"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type LoginRsp struct {
|
||||
Username string `json:"username"`
|
||||
Realname string `json:"realname"`
|
||||
Phone string `json:"phone"`
|
||||
|
|
@ -48,8 +61,13 @@ func (e *StaffUser) SendCode(username, scene string) (*StaffCode, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
func (e *StaffUser) Login(username, timestamp, code string) (*StaffInfo, error) {
|
||||
reqBody := fmt.Sprintf(`{"username":"%s","timestamp":"%s","code":"%s"}`, username, timestamp, code)
|
||||
func (e *StaffUser) Login(req *LoginReq) (*LoginRsp, error) {
|
||||
|
||||
var reqBody string
|
||||
|
||||
reqBody = fmt.Sprintf(`{"username":"%s","password":"%s", timestamp":"%s","type":"%s"}`,
|
||||
req.Username, req.Password, req.Timestamp, req.Type)
|
||||
|
||||
reqUrl := e.GetBaseUrl() + "/ext/staff/user/login"
|
||||
body, err := goutil.HttpPost(reqUrl, e.GetHeader(), []byte(reqBody))
|
||||
if err != nil {
|
||||
|
|
@ -60,7 +78,7 @@ func (e *StaffUser) Login(username, timestamp, code string) (*StaffInfo, error)
|
|||
return nil, errors.New(string(body))
|
||||
}
|
||||
|
||||
r := new(StaffInfo)
|
||||
r := new(LoginRsp)
|
||||
r.Realname = g.Get("data.realname").String()
|
||||
r.Username = g.Get("data.username").String()
|
||||
r.Phone = g.Get("data.phone").String()
|
||||
|
|
|
|||
Loading…
Reference in New Issue