Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修正GroupInfo取RowsAffected逻辑错误导致部分group_player_info读取失败的问题 #1188

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions dice/model/group_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,18 @@ func GroupPlayerInfoGet(db *gorm.DB, groupID string, playerID string) *GroupPlay

// 使用 GORM 查询数据并绑定到结构体中
// db.Table("表名").Where("条件").First(&ret) 查询一条数据并映射到结构体
err := db.Model(&GroupPlayerInfoBase{}).
result := db.Model(&GroupPlayerInfoBase{}).
Where("group_id = ? AND user_id = ?", groupID, playerID).
Select("name, last_command_time, auto_set_name_template, dice_side_num").
Scan(&ret).Error

First(&ret)
err := result.Error
// 如果查询发生错误,打印错误并返回 nil
if err != nil {
log.Errorf("error getting group player info: %s", err.Error())
return nil
}

// 如果查询到的数据为空,返回 nil
if db.RowsAffected == 0 {
if result.RowsAffected == 0 {
return nil
}

Expand Down
Loading