app-cloudep-product-service/pkg/domain/repository/product.go

57 lines
1.8 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package repository
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// ProductRepository 存取 Product 的地方
type ProductRepository interface {
Insert(ctx context.Context, data *entity.Product) error
FindOneByID(ctx context.Context, id string) (*entity.Product, error)
FindOneBySlug(ctx context.Context, slug string) (*entity.Product, error)
Update(ctx context.Context, productID string, data *ProductUpdateParams) (*mongo.UpdateResult, error)
Delete(ctx context.Context, id string) error
ListProduct(ctx context.Context, params *ProductQueryParams) ([]*entity.Product, int64, error)
Transaction(ctx context.Context,
fn func(sessCtx mongo.SessionContext) (any, error),
opts ...*options.TransactionOptions) error
ProductIndex
}
type ProductIndex interface {
Index20250317001UP(ctx context.Context) (*mongo.Cursor, error)
}
// ProductQueryParams 用於查詢專案的參數
type ProductQueryParams struct {
UID *string // 專案擁有者 UID
IsPublished *bool // 是否已上架
Category *string // 類別
StartTime *int64 // 起始時間Unix 時間戳)
EndTime *int64 // 結束時間Unix 時間戳)
Slug *string // URL 後綴
PageIndex int64 // 頁碼
PageSize int64 // 每頁數量
}
// ProductUpdateParams 用於更新專案的參數
type ProductUpdateParams struct {
Title *string
ShortTitle *string
Details *string
ShortDescription string
Media []entity.Media
Category *string
Slug *string
IsPublished *bool
Amount *uint64
StartTime *int64
EndTime *int64
CustomFields []entity.CustomFields
}