change password

This commit is contained in:
jiangyong 2026-07-05 14:13:57 +08:00
parent 8bb537ff6a
commit 5f84186a64
1 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,13 @@ type LoginRsp struct {
Realname string `json:"realname"`
Phone string `json:"phone"`
}
type ChangePasswordReq struct {
Username string `json:"username"`
OldPassword string `json:"old_password"`
NewPassword string `json:"new_password"`
}
type StaffUser struct {
Erp
}
@ -85,3 +92,21 @@ func (e *StaffUser) Login(req *LoginReq) (*LoginRsp, error) {
return r, nil
}
func (e *StaffUser) ChangePassword(req *ChangePasswordReq) error {
var reqBody string
reqBody = goutil.EncodeJSON(req)
reqUrl := e.GetBaseUrl() + "/ext/staff/user/password"
body, err := goutil.HttpPost(reqUrl, e.GetHeader(), []byte(reqBody))
if err != nil {
return err
}
g := gjson.ParseBytes(body)
if g.Get("code").Int() != 0 {
return errors.New(string(body))
}
return nil
}