feat: tmp uc
This commit is contained in:
parent
f84f58a460
commit
dba8d1deeb
|
@ -0,0 +1,124 @@
|
||||||
|
package usecase
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
|
||||||
|
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/repository"
|
||||||
|
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
|
||||||
|
"context"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProductUseCaseParam struct {
|
||||||
|
ProductRepo repository.ProductRepository
|
||||||
|
TagRepo repository.TagRepo
|
||||||
|
TagBinding repository.TagBindingRepo
|
||||||
|
ProductStatisticsRepo repository.ProductStatisticsRepo
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProductUseCase struct {
|
||||||
|
ProductUseCaseParam
|
||||||
|
}
|
||||||
|
|
||||||
|
func MustProductUseCase(param ProductUseCaseParam) usecase.ProductUseCase {
|
||||||
|
return &ProductUseCase{
|
||||||
|
param,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) Create(ctx context.Context, product *usecase.Product) error {
|
||||||
|
//use.ProductRepo.Transaction()
|
||||||
|
insert := &entity.Product{
|
||||||
|
UID: *product.UID,
|
||||||
|
Title: *product.Title,
|
||||||
|
ShortTitle: product.ShortTitle,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UID string `bson:"uid"` // 專案擁有者 UID
|
||||||
|
Title string `bson:"title"` // 專案名稱
|
||||||
|
ShortTitle *string `bson:"short_title,omitempty"` // 計畫簡短標題 -> 不一定要有
|
||||||
|
Details *string `bson:"details"` // 詳細內容
|
||||||
|
ShortDescription string `bson:"short_description,omitempty"` // 簡短描述
|
||||||
|
Media []Media `bson:"media,omitempty"` // 專案動態內容(圖片或者影片)
|
||||||
|
Slug *string `bson:"slug,omitempty"` // URL 後綴(查詢用)
|
||||||
|
IsPublished bool `bson:"is_published" ` // 是否已上架
|
||||||
|
Amount uint64 `bson:"amount,omitempty"` // 目標金額
|
||||||
|
StartTime *int64 `bson:"start_time,omitempty"` // 專案開始時間
|
||||||
|
EndTime *int64 `bson:"end_time,omitempty"` // 專案結束時間
|
||||||
|
Category string `bson:"category"` // 類別
|
||||||
|
CustomFields []CustomFields `bson:"custom_fields,omitempty"` // 自定義屬性
|
||||||
|
|
||||||
|
|
||||||
|
err := use.ProductRepo.Insert(ctx, insert)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) Update(ctx context.Context, id string, product *usecase.Product) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) Delete(ctx context.Context, id string) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) Get(ctx context.Context, id string) (*usecase.ProductResp, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) List(ctx context.Context, data usecase.ProductQueryParams) ([]*usecase.ProductResp, int64, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) IncOrders(ctx context.Context, productID string, count int64) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) DecOrders(ctx context.Context, productID string, count int64) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) UpdateAverageRating(ctx context.Context, productID string, averageRating float64) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) IncFansCount(ctx context.Context, productID string, fansCount uint64) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) DecFansCount(ctx context.Context, productID string, fansCount uint64) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) BindTag(ctx context.Context, binding usecase.TagsBindingTable) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) UnbindTag(ctx context.Context, binding usecase.TagsBindingTable) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) GetBindingsByReference(ctx context.Context, referenceID string) ([]usecase.TagsBindingTableResp, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (use *ProductUseCase) ListTagBinding(ctx context.Context, params usecase.TagBindingQueryParams) ([]usecase.TagsBindingTableResp, int64, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
Loading…
Reference in New Issue