common/structs/storage/storage.go

46 lines
986 B
Go
Raw Permalink Normal View History

2024-08-04 20:46:49 +08:00
package storage
import "gorm.io/gorm"
type Storage struct {
2024-09-02 16:12:22 +08:00
db *gorm.DB
2024-08-26 15:15:04 +08:00
articleApi ArticleApi
providerApi ProviderApi
providerArticleApi ProviderArticleApi
2024-08-27 16:39:06 +08:00
sellerApi SellerApi
sellerArticleApi SellerArticleApi
2024-08-04 20:46:49 +08:00
}
func NewStorage(db *gorm.DB) *Storage {
return &Storage{
2024-09-02 16:12:22 +08:00
db: db,
2024-08-27 19:35:21 +08:00
articleApi: NewArticleApi(db),
providerApi: NewProviderApi(db),
providerArticleApi: NewProviderArticleApi(db),
sellerApi: NewSellerApi(db),
2024-08-31 18:27:17 +08:00
sellerArticleApi: NewSellerArticleApi(db),
2024-08-04 20:46:49 +08:00
}
}
2024-09-02 16:12:22 +08:00
func (s *Storage) DB() *gorm.DB {
return s.db
}
2024-08-04 20:46:49 +08:00
func (s *Storage) Article() ArticleApi {
return s.articleApi
}
2024-08-23 18:12:31 +08:00
func (s *Storage) Provider() ProviderApi {
return s.providerApi
}
2024-08-26 15:15:04 +08:00
func (s *Storage) ProviderArticle() ProviderArticleApi {
return s.providerArticleApi
}
2024-08-27 16:39:06 +08:00
func (s *Storage) Seller() SellerApi {
return s.sellerApi
}
2024-08-31 18:27:17 +08:00
func (s *Storage) SellerArticle() SellerArticleApi {
return s.sellerArticleApi
}