refactoring, fixes and laniakea v0.8

This commit is contained in:
2026-02-19 14:02:25 +03:00
parent 0804398b6c
commit c9a5a81643
30 changed files with 219 additions and 190 deletions

View File

@@ -1,7 +1,8 @@
package psql
import (
"git.nix13.pw/scuroneko/laniakea"
"ymgb/database"
"github.com/vinovest/sqlx"
)
@@ -19,8 +20,8 @@ type AIRepository struct {
func newAiRepository(db *sqlx.DB) AIRepository {
return AIRepository{db}
}
func NewAIRepository(db *laniakea.DatabaseContext) AIRepository {
return newAiRepository(db.PostgresSQL)
func NewAIRepository(db *database.Context) AIRepository {
return newAiRepository(db.Postgres)
}
func (rep AIRepository) GetModel(id string) (AIModel, error) {

View File

@@ -1,7 +1,8 @@
package psql
import (
"git.nix13.pw/scuroneko/laniakea"
"ymgb/database"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -22,8 +23,8 @@ type FractionRepository struct {
func newFractionRepository(db *sqlx.DB) FractionRepository {
return FractionRepository{db}
}
func NewFractionRepository(db *laniakea.DatabaseContext) FractionRepository {
return newFractionRepository(db.PostgresSQL)
func NewFractionRepository(db *database.Context) FractionRepository {
return newFractionRepository(db.Postgres)
}
func (rep FractionRepository) GetAll() ([]Fraction, error) {

View File

@@ -1,7 +1,8 @@
package psql
import (
"git.nix13.pw/scuroneko/laniakea"
"ymgb/database"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -25,8 +26,8 @@ type GroupRepository struct {
func newGroupRepository(db *sqlx.DB) GroupRepository {
return GroupRepository{db}
}
func NewGroupRepository(db *laniakea.DatabaseContext) GroupRepository {
return newGroupRepository(db.PostgresSQL)
func NewGroupRepository(db *database.Context) GroupRepository {
return newGroupRepository(db.Postgres)
}
func (rep GroupRepository) GetAll() ([]Group, error) {

View File

@@ -3,8 +3,8 @@ package psql
import (
"database/sql"
"errors"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/vinovest/sqlx"
)
@@ -56,8 +56,8 @@ type RPRepository struct {
func newRpRepository(db *sqlx.DB) RPRepository {
return RPRepository{db}
}
func NewRPRepository(db *laniakea.DatabaseContext) RPRepository {
return newRpRepository(db.PostgresSQL)
func NewRPRepository(db *database.Context) RPRepository {
return newRpRepository(db.Postgres)
}
func (rep RPRepository) GetOrCreateUser(id int64) (RPUser, error) {

View File

@@ -1,7 +1,8 @@
package psql
import (
"git.nix13.pw/scuroneko/laniakea"
"ymgb/database"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -37,10 +38,10 @@ type ShopRepository struct {
db *sqlx.DB
}
func NewShopRepository(db *laniakea.DatabaseContext) ShopRepository {
return newShopRepository(db.PostgresSQL)
}
func newShopRepository(db *sqlx.DB) ShopRepository { return ShopRepository{db} }
func NewShopRepository(db *database.Context) ShopRepository {
return newShopRepository(db.Postgres)
}
func (rep ShopRepository) GetAllAuto() ([]ShopAuto, error) {
auto := make([]ShopAuto, 0)

View File

@@ -6,8 +6,8 @@ import (
"errors"
"math"
"time"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -56,8 +56,8 @@ type UserRepository struct {
}
func newUserRepository(db *sqlx.DB) UserRepository { return UserRepository{db} }
func NewUserRepository(db *laniakea.DatabaseContext) UserRepository {
return newUserRepository(db.PostgresSQL)
func NewUserRepository(db *database.Context) UserRepository {
return newUserRepository(db.Postgres)
}
func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {

View File

@@ -2,8 +2,8 @@ package psql
import (
"database/sql"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -26,8 +26,9 @@ type WaifuRepository struct {
db *sqlx.DB
}
func NewWaifuRepository(db *laniakea.DatabaseContext) *WaifuRepository {
return &WaifuRepository{db: db.PostgresSQL}
func newWaifuRepository(db *sqlx.DB) *WaifuRepository { return &WaifuRepository{db} }
func NewWaifuRepository(db *database.Context) *WaifuRepository {
return newWaifuRepository(db.Postgres)
}
func (rep *WaifuRepository) GetAll() ([]*Waifu, error) {

View File

@@ -1,7 +1,8 @@
package psql
import (
"git.nix13.pw/scuroneko/laniakea"
"ymgb/database"
"github.com/shopspring/decimal"
"github.com/vinovest/sqlx"
)
@@ -22,8 +23,8 @@ type WorkRepository struct {
func newWorkRepository(db *sqlx.DB) WorkRepository {
return WorkRepository{db}
}
func NewWorkRepository(db *laniakea.DatabaseContext) WorkRepository {
return newWorkRepository(db.PostgresSQL)
func NewWorkRepository(db *database.Context) WorkRepository {
return newWorkRepository(db.Postgres)
}
func (rep WorkRepository) GetById(id int) (Work, error) {