package models import ( "github.com/beego/beego/v2/client/orm" "time" ) // 买方研选网页版用户设置登录密码 type CygxUserPassword struct { UserPasswordId int `orm:"column(user_password_id);pk";comment:"主键ID"` UserId int `comment:"用户ID"` Mobile string `comment:"手机号"` RealName string `comment:"用户实际名称"` Password string `comment:"密码"` CreateTime time.Time `comment:"创建时间"` ModifyTime time.Time `comment:"修改时间"` } type SetUserPasswordReq struct { Mobile string `comment:"手机号"` VCode string `description:"验证码"` Password string `comment:"密码"` } type UpdateUserPasswordReq struct { OldPassword string `comment:"旧密码"` NewPassword string `comment:"新密码"` } // 获取数量 func GetCygxUserPasswordCountByMobile(mobile string) (count int, err error) { o := orm.NewOrm() sqlCount := ` SELECT COUNT(1) AS count FROM cygx_user_password WHERE mobile = ? ` err = o.Raw(sqlCount, mobile).QueryRow(&count) return } // 获取数量 func GetCygxUserPasswordCountByMobileAdnPss(mobile, password string) (count int, err error) { o := orm.NewOrm() sqlCount := ` SELECT COUNT(1) AS count FROM cygx_user_password WHERE mobile = ? AND password = ?` err = o.Raw(sqlCount, mobile, password).QueryRow(&count) return } // 添加 func AddCygxUserPassword(item *CygxUserPassword) (err error) { o := orm.NewOrm() _, err = o.Insert(item) return } // 根据手机号修改密码 func UpdateCygxUserPassword(mobile, password string) (err error) { o := orm.NewOrm() updateParams := make(map[string]interface{}) updateParams["Password"] = password updateParams["ModifyTime"] = time.Now() ptrStructOrTableName := "cygx_user_password" whereParam := map[string]interface{}{"mobile": mobile} qs := o.QueryTable(ptrStructOrTableName) for expr, exprV := range whereParam { qs = qs.Filter(expr, exprV) } _, err = qs.Update(updateParams) if err != nil { return } return }