f
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// ComponentReportRepository 组件报告仓储接口
|
||||
type ComponentReportRepository interface {
|
||||
// 创建下载记录
|
||||
Create(ctx context.Context, download *entities.ComponentReportDownload) error
|
||||
|
||||
// 更新下载记录
|
||||
UpdateDownload(ctx context.Context, download *entities.ComponentReportDownload) error
|
||||
|
||||
// 根据ID获取下载记录
|
||||
GetDownloadByID(ctx context.Context, id string) (*entities.ComponentReportDownload, error)
|
||||
|
||||
// 获取用户的下载记录列表
|
||||
GetUserDownloads(ctx context.Context, userID string, productID *string) ([]*entities.ComponentReportDownload, error)
|
||||
|
||||
// 获取用户有效的下载记录
|
||||
GetActiveDownload(ctx context.Context, userID, productID string) (*entities.ComponentReportDownload, error)
|
||||
|
||||
// 更新下载记录文件路径
|
||||
UpdateFilePath(ctx context.Context, downloadID, filePath string) error
|
||||
|
||||
// 增加下载次数
|
||||
IncrementDownloadCount(ctx context.Context, downloadID string) error
|
||||
|
||||
// 检查用户是否已下载过指定产品编号的组件
|
||||
HasUserDownloaded(ctx context.Context, userID string, productCode string) (bool, error)
|
||||
|
||||
// 获取用户已下载的产品编号列表
|
||||
GetUserDownloadedProductCodes(ctx context.Context, userID string) ([]string, error)
|
||||
|
||||
// 根据支付订单号获取下载记录
|
||||
GetDownloadByPaymentOrderID(ctx context.Context, orderID string) (*entities.ComponentReportDownload, error)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// ProductApiConfigRepository 产品API配置仓库接口
|
||||
type ProductApiConfigRepository interface {
|
||||
// 基础CRUD操作
|
||||
Create(ctx context.Context, config entities.ProductApiConfig) error
|
||||
Update(ctx context.Context, config entities.ProductApiConfig) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
GetByID(ctx context.Context, id string) (*entities.ProductApiConfig, error)
|
||||
|
||||
// 根据产品ID查找配置
|
||||
FindByProductID(ctx context.Context, productID string) (*entities.ProductApiConfig, error)
|
||||
|
||||
// 根据产品代码查找配置
|
||||
FindByProductCode(ctx context.Context, productCode string) (*entities.ProductApiConfig, error)
|
||||
|
||||
// 批量获取配置
|
||||
FindByProductIDs(ctx context.Context, productIDs []string) ([]*entities.ProductApiConfig, error)
|
||||
|
||||
// 检查配置是否存在
|
||||
ExistsByProductID(ctx context.Context, productID string) (bool, error)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
"hyapi-server/internal/domains/product/repositories/queries"
|
||||
"hyapi-server/internal/shared/interfaces"
|
||||
)
|
||||
|
||||
// ProductCategoryRepository 产品分类仓储接口
|
||||
type ProductCategoryRepository interface {
|
||||
interfaces.Repository[entities.ProductCategory]
|
||||
|
||||
// 基础查询方法
|
||||
FindByCode(ctx context.Context, code string) (*entities.ProductCategory, error)
|
||||
FindVisible(ctx context.Context) ([]*entities.ProductCategory, error)
|
||||
FindEnabled(ctx context.Context) ([]*entities.ProductCategory, error)
|
||||
|
||||
// 复杂查询方法
|
||||
ListCategories(ctx context.Context, query *queries.ListCategoriesQuery) ([]*entities.ProductCategory, int64, error)
|
||||
|
||||
// 统计方法
|
||||
CountEnabled(ctx context.Context) (int64, error)
|
||||
CountVisible(ctx context.Context) (int64, error)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// ProductDocumentationRepository 产品文档仓储接口
|
||||
type ProductDocumentationRepository interface {
|
||||
// 基础CRUD操作
|
||||
Create(ctx context.Context, documentation *entities.ProductDocumentation) error
|
||||
Update(ctx context.Context, documentation *entities.ProductDocumentation) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
FindByID(ctx context.Context, id string) (*entities.ProductDocumentation, error)
|
||||
|
||||
// 业务查询操作
|
||||
FindByProductID(ctx context.Context, productID string) (*entities.ProductDocumentation, error)
|
||||
|
||||
// 批量操作
|
||||
FindByProductIDs(ctx context.Context, productIDs []string) ([]*entities.ProductDocumentation, error)
|
||||
UpdateBatch(ctx context.Context, documentations []*entities.ProductDocumentation) error
|
||||
|
||||
// 统计操作
|
||||
CountByProductID(ctx context.Context, productID string) (int64, error)
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
"hyapi-server/internal/domains/product/repositories/queries"
|
||||
"hyapi-server/internal/shared/interfaces"
|
||||
)
|
||||
|
||||
// ProductRepository 产品仓储接口
|
||||
type ProductRepository interface {
|
||||
interfaces.Repository[entities.Product]
|
||||
|
||||
// 基础查询方法
|
||||
FindByCode(ctx context.Context, code string) (*entities.Product, error)
|
||||
FindByOldID(ctx context.Context, oldID string) (*entities.Product, error)
|
||||
FindByCategoryID(ctx context.Context, categoryID string) ([]*entities.Product, error)
|
||||
FindVisible(ctx context.Context) ([]*entities.Product, error)
|
||||
FindEnabled(ctx context.Context) ([]*entities.Product, error)
|
||||
|
||||
// 复杂查询方法
|
||||
ListProducts(ctx context.Context, query *queries.ListProductsQuery) ([]*entities.Product, int64, error)
|
||||
ListProductsWithSubscriptionStatus(ctx context.Context, query *queries.ListProductsQuery) ([]*entities.Product, map[string]bool, int64, error)
|
||||
|
||||
// 业务查询方法
|
||||
FindSubscribableProducts(ctx context.Context, userID string) ([]*entities.Product, error)
|
||||
FindProductsByIDs(ctx context.Context, ids []string) ([]*entities.Product, error)
|
||||
|
||||
// 统计方法
|
||||
CountByCategory(ctx context.Context, categoryID string) (int64, error)
|
||||
CountEnabled(ctx context.Context) (int64, error)
|
||||
CountVisible(ctx context.Context) (int64, error)
|
||||
|
||||
// 组合包相关方法
|
||||
GetPackageItems(ctx context.Context, packageID string) ([]*entities.ProductPackageItem, error)
|
||||
CreatePackageItem(ctx context.Context, packageItem *entities.ProductPackageItem) error
|
||||
GetPackageItemByID(ctx context.Context, itemID string) (*entities.ProductPackageItem, error)
|
||||
UpdatePackageItem(ctx context.Context, packageItem *entities.ProductPackageItem) error
|
||||
DeletePackageItem(ctx context.Context, itemID string) error
|
||||
DeletePackageItemsByPackageID(ctx context.Context, packageID string) error
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// ProductSubCategoryRepository 产品二级分类仓储接口
|
||||
type ProductSubCategoryRepository interface {
|
||||
// 基础CRUD方法
|
||||
GetByID(ctx context.Context, id string) (*entities.ProductSubCategory, error)
|
||||
Create(ctx context.Context, category entities.ProductSubCategory) (*entities.ProductSubCategory, error)
|
||||
Update(ctx context.Context, category entities.ProductSubCategory) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
List(ctx context.Context) ([]*entities.ProductSubCategory, error)
|
||||
|
||||
// 查询方法
|
||||
FindByCode(ctx context.Context, code string) (*entities.ProductSubCategory, error)
|
||||
FindByCategoryID(ctx context.Context, categoryID string) ([]*entities.ProductSubCategory, error)
|
||||
FindVisible(ctx context.Context) ([]*entities.ProductSubCategory, error)
|
||||
FindEnabled(ctx context.Context) ([]*entities.ProductSubCategory, error)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// ProductUIComponentRepository 产品UI组件关联仓储接口
|
||||
type ProductUIComponentRepository interface {
|
||||
Create(ctx context.Context, relation entities.ProductUIComponent) (entities.ProductUIComponent, error)
|
||||
GetByProductID(ctx context.Context, productID string) ([]entities.ProductUIComponent, error)
|
||||
GetByUIComponentID(ctx context.Context, componentID string) ([]entities.ProductUIComponent, error)
|
||||
Delete(ctx context.Context, id string) error
|
||||
DeleteByProductID(ctx context.Context, productID string) error
|
||||
BatchCreate(ctx context.Context, relations []entities.ProductUIComponent) error
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package queries
|
||||
|
||||
// ListCategoriesQuery 分类列表查询
|
||||
type ListCategoriesQuery struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
IsEnabled *bool `json:"is_enabled"`
|
||||
IsVisible *bool `json:"is_visible"`
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
}
|
||||
|
||||
// GetCategoryQuery 获取分类详情查询
|
||||
type GetCategoryQuery struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
// GetCategoryTreeQuery 获取分类树查询
|
||||
type GetCategoryTreeQuery struct {
|
||||
IncludeDisabled bool `json:"include_disabled"`
|
||||
IncludeHidden bool `json:"include_hidden"`
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package queries
|
||||
|
||||
// ListProductsQuery 产品列表查询
|
||||
type ListProductsQuery struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Keyword string `json:"keyword"`
|
||||
CategoryID string `json:"category_id"`
|
||||
MinPrice *float64 `json:"min_price"`
|
||||
MaxPrice *float64 `json:"max_price"`
|
||||
IsEnabled *bool `json:"is_enabled"`
|
||||
IsVisible *bool `json:"is_visible"`
|
||||
IsPackage *bool `json:"is_package"`
|
||||
UserID string `json:"user_id"` // 用户ID,用于查询订阅状态
|
||||
IsSubscribed *bool `json:"is_subscribed"` // 是否已订阅筛选
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
}
|
||||
|
||||
// SearchProductsQuery 产品搜索查询
|
||||
type SearchProductsQuery struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Keyword string `json:"keyword"`
|
||||
CategoryID string `json:"category_id"`
|
||||
MinPrice *float64 `json:"min_price"`
|
||||
MaxPrice *float64 `json:"max_price"`
|
||||
IsEnabled *bool `json:"is_enabled"`
|
||||
IsVisible *bool `json:"is_visible"`
|
||||
IsPackage *bool `json:"is_package"`
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
}
|
||||
|
||||
// GetProductQuery 获取产品详情查询
|
||||
type GetProductQuery struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
// GetProductsByIDsQuery 根据ID列表获取产品查询
|
||||
type GetProductsByIDsQuery struct {
|
||||
IDs []string `json:"ids"`
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package queries
|
||||
|
||||
// ListSubscriptionsQuery 订阅列表查询
|
||||
type ListSubscriptionsQuery struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
UserID string `json:"user_id"`
|
||||
Keyword string `json:"keyword"`
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
|
||||
// 新增筛选字段
|
||||
CompanyName string `json:"company_name"` // 企业名称
|
||||
ProductName string `json:"product_name"` // 产品名称
|
||||
StartTime string `json:"start_time"` // 订阅开始时间
|
||||
EndTime string `json:"end_time"` // 订阅结束时间
|
||||
}
|
||||
|
||||
// GetSubscriptionQuery 获取订阅详情查询
|
||||
type GetSubscriptionQuery struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// GetUserSubscriptionsQuery 获取用户订阅查询
|
||||
type GetUserSubscriptionsQuery struct {
|
||||
UserID string `json:"user_id"`
|
||||
}
|
||||
|
||||
// GetProductSubscriptionsQuery 获取产品订阅查询
|
||||
type GetProductSubscriptionsQuery struct {
|
||||
ProductID string `json:"product_id"`
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
"hyapi-server/internal/domains/product/repositories/queries"
|
||||
"hyapi-server/internal/shared/interfaces"
|
||||
)
|
||||
|
||||
// SubscriptionRepository 订阅仓储接口
|
||||
type SubscriptionRepository interface {
|
||||
interfaces.Repository[entities.Subscription]
|
||||
|
||||
// 基础查询方法
|
||||
FindByUserID(ctx context.Context, userID string) ([]*entities.Subscription, error)
|
||||
FindByProductID(ctx context.Context, productID string) ([]*entities.Subscription, error)
|
||||
FindByUserAndProduct(ctx context.Context, userID, productID string) (*entities.Subscription, error)
|
||||
|
||||
// 复杂查询方法
|
||||
ListSubscriptions(ctx context.Context, query *queries.ListSubscriptionsQuery) ([]*entities.Subscription, int64, error)
|
||||
|
||||
// 统计方法
|
||||
CountByUser(ctx context.Context, userID string) (int64, error)
|
||||
CountByProduct(ctx context.Context, productID string) (int64, error)
|
||||
GetTotalRevenue(ctx context.Context) (float64, error)
|
||||
|
||||
// 乐观锁更新方法
|
||||
IncrementAPIUsageWithOptimisticLock(ctx context.Context, subscriptionID string, increment int64) error
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hyapi-server/internal/domains/product/entities"
|
||||
)
|
||||
|
||||
// UIComponentRepository UI组件仓储接口
|
||||
type UIComponentRepository interface {
|
||||
Create(ctx context.Context, component entities.UIComponent) (entities.UIComponent, error)
|
||||
GetByID(ctx context.Context, id string) (*entities.UIComponent, error)
|
||||
GetByCode(ctx context.Context, code string) (*entities.UIComponent, error)
|
||||
List(ctx context.Context, filters map[string]interface{}) ([]entities.UIComponent, int64, error)
|
||||
Update(ctx context.Context, component entities.UIComponent) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
GetByCodes(ctx context.Context, codes []string) ([]entities.UIComponent, error)
|
||||
}
|
||||
Reference in New Issue
Block a user