package repository import ( "context" "furtuna-be/internal/repository/branches" "furtuna-be/internal/repository/orders" "furtuna-be/internal/repository/oss" "furtuna-be/internal/repository/partners" "furtuna-be/internal/repository/products" "furtuna-be/internal/repository/studios" "furtuna-be/internal/repository/users" "github.com/golang-jwt/jwt" "gorm.io/gorm" "furtuna-be/config" "furtuna-be/internal/entity" "furtuna-be/internal/repository/auth" "furtuna-be/internal/repository/crypto" event "furtuna-be/internal/repository/events" ) type RepoManagerImpl struct { Crypto Crypto Auth Auth Event Event User User Branch Branch Studio Studio Product Product Order Order OSS OSSRepository Partner PartnerRepository } func NewRepoManagerImpl(db *gorm.DB, cfg *config.Config) *RepoManagerImpl { return &RepoManagerImpl{ Crypto: crypto.NewCrypto(cfg.Auth()), Auth: auth.NewAuthRepository(db), Event: event.NewEventRepo(db), User: users.NewUserRepository(db), Branch: branches.NewBranchRepository(db), Studio: studios.NewStudioRepository(db), Product: products.NewProductRepository(db), Order: orders.NewOrderRepository(db), OSS: oss.NewOssRepositoryImpl(cfg.OSSConfig), Partner: partners.NewPartnerRepository(db), } } type Auth interface { CheckExistsUserAccount(ctx context.Context, email string) (*entity.UserDB, error) } type Event interface { CreateEvent(ctx context.Context, event *entity.EventDB) (*entity.EventDB, error) UpdateEvent(ctx context.Context, event *entity.EventDB) (*entity.EventDB, error) GetEventByID(ctx context.Context, id int64) (*entity.EventDB, error) GetAllEvents(ctx context.Context, nameFilter string, limit, offset int) (entity.EventList, int, error) DeleteEvent(ctx context.Context, id int64) error } type Crypto interface { CompareHashAndPassword(hash string, password string) bool ValidateWT(tokenString string) (*jwt.Token, error) GenerateJWT(user *entity.User) (string, error) ParseAndValidateJWT(token string) (*entity.JWTAuthClaims, error) } type User interface { Create(ctx context.Context, user *entity.UserDB) (*entity.UserDB, error) GetAllUsers(ctx context.Context, req entity.UserSearch) (entity.UserList, int, error) GetUserByID(ctx context.Context, id int64) (*entity.UserDB, error) GetUserByEmail(ctx context.Context, email string) (*entity.UserDB, error) UpdateUser(ctx context.Context, user *entity.UserDB) (*entity.UserDB, error) } type Branch interface { CreateBranch(ctx context.Context, branch *entity.BranchDB) (*entity.BranchDB, error) UpdateBranch(ctx context.Context, branch *entity.BranchDB) (*entity.BranchDB, error) GetBranchByID(ctx context.Context, id int64) (*entity.BranchDB, error) GetAllBranches(ctx context.Context, req entity.BranchSearch) (entity.BranchList, int, error) DeleteBranch(ctx context.Context, id int64) error } type Studio interface { CreateStudio(ctx context.Context, studio *entity.StudioDB) (*entity.StudioDB, error) UpdateStudio(ctx context.Context, studio *entity.StudioDB) (*entity.StudioDB, error) GetStudioByID(ctx context.Context, id int64) (*entity.StudioDB, error) SearchStudios(ctx context.Context, req entity.StudioSearch) (entity.StudioList, int, error) } type Product interface { CreateProduct(ctx context.Context, product *entity.ProductDB) (*entity.ProductDB, error) UpdateProduct(ctx context.Context, product *entity.ProductDB) (*entity.ProductDB, error) GetProductByID(ctx context.Context, id int64) (*entity.ProductDB, error) GetAllProducts(ctx context.Context, req entity.ProductSearch) (entity.ProductList, int, error) DeleteProduct(ctx context.Context, id int64) error } type Order interface { CreateOrder(ctx context.Context, order *entity.OrderDB) (*entity.OrderDB, error) UpdateOrder(ctx context.Context, order *entity.OrderDB) (*entity.OrderDB, error) GetOrderByID(ctx context.Context, id int64) (*entity.OrderDB, error) GetAllOrders(ctx context.Context, req entity.OrderSearch) (entity.OrderList, int, error) GetTotalRevenue(ctx context.Context, req entity.OrderTotalRevenueSearch) (float64, int64, error) GetYearlyRevenue(ctx context.Context, year int) (entity.OrderYearlyRevenueList, error) GetBranchRevenue(ctx context.Context, req entity.OrderBranchRevenueSearch) (entity.OrderBranchRevenueList, error) } type OSSRepository interface { UploadFile(ctx context.Context, fileName string, fileContent []byte) (fileUrl string, err error) GetPublicURL(fileName string) string } type PartnerRepository interface { Create(ctx context.Context, branch *entity.PartnerDB) (*entity.PartnerDB, error) Update(ctx context.Context, branch *entity.PartnerDB) (*entity.PartnerDB, error) GetByID(ctx context.Context, id int64) (*entity.PartnerDB, error) GetAll(ctx context.Context, req entity.PartnerSearch) (entity.PartnerList, int, error) Delete(ctx context.Context, id int64) error }