common/structs/storage/storage.go

46 lines
986 B
Go

package storage
import "gorm.io/gorm"
type Storage struct {
db *gorm.DB
articleApi ArticleApi
providerApi ProviderApi
providerArticleApi ProviderArticleApi
sellerApi SellerApi
sellerArticleApi SellerArticleApi
}
func NewStorage(db *gorm.DB) *Storage {
return &Storage{
db: db,
articleApi: NewArticleApi(db),
providerApi: NewProviderApi(db),
providerArticleApi: NewProviderArticleApi(db),
sellerApi: NewSellerApi(db),
sellerArticleApi: NewSellerArticleApi(db),
}
}
func (s *Storage) DB() *gorm.DB {
return s.db
}
func (s *Storage) Article() ArticleApi {
return s.articleApi
}
func (s *Storage) Provider() ProviderApi {
return s.providerApi
}
func (s *Storage) ProviderArticle() ProviderArticleApi {
return s.providerArticleApi
}
func (s *Storage) Seller() SellerApi {
return s.sellerApi
}
func (s *Storage) SellerArticle() SellerArticleApi {
return s.sellerArticleApi
}