134 lines
5.2 KiB
Go
134 lines
5.2 KiB
Go
package usecase
|
||
|
||
import (
|
||
"context"
|
||
|
||
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
|
||
)
|
||
|
||
type ProductUseCase interface {
|
||
Base
|
||
// IncOrders 新增訂單數
|
||
IncOrders(ctx context.Context, productID string, count int64) error
|
||
// DecOrders 減少訂單數。-> 退貨時專用
|
||
DecOrders(ctx context.Context, productID string, count int64) error
|
||
// UpdateAverageRating 只更新綜合評價及其更新時間
|
||
UpdateAverageRating(ctx context.Context, productID string, averageRating float64) error
|
||
// IncFansCount 新增粉絲數
|
||
IncFansCount(ctx context.Context, productID string, fansCount uint64) error
|
||
// DecFansCount 減少粉絲數。
|
||
DecFansCount(ctx context.Context, productID string, fansCount uint64) error
|
||
// BindTag 建立一筆 tag 與其他資料(例如專案)的綁定關係
|
||
BindTag(ctx context.Context, binding TagsBindingTable) error
|
||
// UnbindTag 刪除一筆綁定資料
|
||
UnbindTag(ctx context.Context, binding TagsBindingTable) error
|
||
// GetBindingsByReference 根據參照 ID 取得所有綁定資料
|
||
GetBindingsByReference(ctx context.Context, referenceID string) ([]TagsBindingTableResp, error)
|
||
// ListTagBinding 根據查詢條件取得 tag binding 的資料列表
|
||
ListTagBinding(ctx context.Context, params TagBindingQueryParams) ([]TagsBindingTableResp, int64, error)
|
||
}
|
||
type Base interface {
|
||
Create(ctx context.Context, product *Product) error
|
||
Update(ctx context.Context, id string, product *Product) error
|
||
Delete(ctx context.Context, id string) error
|
||
Get(ctx context.Context, id string) (*ProductResp, error)
|
||
List(ctx context.Context, data ProductQueryParams) ([]*ProductResp, int64, error)
|
||
}
|
||
|
||
type Product struct {
|
||
UID *string // 專案擁有者 UID
|
||
Title *string // 專案名稱
|
||
ShortTitle *string // 計畫簡短標題 -> 不一定要有
|
||
Details *string // 詳細內容
|
||
ShortDescription *string // 簡短描述
|
||
Media []Media // 專案動態內容(圖片或者影片)
|
||
Slug *string // URL 後綴(查詢用)
|
||
IsPublished *bool // 是否已上架
|
||
Amount uint64 // 目標金額
|
||
StartTime *string // 專案開始時間
|
||
EndTime *string // 專案結束時間
|
||
Category *string // 類別
|
||
CustomFields []CustomFields // 自定義屬性
|
||
Tags []string // 這個專案專屬的 tagID
|
||
}
|
||
|
||
type ProductResp struct {
|
||
ID string
|
||
UID string // 專案擁有者 UID
|
||
Title string // 專案名稱
|
||
ShortTitle string // 計畫簡短標題 -> 不一定要有
|
||
Details string // 詳細內容
|
||
ShortDescription string // 簡短描述
|
||
Media []Media // 專案動態內容(圖片或者影片)
|
||
Slug string // URL 後綴(查詢用)
|
||
IsPublished bool // 是否已上架
|
||
Amount uint64 // 目標金額
|
||
StartTime string // 專案開始時間
|
||
EndTime string // 專案結束時間
|
||
Category string // 類別
|
||
CustomFields []CustomFields // 自定義屬性
|
||
Tags []Tags // 這個專案專屬的 tagID
|
||
Orders uint64 // 總接單數
|
||
OrdersUpdateTime string // 更新總接單數的時間
|
||
AverageRating float64 // 綜合評價(如:4.5 顆星)
|
||
AverageRatingUpdateTime string // 更新評價的時間
|
||
FansCount uint64 // 追蹤數量
|
||
FansCountUpdateTime string // 更新追蹤的時間
|
||
UpdatedAt string // 更新時間
|
||
CreatedAt string // 建立時間
|
||
}
|
||
|
||
type Media struct {
|
||
Sort uint64
|
||
Type string
|
||
URL string
|
||
}
|
||
|
||
type CustomFields struct {
|
||
Key string `bson:"key"`
|
||
Value string `bson:"value"`
|
||
}
|
||
|
||
type ProductQueryParams struct {
|
||
UID *string // 專案擁有者 UID
|
||
IsPublished *bool // 是否已上架
|
||
Category *string // 類別
|
||
StartTime *int64 // 起始時間(Unix 時間戳)
|
||
EndTime *int64 // 結束時間(Unix 時間戳)
|
||
Slug *string // URL 後綴
|
||
|
||
PageIndex int64 // 頁碼
|
||
PageSize int64 // 每頁數量
|
||
}
|
||
|
||
type Tags struct {
|
||
ID string // 專案 ID
|
||
Types product.ItemType // Tag 類型
|
||
Name string // tag 名稱
|
||
ShowType product.ShowType // 顯示筐
|
||
Cover string // 封面圖片
|
||
UpdatedAt string // 更新時間
|
||
CreatedAt string // 創建時間
|
||
}
|
||
|
||
type TagsBindingTable struct {
|
||
ReferenceID string // 參照 id (可能為專案或其他的東西)
|
||
TagID string // tag id
|
||
}
|
||
|
||
type TagsBindingTableResp struct {
|
||
ID string
|
||
ReferenceID string // 參照 id (可能為專案或其他的東西)
|
||
TagID string // tag id
|
||
UpdatedAt string // 更新時間
|
||
CreatedAt string // 創建時間
|
||
}
|
||
|
||
// TagBindingQueryParams 為查詢 TagBindingTable 時的參數結構
|
||
type TagBindingQueryParams struct {
|
||
ReferenceID *string // 過濾參照 ID
|
||
TagID *string // 過濾 Tag ID
|
||
PageSize int64
|
||
PageIndex int64
|
||
}
|