package models import ( "rdluck_tools/orm" "time" ) type LoginReq struct { Username string `description:"账号"` Password string `description:"密码"` } type LoginResp struct { Authorization string } type Admin struct { AdminId int `description:"系统用户id"` AdminName string `description:"系统用户名称"` RealName string `description:"系统用户姓名"` Password string `json:"-"` LastUpdatedPasswordTime string `json:"-"` Enabled int Email string `description:"系统用户邮箱"` LastLoginTime string CreatedTime time.Time LastUpdatedTime string Role string `description:"系统用户角色"` Mobile string `description:"手机号"` RoleType int `description:"角色类型:1需要录入指标,0:不需要"` } func CheckSysUser(userName, password string) (item *Admin, err error) { sql := `SELECT * FROM admin WHERE admin_name=? AND password=? LIMIT 1` o := orm.NewOrm() err = o.Raw(sql, userName, password).QueryRow(&item) return } func GetSysUserById(sysUserId int) (item *Admin, err error) { sql := `SELECT * FROM admin WHERE admin_id=? LIMIT 1` o := orm.NewOrm() err = o.Raw(sql, sysUserId).QueryRow(&item) return } func ModifyPwd(sysUserId int, newPwd string) (err error) { sql := `UPDATE admin SET password=?,last_updated_time=NOW() WHERE admin_id=? ` o := orm.NewOrm() _, err = o.Raw(sql, newPwd, sysUserId).Exec() return } type ModifyPwdReq struct { OldPwd string `description:"旧密码"` NewPwd string `description:"新密码"` }