Enha: bot names avoid collision
This commit is contained in:
@ -19,6 +19,7 @@ type PlayersRepo interface {
|
||||
PlayerList(ctx context.Context, isBot bool) ([]models.Player, error)
|
||||
PlayerListAll(ctx context.Context) ([]models.Player, error)
|
||||
PlayerListByRoom(ctx context.Context, roomID string) ([]models.Player, error)
|
||||
PlayerGetMaxID(ctx context.Context) (uint32, error)
|
||||
}
|
||||
|
||||
func (p *RepoProvider) PlayerListNames(ctx context.Context) ([]string, error) {
|
||||
@ -96,6 +97,15 @@ func (p *RepoProvider) PlayerList(ctx context.Context, isBot bool) ([]models.Pla
|
||||
return players, nil
|
||||
}
|
||||
|
||||
func (p *RepoProvider) PlayerGetMaxID(ctx context.Context) (uint32, error) {
|
||||
var maxID uint32
|
||||
err := sqlx.GetContext(ctx, p.DB, &maxID, "SELECT COALESCE(MAX(id), 0) FROM players")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return maxID, nil
|
||||
}
|
||||
|
||||
func (p *RepoProvider) PlayerListAll(ctx context.Context) ([]models.Player, error) {
|
||||
var players []models.Player
|
||||
query := "SELECT id, room_id, username, team, role, is_bot FROM players;"
|
||||
|
Reference in New Issue
Block a user