laniakea v1.0.0 rc1
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
ID int64
|
||||
Balance decimal.Decimal
|
||||
Name string
|
||||
GroupID int `db:"group_id"`
|
||||
@@ -60,7 +60,7 @@ func NewUserRepository(db *database.Context) UserRepository {
|
||||
return newUserRepository(db.Postgres)
|
||||
}
|
||||
|
||||
func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {
|
||||
func (rep UserRepository) GetOrCreate(tgId int64, name string) (*User, error) {
|
||||
user, err := rep.GetById(tgId)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
user, err = rep.Create(tgId, name)
|
||||
@@ -68,13 +68,13 @@ func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (rep UserRepository) Create(id int, name string) (*User, error) {
|
||||
func (rep UserRepository) Create(id int64, name string) (*User, error) {
|
||||
user := new(User)
|
||||
err := rep.db.Get(user, "INSERT INTO users (id, name) VALUES ($1, $2) RETURNING *;", id, name)
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (rep UserRepository) GetById(telegramId int) (*User, error) {
|
||||
func (rep UserRepository) GetById(telegramId int64) (*User, error) {
|
||||
user := new(User)
|
||||
err := rep.db.Get(user, "SELECT * FROM users WHERE id=$1;", telegramId)
|
||||
if err != nil {
|
||||
@@ -125,7 +125,7 @@ func (rep UserRepository) GetJoins(user *User) (*User, error) {
|
||||
user.Miner = &miner
|
||||
}
|
||||
if user.PairID.Valid {
|
||||
pair, err := rep.GetById(int(user.PairID.Int64))
|
||||
pair, err := rep.GetById(user.PairID.Int64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user