my.go
1020 字节
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
package controllers
import (
"encoding/json"
"oppmg/common/log"
"oppmg/protocol"
"oppmg/services/usermy"
)
// MyController 个人中心
type MyController struct {
BaseController
}
//ResetPassword 重置密码
//@router /my/reset_password
func (c *MyController) ResetPassword() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Parameter struct {
Phone string `json:"phone"`
NewPwd string `json:"newpwd"`
ConfirmPwd string `json:"confirmpwd"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
companyid := c.GetCompanyId()
userId := c.GetUserId()
if companyid <= 0 {
msg = protocol.BadRequestParam("1")
return
}
if userId <= 0 {
msg = protocol.BadRequestParam("1")
return
}
err := usermy.ResetPasswordBySms(param.Phone, param.NewPwd, param.ConfirmPwd)
msg = protocol.NewReturnResponse(nil, err)
return
}