164 lines
7.7 KiB
Go
164 lines
7.7 KiB
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"furtuna-be/internal/common/mycontext"
|
|
"furtuna-be/internal/services/balance"
|
|
"furtuna-be/internal/services/discovery"
|
|
service "furtuna-be/internal/services/license"
|
|
"furtuna-be/internal/services/order"
|
|
"furtuna-be/internal/services/oss"
|
|
"furtuna-be/internal/services/partner"
|
|
"furtuna-be/internal/services/product"
|
|
site "furtuna-be/internal/services/sites"
|
|
"furtuna-be/internal/services/studio"
|
|
"furtuna-be/internal/services/transaction"
|
|
"furtuna-be/internal/services/users"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"furtuna-be/config"
|
|
"furtuna-be/internal/entity"
|
|
"furtuna-be/internal/repository"
|
|
"furtuna-be/internal/services/auth"
|
|
"furtuna-be/internal/services/event"
|
|
)
|
|
|
|
type ServiceManagerImpl struct {
|
|
AuthSvc Auth
|
|
EventSvc Event
|
|
UserSvc User
|
|
StudioSvc Studio
|
|
ProductSvc Product
|
|
OrderSvc Order
|
|
OSSSvc OSSService
|
|
PartnerSvc Partner
|
|
SiteSvc Site
|
|
LicenseSvc License
|
|
Transaction Transaction
|
|
Balance Balance
|
|
DiscoverService DiscoverService
|
|
}
|
|
|
|
func NewServiceManagerImpl(cfg *config.Config, repo *repository.RepoManagerImpl) *ServiceManagerImpl {
|
|
return &ServiceManagerImpl{
|
|
AuthSvc: auth.New(repo.Auth, repo.Crypto, repo.User, repo.EmailService, cfg.Email, repo.Trx, repo.License),
|
|
EventSvc: event.NewEventService(repo.Event),
|
|
UserSvc: users.NewUserService(repo.User),
|
|
StudioSvc: studio.NewStudioService(repo.Studio),
|
|
ProductSvc: product.NewProductService(repo.Product),
|
|
OrderSvc: order.NewOrderService(repo.Order, repo.Product, repo.Crypto, repo.Midtrans, repo.Payment, repo.Trx, repo.Wallet, &cfg.Order, repo.Transaction),
|
|
OSSSvc: oss.NewOSSService(repo.OSS),
|
|
PartnerSvc: partner.NewPartnerService(
|
|
repo.Partner, users.NewUserService(repo.User), repo.Trx, repo.Wallet, repo.User),
|
|
SiteSvc: site.NewSiteService(repo.Site, repo.User),
|
|
LicenseSvc: service.NewLicenseService(repo.License),
|
|
Transaction: transaction.New(repo.Transaction, repo.Wallet, repo.Trx),
|
|
Balance: balance.NewBalanceService(repo.Wallet, repo.Trx, repo.Crypto, &cfg.Withdraw, repo.Transaction),
|
|
DiscoverService: discovery.NewDiscoveryService(repo.Site, cfg.Discovery, repo.Product),
|
|
}
|
|
}
|
|
|
|
type Auth interface {
|
|
AuthenticateUser(ctx context.Context, email, password string) (*entity.AuthenticateUser, error)
|
|
SendPasswordResetLink(ctx context.Context, email string) error
|
|
ResetPassword(ctx mycontext.Context, oldPassword, newPassword string) error
|
|
}
|
|
|
|
type Event interface {
|
|
Create(ctx context.Context, eventReq *entity.Event) (*entity.Event, error)
|
|
Update(ctx context.Context, id int64, eventReq *entity.Event) (*entity.Event, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Event, error)
|
|
GetAll(ctx context.Context, search entity.EventSearch) ([]*entity.Event, int, error)
|
|
Delete(ctx context.Context, id int64) error
|
|
}
|
|
|
|
type User interface {
|
|
Create(ctx mycontext.Context, userReq *entity.User) (*entity.User, error)
|
|
CreateWithTx(ctx mycontext.Context, tx *gorm.DB, userReq *entity.User) (*entity.User, error)
|
|
GetAll(ctx mycontext.Context, search entity.UserSearch) ([]*entity.User, int, error)
|
|
GetAllCustomer(ctx mycontext.Context, search entity.CustomerSearch) ([]*entity.Customer, int, error)
|
|
Update(ctx mycontext.Context, id int64, userReq *entity.User) (*entity.User, error)
|
|
UpdateWithTx(ctx mycontext.Context, tx *gorm.DB, req *entity.User) (*entity.User, error)
|
|
GetByID(ctx mycontext.Context, id int64) (*entity.User, error)
|
|
Delete(ctx mycontext.Context, id int64) error
|
|
}
|
|
|
|
type Studio interface {
|
|
Create(ctx mycontext.Context, studioReq *entity.Studio) (*entity.Studio, error)
|
|
Update(ctx mycontext.Context, id int64, studioReq *entity.Studio) (*entity.Studio, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Studio, error)
|
|
Search(ctx context.Context, search entity.StudioSearch) ([]*entity.Studio, int, error)
|
|
}
|
|
|
|
type Product interface {
|
|
Create(ctx mycontext.Context, productReq *entity.Product) (*entity.Product, error)
|
|
Update(ctx mycontext.Context, id int64, productReq *entity.Product) (*entity.Product, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Product, error)
|
|
GetAll(ctx context.Context, search entity.ProductSearch) ([]*entity.Product, int, error)
|
|
GetProductPOS(ctx context.Context, search entity.ProductPOS) ([]*entity.Product, error)
|
|
Delete(ctx mycontext.Context, id int64) error
|
|
}
|
|
|
|
type Order interface {
|
|
CreateOrder(ctx mycontext.Context, req *entity.OrderRequest) (*entity.OrderResponse, error)
|
|
CheckInInquiry(ctx mycontext.Context, qrCode string, partnerID *int64) (*entity.CheckinResponse, error)
|
|
CheckInExecute(ctx mycontext.Context,
|
|
token string, partnerID *int64) (*entity.CheckinExecute, error)
|
|
Execute(ctx context.Context, req *entity.OrderExecuteRequest) (*entity.ExecuteOrderResponse, error)
|
|
ProcessCallback(ctx context.Context, req *entity.CallbackRequest) error
|
|
GetAllHistoryOrders(ctx mycontext.Context, req entity.OrderSearch) ([]*entity.HistoryOrder, int, error)
|
|
CountSoldOfTicket(ctx mycontext.Context, req entity.OrderSearch) (*entity.TicketSold, error)
|
|
SumAmount(ctx mycontext.Context, req entity.OrderSearch) (*entity.Order, error)
|
|
GetDailySales(ctx mycontext.Context, req entity.OrderSearch) ([]entity.ProductDailySales, error)
|
|
GetPaymentDistribution(ctx mycontext.Context, req entity.OrderSearch) ([]entity.PaymentTypeDistribution, error)
|
|
GetByID(ctx mycontext.Context, id int64, referenceID string) (*entity.Order, error)
|
|
GetPrintDetail(ctx mycontext.Context, id int64) (*entity.OrderPrintDetail, error)
|
|
}
|
|
|
|
type OSSService interface {
|
|
UploadFile(ctx context.Context, req *entity.UploadFileRequest) (*entity.UploadFileResponse, error)
|
|
}
|
|
|
|
type Partner interface {
|
|
Create(ctx mycontext.Context, branchReq *entity.CreatePartnerRequest) (*entity.Partner, error)
|
|
Update(ctx mycontext.Context, branchReq *entity.PartnerUpdate) (*entity.Partner, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Partner, error)
|
|
GetAll(ctx context.Context, search entity.PartnerSearch) ([]*entity.Partner, int, error)
|
|
Delete(ctx mycontext.Context, id int64) error
|
|
}
|
|
|
|
type Site interface {
|
|
Create(ctx mycontext.Context, branchReq *entity.Site) (*entity.Site, error)
|
|
Update(ctx mycontext.Context, id int64, branchReq *entity.Site) (*entity.Site, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Site, error)
|
|
GetAll(ctx context.Context, search entity.SiteSearch) ([]*entity.Site, int, error)
|
|
Delete(ctx mycontext.Context, id int64) error
|
|
Count(ctx mycontext.Context, req entity.SiteSearch) (*entity.SiteCount, error)
|
|
}
|
|
|
|
type License interface {
|
|
Create(ctx mycontext.Context, licenseReq *entity.License) (*entity.License, error)
|
|
Update(ctx mycontext.Context, id string, licenseReq *entity.License) (*entity.License, error)
|
|
GetByID(ctx context.Context, id string) (*entity.License, error)
|
|
GetAll(ctx context.Context, limit, offset int, status string) ([]*entity.LicenseGetAll, int64, error)
|
|
}
|
|
|
|
type Transaction interface {
|
|
GetTransactionList(ctx mycontext.Context, req entity.TransactionSearch) ([]*entity.TransactionList, int, error)
|
|
Approval(ctx mycontext.Context, req *entity.TransactionApproval) error
|
|
}
|
|
|
|
type Balance interface {
|
|
GetByID(ctx context.Context, id int64) (*entity.Balance, error)
|
|
WithdrawInquiry(ctx context.Context, req *entity.BalanceWithdrawInquiry) (*entity.BalanceWithdrawInquiryResponse, error)
|
|
WithdrawExecute(ctx mycontext.Context, req *entity.WalletWithdrawRequest) (*entity.WalletWithdrawResponse, error)
|
|
}
|
|
|
|
type DiscoverService interface {
|
|
Home(ctx context.Context, search *entity.DiscoverySearch) (*entity.DiscoverySearchResp, error)
|
|
Search(ctx context.Context, search *entity.DiscoverySearch) (*entity.DiscoverySearchResp, int64, error)
|
|
GetByID(ctx context.Context, id int64) (*entity.Site, error)
|
|
GetProductsByID(ctx context.Context, id int64) ([]*entity.Product, error)
|
|
}
|