2025-07-15 13:21:34 +08:00
|
|
|
package product
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"tyapi-server/internal/application/product/dto/commands"
|
|
|
|
|
"tyapi-server/internal/application/product/dto/queries"
|
|
|
|
|
"tyapi-server/internal/application/product/dto/responses"
|
2025-07-28 01:46:39 +08:00
|
|
|
"tyapi-server/internal/shared/interfaces"
|
2025-07-15 13:21:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ProductApplicationService 产品应用服务接口
|
|
|
|
|
type ProductApplicationService interface {
|
|
|
|
|
// 产品管理
|
|
|
|
|
CreateProduct(ctx context.Context, cmd *commands.CreateProductCommand) error
|
|
|
|
|
UpdateProduct(ctx context.Context, cmd *commands.UpdateProductCommand) error
|
|
|
|
|
DeleteProduct(ctx context.Context, cmd *commands.DeleteProductCommand) error
|
2025-07-20 20:53:26 +08:00
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
GetProductByID(ctx context.Context, query *queries.GetProductQuery) (*responses.ProductInfoResponse, error)
|
2025-07-28 01:46:39 +08:00
|
|
|
ListProducts(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductListResponse, error)
|
2025-07-29 00:30:32 +08:00
|
|
|
ListProductsWithSubscriptionStatus(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductListResponse, error)
|
2025-07-15 13:21:34 +08:00
|
|
|
GetProductsByIDs(ctx context.Context, query *queries.GetProductsByIDsQuery) ([]*responses.ProductInfoResponse, error)
|
2025-07-20 20:53:26 +08:00
|
|
|
|
2025-07-30 00:51:22 +08:00
|
|
|
// 管理员专用方法
|
|
|
|
|
ListProductsForAdmin(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductAdminListResponse, error)
|
|
|
|
|
GetProductByIDForAdmin(ctx context.Context, query *queries.GetProductQuery) (*responses.ProductAdminInfoResponse, error)
|
|
|
|
|
|
|
|
|
|
// 用户端专用方法
|
|
|
|
|
GetProductByIDForUser(ctx context.Context, query *queries.GetProductQuery) (*responses.ProductInfoResponse, error)
|
|
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
// 业务查询
|
|
|
|
|
GetSubscribableProducts(ctx context.Context, query *queries.GetSubscribableProductsQuery) ([]*responses.ProductInfoResponse, error)
|
|
|
|
|
GetProductStats(ctx context.Context) (*responses.ProductStatsResponse, error)
|
2025-07-28 01:46:39 +08:00
|
|
|
|
|
|
|
|
// 组合包管理
|
|
|
|
|
AddPackageItem(ctx context.Context, packageID string, cmd *commands.AddPackageItemCommand) error
|
|
|
|
|
UpdatePackageItem(ctx context.Context, packageID, itemID string, cmd *commands.UpdatePackageItemCommand) error
|
|
|
|
|
RemovePackageItem(ctx context.Context, packageID, itemID string) error
|
|
|
|
|
ReorderPackageItems(ctx context.Context, packageID string, cmd *commands.ReorderPackageItemsCommand) error
|
|
|
|
|
UpdatePackageItems(ctx context.Context, packageID string, cmd *commands.UpdatePackageItemsCommand) error
|
2025-07-30 00:51:22 +08:00
|
|
|
|
|
|
|
|
// 可选子产品查询
|
2025-07-28 01:46:39 +08:00
|
|
|
GetAvailableProducts(ctx context.Context, query *queries.GetAvailableProductsQuery) (*responses.ProductListResponse, error)
|
|
|
|
|
|
|
|
|
|
// API配置管理
|
|
|
|
|
GetProductApiConfig(ctx context.Context, productID string) (*responses.ProductApiConfigResponse, error)
|
|
|
|
|
CreateProductApiConfig(ctx context.Context, productID string, config *responses.ProductApiConfigResponse) error
|
|
|
|
|
UpdateProductApiConfig(ctx context.Context, configID string, config *responses.ProductApiConfigResponse) error
|
|
|
|
|
DeleteProductApiConfig(ctx context.Context, configID string) error
|
2025-07-15 13:21:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CategoryApplicationService 分类应用服务接口
|
|
|
|
|
type CategoryApplicationService interface {
|
|
|
|
|
// 分类管理
|
|
|
|
|
CreateCategory(ctx context.Context, cmd *commands.CreateCategoryCommand) error
|
|
|
|
|
UpdateCategory(ctx context.Context, cmd *commands.UpdateCategoryCommand) error
|
|
|
|
|
DeleteCategory(ctx context.Context, cmd *commands.DeleteCategoryCommand) error
|
2025-07-20 20:53:26 +08:00
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
GetCategoryByID(ctx context.Context, query *queries.GetCategoryQuery) (*responses.CategoryInfoResponse, error)
|
|
|
|
|
ListCategories(ctx context.Context, query *queries.ListCategoriesQuery) (*responses.CategoryListResponse, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SubscriptionApplicationService 订阅应用服务接口
|
|
|
|
|
type SubscriptionApplicationService interface {
|
2025-07-20 20:53:26 +08:00
|
|
|
// 订阅管理
|
|
|
|
|
UpdateSubscriptionPrice(ctx context.Context, cmd *commands.UpdateSubscriptionPriceCommand) error
|
|
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
// 订阅管理
|
|
|
|
|
CreateSubscription(ctx context.Context, cmd *commands.CreateSubscriptionCommand) error
|
|
|
|
|
GetSubscriptionByID(ctx context.Context, query *queries.GetSubscriptionQuery) (*responses.SubscriptionInfoResponse, error)
|
|
|
|
|
ListSubscriptions(ctx context.Context, query *queries.ListSubscriptionsQuery) (*responses.SubscriptionListResponse, error)
|
2025-07-20 20:53:26 +08:00
|
|
|
|
2025-07-28 23:28:24 +08:00
|
|
|
// 我的订阅(用户专用)
|
|
|
|
|
ListMySubscriptions(ctx context.Context, userID string, query *queries.ListSubscriptionsQuery) (*responses.SubscriptionListResponse, error)
|
|
|
|
|
GetMySubscriptionStats(ctx context.Context, userID string) (*responses.SubscriptionStatsResponse, error)
|
|
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
// 业务查询
|
|
|
|
|
GetUserSubscriptions(ctx context.Context, query *queries.GetUserSubscriptionsQuery) ([]*responses.SubscriptionInfoResponse, error)
|
|
|
|
|
GetProductSubscriptions(ctx context.Context, query *queries.GetProductSubscriptionsQuery) ([]*responses.SubscriptionInfoResponse, error)
|
|
|
|
|
GetSubscriptionUsage(ctx context.Context, subscriptionID string) (*responses.SubscriptionUsageResponse, error)
|
2025-07-20 20:53:26 +08:00
|
|
|
|
2025-07-15 13:21:34 +08:00
|
|
|
// 统计
|
|
|
|
|
GetSubscriptionStats(ctx context.Context) (*responses.SubscriptionStatsResponse, error)
|
2025-07-20 20:53:26 +08:00
|
|
|
}
|