You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

4 years ago
package user
import (
"github.com/gin-gonic/gin"
"recook/internal/cache"
"recook/internal/dbc"
"recook/internal/v2/lib/back"
"recook/internal/v2/lib/common"
"recook/internal/v2/model/recook/user"
"recook/tools"
)
type Operate struct {
}
type DestroyWithCodeReq struct {
UserId uint `json:"user_id"`
Code string `json:"code"`
}
func (o *Operate) DestroyWithCode(c *gin.Context) {
id, err := common.GetAppUserId(c)
var p DestroyWithCodeReq
err = tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return
}
if p.UserId <= 0 {
back.Fail(c, "参数有误!")
return
}
if cache.GetUserDestroySMSCode(id) != p.Code {
back.Fail(c, "验证码不正确")
return
}
var userInfo user.RecookUserInfoModel
dbc.DB.First(&userInfo, p.UserId)
if err = dbc.DB.Model(&userInfo).Updates(user.RecookUserInfoModel{
Phone: "2" + userInfo.Phone,
Mobile: "2" + userInfo.Mobile,
WxUnionID: "--",
}).Error; err != nil {
back.Fail(c, "更新失败:"+err.Error())
return
}
back.Suc(c, "操作成功", nil)
4 years ago
}