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
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Waifu struct {
|
||||
ID int
|
||||
ID int64
|
||||
OwnerID sql.NullInt64 `db:"owner_id"`
|
||||
Name string
|
||||
Rarity int
|
||||
@@ -51,7 +51,7 @@ func (rep *WaifuRepository) GetAll() ([]*Waifu, error) {
|
||||
return waifus, err
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetByUserId(userId int) ([]*Waifu, error) {
|
||||
func (rep *WaifuRepository) GetByUserId(userId int64) ([]*Waifu, error) {
|
||||
waifus, err := sqlx.List[*Waifu](rep.db, "SELECT waifus.* FROM waifus WHERE owner_id=$1;", userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -69,7 +69,7 @@ func (rep *WaifuRepository) GetByUserId(userId int) ([]*Waifu, error) {
|
||||
return waifus, nil
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetCountByUserId(userId int) (int64, error) {
|
||||
func (rep *WaifuRepository) GetCountByUserId(userId int64) (int64, error) {
|
||||
var count int64 = 0
|
||||
err := rep.db.QueryRow("SELECT COUNT(*) FROM waifus WHERE owner_id=$1;", userId).Scan(&count)
|
||||
return count, err
|
||||
@@ -91,7 +91,7 @@ func (rep *WaifuRepository) GetFreeByRarity(rarity int) ([]Waifu, error) {
|
||||
return waifus, err
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetById(id int) (*Waifu, error) {
|
||||
func (rep *WaifuRepository) GetById(id int64) (*Waifu, error) {
|
||||
waifu := new(Waifu)
|
||||
err := rep.db.Get(waifu, "SELECT * FROM waifus WHERE id=$1;", id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user