fix(base): 修复QQ绑定功能中用户名查询条件错误 在BindQQ方法中,将数据库查询条件从"id"字段更正为"username"字段, 确保能够正确根据用户名查找和更新用户信息。 ```
This commit is contained in:
@@ -84,7 +84,7 @@ func (s *BaseSysUserService) BindQQ(username string, passworid string, qq int64)
|
||||
return
|
||||
}
|
||||
var res1 *model.BaseSysUser
|
||||
cool.DBM(s.Model).Where("id", username).Scan(&res1)
|
||||
cool.DBM(s.Model).Where("username", username).Scan(&res1)
|
||||
if res1 == nil {
|
||||
return gerror.New("用户未激活")
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (s *BaseSysUserService) BindQQ(username string, passworid string, qq int64)
|
||||
err = gerror.New("用户不存在")
|
||||
return
|
||||
}
|
||||
_, err = cool.DBM(s.Model).Where("id", username).Data("qq", qq).Update()
|
||||
_, err = cool.DBM(s.Model).Where("username", username).Data("qq", qq).Update()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
26
modules/player/controller/robot/bindqq.go
Normal file
26
modules/player/controller/robot/bindqq.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"blazing/modules/base/service"
|
||||
"strings"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
)
|
||||
|
||||
func init() {
|
||||
zero.OnCommand("绑定").
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msgs := strings.Fields(ctx.Event.Message.String())
|
||||
if len(msgs) > 2 {
|
||||
|
||||
err := service.NewBaseSysUserService().BindQQ(msgs[1], msgs[2], ctx.Event.Sender.ID)
|
||||
if err != nil {
|
||||
ctx.Send(err.Error())
|
||||
} else {
|
||||
ctx.Send("绑定成功")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user