From 5f84186a642af3e7289b2c0e55371cf6427474ad Mon Sep 17 00:00:00 2001 From: jiangyong Date: Sun, 5 Jul 2026 14:13:57 +0800 Subject: [PATCH] change password --- erp/staff_user.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/erp/staff_user.go b/erp/staff_user.go index e9a0cb2..63fe1b6 100644 --- a/erp/staff_user.go +++ b/erp/staff_user.go @@ -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 +}