MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / InsertOrUpdateScoreByUID

Method InsertOrUpdateScoreByUID

plugin/score/model.go:80–100  ·  view source on GitHub ↗

InsertOrUpdateScoreByUID 插入或更新分数

(uid int64, score int)

Source from the content-addressed store, hash-verified

78
79// InsertOrUpdateScoreByUID 插入或更新分数
80func (sdb *scoredb) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
81 sdb.scoremu.Lock()
82 defer sdb.scoremu.Unlock()
83 db := sdb.db
84 s := scoretable{
85 UID: uid,
86 Score: score,
87 }
88 if err = db.Model(&scoretable{}).First(&s, "uid = ? ", uid).Error; err != nil {
89 // error handling...
90 if gorm.IsRecordNotFoundError(err) {
91 err = db.Model(&scoretable{}).Create(&s).Error // newUser not user
92 }
93 } else {
94 err = db.Model(&scoretable{}).Where("uid = ? ", uid).Update(
95 map[string]any{
96 "score": score,
97 }).Error
98 }
99 return
100}
101
102// GetSignInByUID 取得签到次数
103func (sdb *scoredb) GetSignInByUID(uid int64) (si signintable) {

Callers 1

initFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected