feat: update service

This commit is contained in:
王性驊 2025-04-09 22:46:53 +08:00
parent 1a32f58515
commit 748d0c0725
46 changed files with 2507 additions and 1940 deletions

View File

@ -21,7 +21,7 @@ fmt: # 格式優化
.PHONY: gen-rpc
gen-rpc: # 建立 rpc code
goctl rpc protoc ./generate/protobuf/product.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
goctl rpc protoc ./generate/protobuf/product.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=. -m
go mod tidy
@echo "Generate core-api files successfully"

View File

@ -0,0 +1,104 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package category_service
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Category = product.Category
CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq
CreateKycReq = product.CreateKycReq
CreateProductItemRequest = product.CreateProductItemRequest
CreateTagsReq = product.CreateTagsReq
CustomField = product.CustomField
DeleteProductItemRequest = product.DeleteProductItemRequest
DeleteProductItemsByReferenceIDReq = product.DeleteProductItemsByReferenceIDReq
FindKycByIDReq = product.FindKycByIDReq
FindLatestKycByUIDReq = product.FindLatestKycByUIDReq
GetProductItemRequest = product.GetProductItemRequest
IncDecSalesCountRequest = product.IncDecSalesCountRequest
Kyc = product.Kyc
ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp
ListKycReq = product.ListKycReq
ListKycResp = product.ListKycResp
ListProductItemRequest = product.ListProductItemRequest
ListProductItemResponse = product.ListProductItemResponse
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
Media = product.Media
ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq
OKResp = product.OKResp
ProductItem = product.ProductItem
Tags = product.Tags
TagsReq = product.TagsReq
UpdateKycInfoReq = product.UpdateKycInfoReq
UpdateKycStatusReq = product.UpdateKycStatusReq
UpdateProductItemRequest = product.UpdateProductItemRequest
UpdateStatusRequest = product.UpdateStatusRequest
CategoryService interface {
// Create 建立 product 分類
Create(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// Modify 修改 product 分類名稱
Modify(ctx context.Context, in *ModifyCategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// Delete 刪除 product 分類
Delete(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// Get 取得 product 分類
Get(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error)
// List 建立 product 分類
List(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error)
}
defaultCategoryService struct {
cli zrpc.Client
}
)
func NewCategoryService(cli zrpc.Client) CategoryService {
return &defaultCategoryService{
cli: cli,
}
}
// Create 建立 product 分類
func (m *defaultCategoryService) Create(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewCategory_ServiceClient(m.cli.Conn())
return client.Create(ctx, in, opts...)
}
// Modify 修改 product 分類名稱
func (m *defaultCategoryService) Modify(ctx context.Context, in *ModifyCategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewCategory_ServiceClient(m.cli.Conn())
return client.Modify(ctx, in, opts...)
}
// Delete 刪除 product 分類
func (m *defaultCategoryService) Delete(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewCategory_ServiceClient(m.cli.Conn())
return client.Delete(ctx, in, opts...)
}
// Get 取得 product 分類
func (m *defaultCategoryService) Get(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error) {
client := product.NewCategory_ServiceClient(m.cli.Conn())
return client.Get(ctx, in, opts...)
}
// List 建立 product 分類
func (m *defaultCategoryService) List(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) {
client := product.NewCategory_ServiceClient(m.cli.Conn())
return client.List(ctx, in, opts...)
}

View File

@ -0,0 +1,112 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package kyc_service
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Category = product.Category
CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq
CreateKycReq = product.CreateKycReq
CreateProductItemRequest = product.CreateProductItemRequest
CreateTagsReq = product.CreateTagsReq
CustomField = product.CustomField
DeleteProductItemRequest = product.DeleteProductItemRequest
DeleteProductItemsByReferenceIDReq = product.DeleteProductItemsByReferenceIDReq
FindKycByIDReq = product.FindKycByIDReq
FindLatestKycByUIDReq = product.FindLatestKycByUIDReq
GetProductItemRequest = product.GetProductItemRequest
IncDecSalesCountRequest = product.IncDecSalesCountRequest
Kyc = product.Kyc
ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp
ListKycReq = product.ListKycReq
ListKycResp = product.ListKycResp
ListProductItemRequest = product.ListProductItemRequest
ListProductItemResponse = product.ListProductItemResponse
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
Media = product.Media
ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq
OKResp = product.OKResp
ProductItem = product.ProductItem
Tags = product.Tags
TagsReq = product.TagsReq
UpdateKycInfoReq = product.UpdateKycInfoReq
UpdateKycStatusReq = product.UpdateKycStatusReq
UpdateProductItemRequest = product.UpdateProductItemRequest
UpdateStatusRequest = product.UpdateStatusRequest
KycService interface {
// Create 建立 KYC 資料
Create(ctx context.Context, in *CreateKycReq, opts ...grpc.CallOption) (*OKResp, error)
// FindLatestByUID 根據使用者 UID 查詢最新 KYC 紀錄
FindLatestByUid(ctx context.Context, in *FindLatestKycByUIDReq, opts ...grpc.CallOption) (*Kyc, error)
// FindByID 根據 KYC ID 查詢
FindById(ctx context.Context, in *FindKycByIDReq, opts ...grpc.CallOption) (*Kyc, error)
// List 分頁查詢 Kyc 清單(後台審核用)
List(ctx context.Context, in *ListKycReq, opts ...grpc.CallOption) (*ListKycResp, error)
// UpdateStatus 更新 Kyc 審核狀態與原因
UpdateStatus(ctx context.Context, in *UpdateKycStatusReq, opts ...grpc.CallOption) (*OKResp, error)
// Update 更新使用者的 Kyc尚未審核
Update(ctx context.Context, in *UpdateKycInfoReq, opts ...grpc.CallOption) (*OKResp, error)
}
defaultKycService struct {
cli zrpc.Client
}
)
func NewKycService(cli zrpc.Client) KycService {
return &defaultKycService{
cli: cli,
}
}
// Create 建立 KYC 資料
func (m *defaultKycService) Create(ctx context.Context, in *CreateKycReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.Create(ctx, in, opts...)
}
// FindLatestByUID 根據使用者 UID 查詢最新 KYC 紀錄
func (m *defaultKycService) FindLatestByUid(ctx context.Context, in *FindLatestKycByUIDReq, opts ...grpc.CallOption) (*Kyc, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.FindLatestByUid(ctx, in, opts...)
}
// FindByID 根據 KYC ID 查詢
func (m *defaultKycService) FindById(ctx context.Context, in *FindKycByIDReq, opts ...grpc.CallOption) (*Kyc, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.FindById(ctx, in, opts...)
}
// List 分頁查詢 Kyc 清單(後台審核用)
func (m *defaultKycService) List(ctx context.Context, in *ListKycReq, opts ...grpc.CallOption) (*ListKycResp, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.List(ctx, in, opts...)
}
// UpdateStatus 更新 Kyc 審核狀態與原因
func (m *defaultKycService) UpdateStatus(ctx context.Context, in *UpdateKycStatusReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.UpdateStatus(ctx, in, opts...)
}
// Update 更新使用者的 Kyc尚未審核
func (m *defaultKycService) Update(ctx context.Context, in *UpdateKycInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewKyc_ServiceClient(m.cli.Conn())
return client.Update(ctx, in, opts...)
}

View File

@ -1,264 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package product
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Category = product.Category
CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq
CreateKYCReq = product.CreateKYCReq
CreateProductItemRequest = product.CreateProductItemRequest
CreateTagsReq = product.CreateTagsReq
CustomField = product.CustomField
DeleteProductItemRequest = product.DeleteProductItemRequest
DeleteProductItemsByReferenceIDReq = product.DeleteProductItemsByReferenceIDReq
FindKYCByIDReq = product.FindKYCByIDReq
FindLatestKYCByUIDReq = product.FindLatestKYCByUIDReq
GetProductItemRequest = product.GetProductItemRequest
IncDecSalesCountRequest = product.IncDecSalesCountRequest
KYC = product.KYC
ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp
ListKYCReq = product.ListKYCReq
ListKYCResp = product.ListKYCResp
ListProductItemRequest = product.ListProductItemRequest
ListProductItemResponse = product.ListProductItemResponse
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
Media = product.Media
ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq
OKResp = product.OKResp
ProductItem = product.ProductItem
Tags = product.Tags
TagsReq = product.TagsReq
UpdateKYCInfoReq = product.UpdateKYCInfoReq
UpdateKYCStatusReq = product.UpdateKYCStatusReq
UpdateProductItemRequest = product.UpdateProductItemRequest
UpdateStatusRequest = product.UpdateStatusRequest
Product interface {
// ====================== Category Service Start ======================
CreateCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// ModifyCategory 修改 product 分類名稱
ModifyCategory(ctx context.Context, in *ModifyCategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// DeleteCategory 刪除 product 分類
DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// GetCategory 取得 product 分類
GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error)
// ListCategory 建立 product 分類
ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error)
// ====================== Category Service End ======================
CreateTags(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*OKResp, error)
// ModifyTags 修改 tags
ModifyTags(ctx context.Context, in *ModifyTagsReq, opts ...grpc.CallOption) (*OKResp, error)
// DeleteTags 刪除tags
DeleteTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*OKResp, error)
// GetTags 取得 tags
GetTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*Tags, error)
// ListTags 建立 tags
ListTags(ctx context.Context, in *ListTagsReq, opts ...grpc.CallOption) (*ListTagsResp, error)
// ====================== Tags Service End ======================
CreateKYC(ctx context.Context, in *CreateKYCReq, opts ...grpc.CallOption) (*OKResp, error)
// FindLatestKYCByUID 根據使用者 UID 查詢最新 KYC 紀錄
FindLatestKYCByUID(ctx context.Context, in *FindLatestKYCByUIDReq, opts ...grpc.CallOption) (*KYC, error)
// FindKYCByID 根據 KYC ID 查詢
FindKYCByID(ctx context.Context, in *FindKYCByIDReq, opts ...grpc.CallOption) (*KYC, error)
// ListKYC 分頁查詢 KYC 清單(後台審核用)
ListKYC(ctx context.Context, in *ListKYCReq, opts ...grpc.CallOption) (*ListKYCResp, error)
// UpdateKYCStatus 更新 KYC 審核狀態與原因
UpdateKYCStatus(ctx context.Context, in *UpdateKYCStatusReq, opts ...grpc.CallOption) (*OKResp, error)
// UpdateKYCInfo 更新使用者的 KYC尚未審核
UpdateKYCInfo(ctx context.Context, in *UpdateKYCInfoReq, opts ...grpc.CallOption) (*OKResp, error)
// ====================== Know You Customer Service End ======================
CreateItem(ctx context.Context, in *CreateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// GetProductItem 取得 ProductItem
GetProductItem(ctx context.Context, in *GetProductItemRequest, opts ...grpc.CallOption) (*ProductItem, error)
// GetProductItemsByProductID 使用 ProductID 取得 ProductItems
GetProductItemsByProductID(ctx context.Context, in *ListProductItemRequest, opts ...grpc.CallOption) (*ListProductItemResponse, error)
// DeleteProductItems 刪除 Delete Product Item
DeleteProductItems(ctx context.Context, in *DeleteProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// DeleteProductItemsByReferenceID 使用 ProductID 刪除所有 Item
DeleteProductItemsByReferenceID(ctx context.Context, in *DeleteProductItemsByReferenceIDReq, opts ...grpc.CallOption) (*OKResp, error)
// IncSalesCount 增加賣出數量
IncSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error)
// DecSalesCount 減少賣出數量
DecSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error)
// Update 更新 Item
Update(ctx context.Context, in *UpdateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// UpdateStatus 更新 Item status
UpdateStatus(ctx context.Context, in *UpdateStatusRequest, opts ...grpc.CallOption) (*OKResp, error)
}
defaultProduct struct {
cli zrpc.Client
}
)
func NewProduct(cli zrpc.Client) Product {
return &defaultProduct{
cli: cli,
}
}
// ====================== Category Service Start ======================
func (m *defaultProduct) CreateCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.CreateCategory(ctx, in, opts...)
}
// ModifyCategory 修改 product 分類名稱
func (m *defaultProduct) ModifyCategory(ctx context.Context, in *ModifyCategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.ModifyCategory(ctx, in, opts...)
}
// DeleteCategory 刪除 product 分類
func (m *defaultProduct) DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.DeleteCategory(ctx, in, opts...)
}
// GetCategory 取得 product 分類
func (m *defaultProduct) GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error) {
client := product.NewProductClient(m.cli.Conn())
return client.GetCategory(ctx, in, opts...)
}
// ListCategory 建立 product 分類
func (m *defaultProduct) ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.ListCategory(ctx, in, opts...)
}
// ====================== Category Service End ======================
func (m *defaultProduct) CreateTags(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.CreateTags(ctx, in, opts...)
}
// ModifyTags 修改 tags
func (m *defaultProduct) ModifyTags(ctx context.Context, in *ModifyTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.ModifyTags(ctx, in, opts...)
}
// DeleteTags 刪除tags
func (m *defaultProduct) DeleteTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.DeleteTags(ctx, in, opts...)
}
// GetTags 取得 tags
func (m *defaultProduct) GetTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*Tags, error) {
client := product.NewProductClient(m.cli.Conn())
return client.GetTags(ctx, in, opts...)
}
// ListTags 建立 tags
func (m *defaultProduct) ListTags(ctx context.Context, in *ListTagsReq, opts ...grpc.CallOption) (*ListTagsResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.ListTags(ctx, in, opts...)
}
// ====================== Tags Service End ======================
func (m *defaultProduct) CreateKYC(ctx context.Context, in *CreateKYCReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.CreateKYC(ctx, in, opts...)
}
// FindLatestKYCByUID 根據使用者 UID 查詢最新 KYC 紀錄
func (m *defaultProduct) FindLatestKYCByUID(ctx context.Context, in *FindLatestKYCByUIDReq, opts ...grpc.CallOption) (*KYC, error) {
client := product.NewProductClient(m.cli.Conn())
return client.FindLatestKYCByUID(ctx, in, opts...)
}
// FindKYCByID 根據 KYC ID 查詢
func (m *defaultProduct) FindKYCByID(ctx context.Context, in *FindKYCByIDReq, opts ...grpc.CallOption) (*KYC, error) {
client := product.NewProductClient(m.cli.Conn())
return client.FindKYCByID(ctx, in, opts...)
}
// ListKYC 分頁查詢 KYC 清單(後台審核用)
func (m *defaultProduct) ListKYC(ctx context.Context, in *ListKYCReq, opts ...grpc.CallOption) (*ListKYCResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.ListKYC(ctx, in, opts...)
}
// UpdateKYCStatus 更新 KYC 審核狀態與原因
func (m *defaultProduct) UpdateKYCStatus(ctx context.Context, in *UpdateKYCStatusReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.UpdateKYCStatus(ctx, in, opts...)
}
// UpdateKYCInfo 更新使用者的 KYC尚未審核
func (m *defaultProduct) UpdateKYCInfo(ctx context.Context, in *UpdateKYCInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.UpdateKYCInfo(ctx, in, opts...)
}
// ====================== Know You Customer Service End ======================
func (m *defaultProduct) CreateItem(ctx context.Context, in *CreateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.CreateItem(ctx, in, opts...)
}
// GetProductItem 取得 ProductItem
func (m *defaultProduct) GetProductItem(ctx context.Context, in *GetProductItemRequest, opts ...grpc.CallOption) (*ProductItem, error) {
client := product.NewProductClient(m.cli.Conn())
return client.GetProductItem(ctx, in, opts...)
}
// GetProductItemsByProductID 使用 ProductID 取得 ProductItems
func (m *defaultProduct) GetProductItemsByProductID(ctx context.Context, in *ListProductItemRequest, opts ...grpc.CallOption) (*ListProductItemResponse, error) {
client := product.NewProductClient(m.cli.Conn())
return client.GetProductItemsByProductID(ctx, in, opts...)
}
// DeleteProductItems 刪除 Delete Product Item
func (m *defaultProduct) DeleteProductItems(ctx context.Context, in *DeleteProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.DeleteProductItems(ctx, in, opts...)
}
// DeleteProductItemsByReferenceID 使用 ProductID 刪除所有 Item
func (m *defaultProduct) DeleteProductItemsByReferenceID(ctx context.Context, in *DeleteProductItemsByReferenceIDReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.DeleteProductItemsByReferenceID(ctx, in, opts...)
}
// IncSalesCount 增加賣出數量
func (m *defaultProduct) IncSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.IncSalesCount(ctx, in, opts...)
}
// DecSalesCount 減少賣出數量
func (m *defaultProduct) DecSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.DecSalesCount(ctx, in, opts...)
}
// Update 更新 Item
func (m *defaultProduct) Update(ctx context.Context, in *UpdateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.Update(ctx, in, opts...)
}
// UpdateStatus 更新 Item status
func (m *defaultProduct) UpdateStatus(ctx context.Context, in *UpdateStatusRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProductClient(m.cli.Conn())
return client.UpdateStatus(ctx, in, opts...)
}

View File

@ -0,0 +1,136 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package product_item_service
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Category = product.Category
CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq
CreateKycReq = product.CreateKycReq
CreateProductItemRequest = product.CreateProductItemRequest
CreateTagsReq = product.CreateTagsReq
CustomField = product.CustomField
DeleteProductItemRequest = product.DeleteProductItemRequest
DeleteProductItemsByReferenceIDReq = product.DeleteProductItemsByReferenceIDReq
FindKycByIDReq = product.FindKycByIDReq
FindLatestKycByUIDReq = product.FindLatestKycByUIDReq
GetProductItemRequest = product.GetProductItemRequest
IncDecSalesCountRequest = product.IncDecSalesCountRequest
Kyc = product.Kyc
ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp
ListKycReq = product.ListKycReq
ListKycResp = product.ListKycResp
ListProductItemRequest = product.ListProductItemRequest
ListProductItemResponse = product.ListProductItemResponse
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
Media = product.Media
ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq
OKResp = product.OKResp
ProductItem = product.ProductItem
Tags = product.Tags
TagsReq = product.TagsReq
UpdateKycInfoReq = product.UpdateKycInfoReq
UpdateKycStatusReq = product.UpdateKycStatusReq
UpdateProductItemRequest = product.UpdateProductItemRequest
UpdateStatusRequest = product.UpdateStatusRequest
ProductItemService interface {
// Create 建立 ProductItem
Create(ctx context.Context, in *CreateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// GetProductItem 取得 ProductItem
Get(ctx context.Context, in *GetProductItemRequest, opts ...grpc.CallOption) (*ProductItem, error)
// ListByProductId 使用 ProductID 取得 ProductItems
ListByProductId(ctx context.Context, in *ListProductItemRequest, opts ...grpc.CallOption) (*ListProductItemResponse, error)
// Delete 刪除 Delete Product Item
Delete(ctx context.Context, in *DeleteProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// DeleteByReferenceId 使用 ProductID 刪除所有 Item
DeleteByReferenceId(ctx context.Context, in *DeleteProductItemsByReferenceIDReq, opts ...grpc.CallOption) (*OKResp, error)
// IncSalesCount 增加賣出數量
IncSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error)
// DecSalesCount 減少賣出數量
DecSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error)
// Update 更新 Item
Update(ctx context.Context, in *UpdateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error)
// UpdateStatus 更新 Item status
UpdateStatus(ctx context.Context, in *UpdateStatusRequest, opts ...grpc.CallOption) (*OKResp, error)
}
defaultProductItemService struct {
cli zrpc.Client
}
)
func NewProductItemService(cli zrpc.Client) ProductItemService {
return &defaultProductItemService{
cli: cli,
}
}
// Create 建立 ProductItem
func (m *defaultProductItemService) Create(ctx context.Context, in *CreateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.Create(ctx, in, opts...)
}
// GetProductItem 取得 ProductItem
func (m *defaultProductItemService) Get(ctx context.Context, in *GetProductItemRequest, opts ...grpc.CallOption) (*ProductItem, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.Get(ctx, in, opts...)
}
// ListByProductId 使用 ProductID 取得 ProductItems
func (m *defaultProductItemService) ListByProductId(ctx context.Context, in *ListProductItemRequest, opts ...grpc.CallOption) (*ListProductItemResponse, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.ListByProductId(ctx, in, opts...)
}
// Delete 刪除 Delete Product Item
func (m *defaultProductItemService) Delete(ctx context.Context, in *DeleteProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.Delete(ctx, in, opts...)
}
// DeleteByReferenceId 使用 ProductID 刪除所有 Item
func (m *defaultProductItemService) DeleteByReferenceId(ctx context.Context, in *DeleteProductItemsByReferenceIDReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.DeleteByReferenceId(ctx, in, opts...)
}
// IncSalesCount 增加賣出數量
func (m *defaultProductItemService) IncSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.IncSalesCount(ctx, in, opts...)
}
// DecSalesCount 減少賣出數量
func (m *defaultProductItemService) DecSalesCount(ctx context.Context, in *IncDecSalesCountRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.DecSalesCount(ctx, in, opts...)
}
// Update 更新 Item
func (m *defaultProductItemService) Update(ctx context.Context, in *UpdateProductItemRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.Update(ctx, in, opts...)
}
// UpdateStatus 更新 Item status
func (m *defaultProductItemService) UpdateStatus(ctx context.Context, in *UpdateStatusRequest, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewProduct_Item_ServiceClient(m.cli.Conn())
return client.UpdateStatus(ctx, in, opts...)
}

View File

@ -0,0 +1,104 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package tag_service
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Category = product.Category
CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq
CreateKycReq = product.CreateKycReq
CreateProductItemRequest = product.CreateProductItemRequest
CreateTagsReq = product.CreateTagsReq
CustomField = product.CustomField
DeleteProductItemRequest = product.DeleteProductItemRequest
DeleteProductItemsByReferenceIDReq = product.DeleteProductItemsByReferenceIDReq
FindKycByIDReq = product.FindKycByIDReq
FindLatestKycByUIDReq = product.FindLatestKycByUIDReq
GetProductItemRequest = product.GetProductItemRequest
IncDecSalesCountRequest = product.IncDecSalesCountRequest
Kyc = product.Kyc
ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp
ListKycReq = product.ListKycReq
ListKycResp = product.ListKycResp
ListProductItemRequest = product.ListProductItemRequest
ListProductItemResponse = product.ListProductItemResponse
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
Media = product.Media
ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq
OKResp = product.OKResp
ProductItem = product.ProductItem
Tags = product.Tags
TagsReq = product.TagsReq
UpdateKycInfoReq = product.UpdateKycInfoReq
UpdateKycStatusReq = product.UpdateKycStatusReq
UpdateProductItemRequest = product.UpdateProductItemRequest
UpdateStatusRequest = product.UpdateStatusRequest
TagService interface {
// CreateTags 建立 tags
Create(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*OKResp, error)
// ModifyTags 修改 tags
Modify(ctx context.Context, in *ModifyTagsReq, opts ...grpc.CallOption) (*OKResp, error)
// DeleteTags 刪除tags
Delete(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*OKResp, error)
// GetTags 取得 tags
Get(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*Tags, error)
// ListTags 建立 tags
List(ctx context.Context, in *ListTagsReq, opts ...grpc.CallOption) (*ListTagsResp, error)
}
defaultTagService struct {
cli zrpc.Client
}
)
func NewTagService(cli zrpc.Client) TagService {
return &defaultTagService{
cli: cli,
}
}
// CreateTags 建立 tags
func (m *defaultTagService) Create(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewTag_ServiceClient(m.cli.Conn())
return client.Create(ctx, in, opts...)
}
// ModifyTags 修改 tags
func (m *defaultTagService) Modify(ctx context.Context, in *ModifyTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewTag_ServiceClient(m.cli.Conn())
return client.Modify(ctx, in, opts...)
}
// DeleteTags 刪除tags
func (m *defaultTagService) Delete(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*OKResp, error) {
client := product.NewTag_ServiceClient(m.cli.Conn())
return client.Delete(ctx, in, opts...)
}
// GetTags 取得 tags
func (m *defaultTagService) Get(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*Tags, error) {
client := product.NewTag_ServiceClient(m.cli.Conn())
return client.Get(ctx, in, opts...)
}
// ListTags 建立 tags
func (m *defaultTagService) List(ctx context.Context, in *ListTagsReq, opts ...grpc.CallOption) (*ListTagsResp, error) {
client := product.NewTag_ServiceClient(m.cli.Conn())
return client.List(ctx, in, opts...)
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ message OKResp {}
// NoneReq
message NoneReq {}
// ====================== Category Param ======================
// ====================== Category ======================
message CreateCategoryReq {
string name = 1;
}
@ -41,20 +41,35 @@ message ListCategoryResp {
repeated Category data=3;
}
service Category_Service {
// Create product
rpc Create(CreateCategoryReq) returns(OKResp);
// Modify product
rpc Modify(ModifyCategoryReq) returns(OKResp);
// Delete product
rpc Delete(CategoryReq) returns(OKResp);
// Get product
rpc Get(CategoryReq) returns(Category);
// List product
rpc List(ListCategoryReq) returns(ListCategoryResp);
}
// ====================== Tags Param ======================
message CreateTagsReq{
int32 types=1;
string types=1;
string name=2;
int64 show_type=3;
string show_type=3;
optional string cover=4;
}
message ModifyTagsReq{
string id=1;
optional int32 types=2;
optional string types=2;
optional string name=3;
optional int64 show_type=4;
optional string show_type=4;
optional string cover=5;
}
@ -64,9 +79,9 @@ message TagsReq {
message Tags{
string id=1;
int32 types=2;
string types=2;
string name=3;
int64 show_type=4;
string show_type=4;
string cover=5;
int64 update_at=6;
int64 created_at=7;
@ -77,8 +92,8 @@ message ListTagsReq {
int64 page_size =2;
repeated string ids=3;
optional string name=4;
optional int32 types=5;
optional int64 show_type=6;
optional string types=5;
optional string show_type=6;
}
message ListTagsResp {
@ -86,8 +101,21 @@ message ListTagsResp {
repeated Tags data=3;
}
service Tag_Service {
// CreateTags tags
rpc Create(CreateTagsReq) returns(OKResp);
// ModifyTags tags
rpc Modify(ModifyTagsReq) returns(OKResp);
// DeleteTags tags
rpc Delete(TagsReq) returns(OKResp);
// GetTags tags
rpc Get(TagsReq) returns(Tags);
// ListTags tags
rpc List(ListTagsReq) returns(ListTagsResp);
}
// ====================== KYC Param ======================
message KYC {
message Kyc {
string id = 1; // MongoDB ObjectID
string uid = 2; // UID
string country_region = 3; // "TW", "JP", "US"...
@ -110,7 +138,7 @@ message KYC {
int64 created_at = 20; // timestamp
}
message CreateKYCReq {
message CreateKycReq {
string uid = 1;
string country_region = 2;
string name = 3;
@ -128,15 +156,15 @@ message CreateKYCReq {
string bank_account = 15;
}
message FindLatestKYCByUIDReq {
message FindLatestKycByUIDReq {
string uid = 1;
}
message FindKYCByIDReq {
message FindKycByIDReq {
string id = 1;
}
message ListKYCReq {
message ListKycReq {
optional string uid = 1;
optional string country = 2;
optional string status = 3; // enum
@ -145,18 +173,18 @@ message ListKYCReq {
bool sort_by_date = 6;
}
message ListKYCResp {
repeated KYC list = 1;
message ListKycResp {
repeated Kyc list = 1;
int64 total = 2;
}
message UpdateKYCStatusReq {
message UpdateKycStatusReq {
string id = 1;
string status = 2; // enumPENDING, APPROVED, REJECTED
optional string reason = 3;
}
message UpdateKYCInfoReq {
message UpdateKycInfoReq {
string id = 1;
optional string name = 2;
@ -174,6 +202,20 @@ message UpdateKYCInfoReq {
optional string bank_account = 14;
}
service Kyc_Service{
// Create KYC
rpc Create (CreateKycReq) returns (OKResp);
// FindLatestByUID 使 UID KYC
rpc FindLatestByUid (FindLatestKycByUIDReq) returns (Kyc);
// FindByID KYC ID
rpc FindById (FindKycByIDReq) returns (Kyc);
// List Kyc
rpc List (ListKycReq) returns (ListKycResp);
// UpdateStatus Kyc
rpc UpdateStatus (UpdateKycStatusReq) returns (OKResp);
// Update 使 Kyc
rpc Update (UpdateKycInfoReq) returns (OKResp);
}
// ====================== Product Item Param ======================
message ProductItem {
@ -193,8 +235,8 @@ message ProductItem {
repeated CustomField freight = 14;
repeated CustomField custom_fields = 15;
uint64 sales_count = 16;
optional string updated_at = 17;
optional string created_at = 18;
optional int64 updated_at = 17;
optional int64 created_at = 18;
}
message Media {
@ -265,56 +307,17 @@ message UpdateStatusRequest {
}
service Product {
// ====================== Category Service Start ======================
// CreateCategory product
rpc CreateCategory(CreateCategoryReq) returns(OKResp);
// ModifyCategory product
rpc ModifyCategory(ModifyCategoryReq) returns(OKResp);
// DeleteCategory product
rpc DeleteCategory(CategoryReq) returns(OKResp);
// GetCategory product
rpc GetCategory(CategoryReq) returns(Category);
// ListCategory product
rpc ListCategory(ListCategoryReq) returns(ListCategoryResp);
// ====================== Category Service End ======================
// ====================== Tags Service Start ======================
// CreateTags tags
rpc CreateTags(CreateTagsReq) returns(OKResp);
// ModifyTags tags
rpc ModifyTags(ModifyTagsReq) returns(OKResp);
// DeleteTags tags
rpc DeleteTags(TagsReq) returns(OKResp);
// GetTags tags
rpc GetTags(TagsReq) returns(Tags);
// ListTags tags
rpc ListTags(ListTagsReq) returns(ListTagsResp);
// ====================== Tags Service End ======================
// ====================== Know You Customer Service Start ======================
// CreateKYC KYC
rpc CreateKYC (CreateKYCReq) returns (OKResp);
// FindLatestKYCByUID 使 UID KYC
rpc FindLatestKYCByUID (FindLatestKYCByUIDReq) returns (KYC);
// FindKYCByID KYC ID
rpc FindKYCByID (FindKYCByIDReq) returns (KYC);
// ListKYC KYC
rpc ListKYC (ListKYCReq) returns (ListKYCResp);
// UpdateKYCStatus KYC
rpc UpdateKYCStatus (UpdateKYCStatusReq) returns (OKResp);
// UpdateKYCInfo 使 KYC
rpc UpdateKYCInfo (UpdateKYCInfoReq) returns (OKResp);
// ====================== Know You Customer Service End ======================
// ====================== ProductItem Service Start ======================
// CreateItem ProductItem
rpc CreateItem(CreateProductItemRequest) returns (OKResp);
service Product_Item_Service {
// Create ProductItem
rpc Create(CreateProductItemRequest) returns (OKResp);
// GetProductItem ProductItem
rpc GetProductItem(GetProductItemRequest) returns (ProductItem);
// GetProductItemsByProductID 使 ProductID ProductItems
rpc GetProductItemsByProductID(ListProductItemRequest) returns (ListProductItemResponse);
// DeleteProductItems Delete Product Item
rpc DeleteProductItems(DeleteProductItemRequest) returns (OKResp);
// DeleteProductItemsByReferenceID 使 ProductID Item
rpc DeleteProductItemsByReferenceID(DeleteProductItemsByReferenceIDReq) returns (OKResp);
rpc Get(GetProductItemRequest) returns (ProductItem);
// ListByProductId 使 ProductID ProductItems
rpc ListByProductId(ListProductItemRequest) returns (ListProductItemResponse);
// Delete Delete Product Item
rpc Delete(DeleteProductItemRequest) returns (OKResp);
// DeleteByReferenceId 使 ProductID Item
rpc DeleteByReferenceId(DeleteProductItemsByReferenceIDReq) returns (OKResp);
// IncSalesCount
rpc IncSalesCount(IncDecSalesCountRequest) returns (OKResp);
// DecSalesCount
@ -323,5 +326,4 @@ service Product {
rpc Update(UpdateProductItemRequest) returns (OKResp);
// UpdateStatus Item status
rpc UpdateStatus(UpdateStatusRequest) returns (OKResp);
// ====================== ProductItem Service End ======================
}

View File

@ -1,4 +1,4 @@
package productlogic
package categoryservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
@ -10,22 +10,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type CreateCategoryLogic struct {
type CreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateCategoryLogic {
return &CreateCategoryLogic{
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// CreateCategory 建立 product 分類
func (l *CreateCategoryLogic) CreateCategory(in *product.CreateCategoryReq) (*product.OKResp, error) {
// Create 建立 product 分類
func (l *CreateLogic) Create(in *product.CreateCategoryReq) (*product.OKResp, error) {
err := l.svcCtx.CategoryUseCase.Insert(l.ctx, &entity.Category{
Name: in.GetName(),
})

View File

@ -1,4 +1,4 @@
package productlogic
package categoryservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteCategoryLogic struct {
type DeleteLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCategoryLogic {
return &DeleteCategoryLogic{
func NewDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLogic {
return &DeleteLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteCategory 刪除 product 分類
func (l *DeleteCategoryLogic) DeleteCategory(in *product.CategoryReq) (*product.OKResp, error) {
// Delete 刪除 product 分類
func (l *DeleteLogic) Delete(in *product.CategoryReq) (*product.OKResp, error) {
err := l.svcCtx.CategoryUseCase.Delete(l.ctx, in.GetId())
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package productlogic
package categoryservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type GetCategoryLogic struct {
type GetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCategoryLogic {
return &GetCategoryLogic{
func NewGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogic {
return &GetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetCategory 取得 product 分類
func (l *GetCategoryLogic) GetCategory(in *product.CategoryReq) (*product.Category, error) {
// Get 取得 product 分類
func (l *GetLogic) Get(in *product.CategoryReq) (*product.Category, error) {
category, err := l.svcCtx.CategoryUseCase.FindOneByID(l.ctx, in.GetId())
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package productlogic
package categoryservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
@ -10,22 +10,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type ListCategoryLogic struct {
type ListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCategoryLogic {
return &ListCategoryLogic{
func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
return &ListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListCategory 建立 product 分類
func (l *ListCategoryLogic) ListCategory(in *product.ListCategoryReq) (*product.ListCategoryResp, error) {
// List 建立 product 分類
func (l *ListLogic) List(in *product.ListCategoryReq) (*product.ListCategoryResp, error) {
q := usecase.CategoryQueryParams{
PageSize: in.GetPageSize(),
PageIndex: in.GetPageIndex(),
@ -35,18 +35,18 @@ func (l *ListCategoryLogic) ListCategory(in *product.ListCategoryReq) (*product.
q.ID = in.GetIds()
}
categorys, total, err := l.svcCtx.CategoryUseCase.ListCategory(l.ctx, q)
category, total, err := l.svcCtx.CategoryUseCase.ListCategory(l.ctx, q)
if err != nil {
return nil, err
}
res := make([]*product.Category, 0, len(categorys))
for _, category := range categorys {
res := make([]*product.Category, 0, len(category))
for _, c := range category {
res = append(res, &product.Category{
Id: category.ID.Hex(),
Name: category.Name,
CreateTime: category.CreatedAt,
UpdateTime: category.UpdatedAt,
Id: c.ID.Hex(),
Name: c.Name,
CreateTime: c.CreatedAt,
UpdateTime: c.UpdatedAt,
})
}

View File

@ -1,4 +1,4 @@
package productlogic
package categoryservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
@ -10,22 +10,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type ModifyCategoryLogic struct {
type ModifyLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewModifyCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyCategoryLogic {
return &ModifyCategoryLogic{
func NewModifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyLogic {
return &ModifyLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ModifyCategory 修改 product 分類名稱
func (l *ModifyCategoryLogic) ModifyCategory(in *product.ModifyCategoryReq) (*product.OKResp, error) {
// Modify 修改 product 分類名稱
func (l *ModifyLogic) Modify(in *product.ModifyCategoryReq) (*product.OKResp, error) {
err := l.svcCtx.CategoryUseCase.Update(l.ctx, in.GetId(), &entity.Category{Name: in.GetName()})
if err != nil {
return nil, err

View File

@ -1,30 +1,32 @@
package productlogic
package kycservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/kyc"
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateKYCLogic struct {
type CreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateKYCLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateKYCLogic {
return &CreateKYCLogic{
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateKYCLogic) CreateKYC(in *product.CreateKYCReq) (*product.OKResp, error) {
// Create 建立 KYC 資料
func (l *CreateLogic) Create(in *product.CreateKycReq) (*product.OKResp, error) {
err := l.svcCtx.KYCUseCase.Create(l.ctx, &entity.KYC{
UID: in.GetUid(),
CountryRegion: in.GetCountryRegion(),

View File

@ -1,4 +1,4 @@
package productlogic
package kycservicelogic
import (
"context"
@ -9,28 +9,28 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type FindKYCByIDLogic struct {
type FindByIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewFindKYCByIDLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindKYCByIDLogic {
return &FindKYCByIDLogic{
func NewFindByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindByIdLogic {
return &FindByIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// FindKYCByID 根據 KYC ID 查詢
func (l *FindKYCByIDLogic) FindKYCByID(in *product.FindKYCByIDReq) (*product.KYC, error) {
// FindById 根據 KYC ID 查詢
func (l *FindByIdLogic) FindById(in *product.FindKycByIDReq) (*product.Kyc, error) {
kycInfo, err := l.svcCtx.KYCUseCase.FindByID(l.ctx, in.GetId())
if err != nil {
return nil, err
}
return &product.KYC{
return &product.Kyc{
Id: kycInfo.ID.Hex(),
Uid: kycInfo.UID,
CountryRegion: kycInfo.CountryRegion,

View File

@ -1,4 +1,4 @@
package productlogic
package kycservicelogic
import (
"context"
@ -9,28 +9,28 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type FindLatestKYCByUIDLogic struct {
type FindLatestByUidLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewFindLatestKYCByUIDLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindLatestKYCByUIDLogic {
return &FindLatestKYCByUIDLogic{
func NewFindLatestByUidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindLatestByUidLogic {
return &FindLatestByUidLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// FindLatestKYCByUID 根據使用者 UID 查詢最新 KYC 紀錄
func (l *FindLatestKYCByUIDLogic) FindLatestKYCByUID(in *product.FindLatestKYCByUIDReq) (*product.KYC, error) {
// FindLatestByUid 根據使用者 UID 查詢最新 KYC 紀錄
func (l *FindLatestByUidLogic) FindLatestByUid(in *product.FindLatestKycByUIDReq) (*product.Kyc, error) {
kycInfo, err := l.svcCtx.KYCUseCase.FindLatestByUID(l.ctx, in.GetUid())
if err != nil {
return nil, err
}
return &product.KYC{
return &product.Kyc{
Id: kycInfo.ID.Hex(),
Uid: kycInfo.UID,
CountryRegion: kycInfo.CountryRegion,

View File

@ -1,4 +1,4 @@
package productlogic
package kycservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
@ -10,22 +10,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type ListKYCLogic struct {
type ListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListKYCLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListKYCLogic {
return &ListKYCLogic{
func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
return &ListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListKYC 分頁查詢 KYC 清單(後台審核用)
func (l *ListKYCLogic) ListKYC(in *product.ListKYCReq) (*product.ListKYCResp, error) {
// List 分頁查詢 Kyc 清單(後台審核用)
func (l *ListLogic) List(in *product.ListKycReq) (*product.ListKycResp, error) {
filter := usecase.KYCQueryParams{
UID: in.Uid,
Country: in.Country,
@ -39,9 +39,9 @@ func (l *ListKYCLogic) ListKYC(in *product.ListKYCReq) (*product.ListKYCResp, er
return nil, err
}
result := make([]*product.KYC, 0, len(list))
result := make([]*product.Kyc, 0, len(list))
for _, kycInfo := range list {
result = append(result, &product.KYC{
result = append(result, &product.Kyc{
Id: kycInfo.ID.Hex(),
Uid: kycInfo.UID,
CountryRegion: kycInfo.CountryRegion,
@ -65,7 +65,7 @@ func (l *ListKYCLogic) ListKYC(in *product.ListKYCReq) (*product.ListKYCResp, er
})
}
return &product.ListKYCResp{
return &product.ListKycResp{
Total: total,
List: result,
}, nil

View File

@ -1,4 +1,4 @@
package productlogic
package kycservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
@ -11,22 +11,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateKYCInfoLogic struct {
type UpdateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateKYCInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateKYCInfoLogic {
return &UpdateKYCInfoLogic{
func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
return &UpdateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// UpdateKYCInfo 更新使用者的 KYC(尚未審核)
func (l *UpdateKYCInfoLogic) UpdateKYCInfo(in *product.UpdateKYCInfoReq) (*product.OKResp, error) {
// Update 更新使用者的 Kyc(尚未審核)
func (l *UpdateLogic) Update(in *product.UpdateKycInfoReq) (*product.OKResp, error) {
// 如果已完成應該不能
err := l.svcCtx.KYCUseCase.UpdateKYCInfo(l.ctx, in.GetId(), &usecase.KYCUpdateParams{
Name: proto.String(in.GetName()),

View File

@ -1,4 +1,4 @@
package productlogic
package kycservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateKYCStatusLogic struct {
type UpdateStatusLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateKYCStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateKYCStatusLogic {
return &UpdateKYCStatusLogic{
func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
return &UpdateStatusLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// UpdateKYCStatus 更新 KYC 審核狀態與原因
func (l *UpdateKYCStatusLogic) UpdateKYCStatus(in *product.UpdateKYCStatusReq) (*product.OKResp, error) {
// UpdateStatus 更新 Kyc 審核狀態與原因
func (l *UpdateStatusLogic) UpdateStatus(in *product.UpdateKycStatusReq) (*product.OKResp, error) {
err := l.svcCtx.KYCUseCase.UpdateStatus(l.ctx, in.GetId(), in.GetStatus(), in.GetReason())
if err != nil {
return nil, err

View File

@ -1,85 +0,0 @@
package productlogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"context"
"github.com/zeromicro/go-zero/core/logx"
)
type ListTagsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTagsLogic {
return &ListTagsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListTags 建立 tags
func (l *ListTagsLogic) ListTags(in *product.ListTagsReq) (*product.ListTagsResp, error) {
tags := make([]*entity.Tags, 0)
var err error
var total int64
if len(in.GetIds()) > 0 {
tags, err = l.svcCtx.TagsUseCase.GetByIDs(l.ctx, in.GetIds())
if err != nil {
return nil, err
}
total = int64(len(tags))
} else {
q := usecase.TagQueryParams{
PageSize: in.GetPageSize(),
PageIndex: in.GetPageIndex(),
}
if in.Name != nil {
q.Name = in.Name
}
if in.Types != nil {
t, err := safeItemType(*in.Types)
if err != nil {
return nil, err
}
q.Types = &t
}
if in.ShowType != nil {
st := domain.ShowType(*in.ShowType)
q.ShowType = &st
}
tags, total, err = l.svcCtx.TagsUseCase.List(l.ctx, q)
if err != nil {
return nil, err
}
}
result := make([]*product.Tags, 0, len(tags))
for _, tag := range tags {
r := &product.Tags{Id: tag.ID.Hex(),
Types: int32(tag.Types),
Name: tag.Name,
ShowType: int64(tag.ShowType),
UpdateAt: tag.UpdatedAt,
CreatedAt: tag.CreatedAt,
}
if tag.Cover != nil {
r.Cover = *tag.Cover
}
result = append(result, r)
}
return &product.ListTagsResp{
Total: total,
Data: result,
}, nil
}

View File

@ -1,37 +0,0 @@
package productlogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
return &UpdateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Update 更新 Item
func (l *UpdateLogic) Update(in *product.UpdateProductItemRequest) (*product.OKResp, error) {
update := &usecase.UpdateProductItems{}
err := l.svcCtx.ProductItemUseCase.Update(l.ctx, in.GetId(), update)
if err != nil {
return nil, err
}
return &product.OKResp{}, nil
}

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/internal/utils"
@ -13,21 +13,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type CreateItemLogic struct {
type CreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateItemLogic {
return &CreateItemLogic{
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateItemLogic) CreateItem(in *PB.CreateProductItemRequest) (*PB.OKResp, error) {
// Create 建立 ProductItem
func (l *CreateLogic) Create(in *PB.CreateProductItemRequest) (*PB.OKResp, error) {
insert := &usecase.ProductItems{
ReferenceID: in.GetItem().ReferenceId, // 對應的專案 ID
Name: in.GetItem().Name, // 名稱
@ -43,8 +44,9 @@ func (l *CreateItemLogic) CreateItem(in *PB.CreateProductItemRequest) (*PB.OKRes
if len(in.GetItem().Media) > 0 {
// 專案動態內容(圖片或者影片)
m := make([]usecase.Media, 0, len(in.GetItem().Media))
for _, item := range in.GetItem().Media {
for i, item := range in.GetItem().Media {
m = append(m, usecase.Media{
Sort: uint64(i),
URL: item.Url,
Type: item.Type,
})

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"context"

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteProductItemsByReferenceIDLogic struct {
type DeleteByReferenceIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteProductItemsByReferenceIDLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteProductItemsByReferenceIDLogic {
return &DeleteProductItemsByReferenceIDLogic{
func NewDeleteByReferenceIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteByReferenceIdLogic {
return &DeleteByReferenceIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteProductItemsByReferenceID 使用 ProductID 刪除所有 Item
func (l *DeleteProductItemsByReferenceIDLogic) DeleteProductItemsByReferenceID(in *product.DeleteProductItemsByReferenceIDReq) (*product.OKResp, error) {
// DeleteByReferenceId 使用 ProductID 刪除所有 Item
func (l *DeleteByReferenceIdLogic) DeleteByReferenceId(in *product.DeleteProductItemsByReferenceIDReq) (*product.OKResp, error) {
err := l.svcCtx.ProductItemUseCase.DeleteByReferenceID(l.ctx, in.GetId())
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteProductItemsLogic struct {
type DeleteLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteProductItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteProductItemsLogic {
return &DeleteProductItemsLogic{
func NewDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLogic {
return &DeleteLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteProductItems 刪除 Delete Product Item
func (l *DeleteProductItemsLogic) DeleteProductItems(in *product.DeleteProductItemRequest) (*product.OKResp, error) {
// Delete 刪除 Delete Product Item
func (l *DeleteLogic) Delete(in *product.DeleteProductItemRequest) (*product.OKResp, error) {
err := l.svcCtx.ProductItemUseCase.Delete(l.ctx, in.GetId())
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/internal/utils"
@ -11,22 +11,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type GetProductItemLogic struct {
type GetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetProductItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductItemLogic {
return &GetProductItemLogic{
func NewGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogic {
return &GetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetProductItem 取得 ProductItem
func (l *GetProductItemLogic) GetProductItem(in *product.GetProductItemRequest) (*product.ProductItem, error) {
// Get 取得 ProductItem
func (l *GetLogic) Get(in *product.GetProductItemRequest) (*product.ProductItem, error) {
item, err := l.svcCtx.ProductItemUseCase.Get(l.ctx, in.GetId())
if err != nil {
return nil, err
@ -46,8 +46,8 @@ func (l *GetProductItemLogic) GetProductItem(in *product.GetProductItemRequest)
TimeSeries: item.TimeSeries.ToString(),
SalesCount: item.SalesCount,
Status: item.Status.ToString(),
UpdatedAt: proto.String(item.UpdatedAt),
CreatedAt: proto.String(item.CreatedAt),
UpdatedAt: &item.UpdatedAt,
CreatedAt: &item.CreatedAt,
}
media := make([]*product.Media, 0, len(item.Media))
for _, pi := range item.Media {

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"context"

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/internal/utils"
@ -14,22 +14,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type GetProductItemsByProductIDLogic struct {
type ListByProductIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetProductItemsByProductIDLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductItemsByProductIDLogic {
return &GetProductItemsByProductIDLogic{
func NewListByProductIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListByProductIdLogic {
return &ListByProductIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetProductItemsByProductID 使用 ProductID 取得 ProductItems
func (l *GetProductItemsByProductIDLogic) GetProductItemsByProductID(in *PB.ListProductItemRequest) (*PB.ListProductItemResponse, error) {
// ListByProductId 使用 ProductID 取得 ProductItems
func (l *ListByProductIdLogic) ListByProductId(in *PB.ListProductItemRequest) (*PB.ListProductItemResponse, error) {
filter := usecase.QueryProductItemParam{
PageSize: in.GetPageSize(),
PageIndex: in.GetPageIndex(),
@ -70,8 +70,8 @@ func (l *GetProductItemsByProductIDLogic) GetProductItemsByProductID(in *PB.List
TimeSeries: item.TimeSeries.ToString(),
SalesCount: item.SalesCount,
Status: item.Status.ToString(),
UpdatedAt: proto.String(item.UpdatedAt),
CreatedAt: proto.String(item.CreatedAt),
UpdatedAt: &item.UpdatedAt,
CreatedAt: &item.CreatedAt,
}
media := make([]*PB.Media, 0, len(item.Media))

View File

@ -0,0 +1,88 @@
package productitemservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"code.30cm.net/digimon/library-go/errs"
"context"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
return &UpdateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Update 更新 Item
func (l *UpdateLogic) Update(in *product.UpdateProductItemRequest) (*product.OKResp, error) {
update := &usecase.UpdateProductItems{
Name: in.Name,
Description: in.Description,
ShortDescription: in.ShortDescription,
IsUnLimit: in.IsUnLimit,
IsFree: in.IsFree,
Stock: in.Stock,
Price: in.Price,
SKU: in.Sku,
}
if in.TimeSeries != nil {
ts, status := domain.StringToTimeSeries(in.GetTimeSeries())
if !status {
return nil, errs.InvalidFormat("timeSeries")
}
update.TimeSeries = &ts
}
if len(in.GetMedia()) > 0 {
// 專案動態內容(圖片或者影片)
m := make([]usecase.Media, 0, len(in.GetMedia()))
for _, item := range in.GetMedia() {
m = append(m, usecase.Media{
Sort: *item.Sort,
URL: item.Url,
Type: item.Type,
})
}
update.Media = m
}
if len(in.GetCustomFields()) > 0 {
// 自定義屬性
c := make([]usecase.CustomFields, 0, len(in.GetCustomFields()))
for _, cItem := range in.GetCustomFields() {
c = append(c, usecase.CustomFields{
Key: cItem.Key,
Value: cItem.Value,
})
}
update.CustomFields = c
}
if len(in.GetFreight()) > 0 {
// 運費
f := make([]usecase.CustomFields, 0, len(in.GetFreight()))
for _, fItem := range in.GetFreight() {
f = append(f, usecase.CustomFields{
Key: fItem.Key,
Value: fItem.Value,
})
}
update.Freight = f
}
err := l.svcCtx.ProductItemUseCase.Update(l.ctx, in.GetId(), update)
if err != nil {
return nil, err
}
return &product.OKResp{}, nil
}

View File

@ -1,4 +1,4 @@
package productlogic
package productitemservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"

View File

@ -1,59 +1,55 @@
package productlogic
package tagservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
domainProduct "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/library-go/errs"
"context"
"fmt"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateTagsLogic struct {
type CreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTagsLogic {
return &CreateTagsLogic{
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateTagsLogic) CreateTags(in *product.CreateTagsReq) (*product.OKResp, error) {
t, err := safeItemType(in.GetTypes())
if err != nil {
return nil, errs.InvalidFormat("failed to validate item type")
// Create 建立 tags
func (l *CreateLogic) Create(in *product.CreateTagsReq) (*product.OKResp, error) {
showType, status := domainProduct.StringToShowType(in.GetShowType())
if !status {
return nil, errs.InvalidFormat("failed to convert show types")
}
itemTypes, itemStatus := domainProduct.StringToItemType(in.GetTypes())
if !itemStatus {
return nil, errs.InvalidFormat("failed to convert types")
}
insert := &entity.Tags{
Types: t,
Types: itemTypes,
Name: in.GetName(),
ShowType: domainProduct.ShowType(in.GetShowType()),
ShowType: showType,
}
if in.Cover != nil {
insert.Cover = in.Cover
}
err = l.svcCtx.TagsUseCase.Create(l.ctx, insert)
err := l.svcCtx.TagsUseCase.Create(l.ctx, insert)
if err != nil {
return nil, err
}
return &product.OKResp{}, nil
}
func safeItemType(t int32) (domainProduct.ItemType, error) {
if t < -128 || t > 127 {
return 0, fmt.Errorf("invalid ItemType value: %d", t)
}
return domainProduct.ItemType(t), nil
}

View File

@ -1,4 +1,4 @@
package productlogic
package tagservicelogic
import (
"context"
@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteTagsLogic struct {
type DeleteLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTagsLogic {
return &DeleteTagsLogic{
func NewDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLogic {
return &DeleteLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTags 刪除tags
func (l *DeleteTagsLogic) DeleteTags(in *product.TagsReq) (*product.OKResp, error) {
// Delete 刪除tags
func (l *DeleteLogic) Delete(in *product.TagsReq) (*product.OKResp, error) {
err := l.svcCtx.TagsUseCase.Delete(l.ctx, in.GetId())
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package productlogic
package tagservicelogic
import (
"context"
@ -9,31 +9,31 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type GetTagsLogic struct {
type GetLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagsLogic {
return &GetTagsLogic{
func NewGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogic {
return &GetLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetTags 取得 tags
func (l *GetTagsLogic) GetTags(in *product.TagsReq) (*product.Tags, error) {
// Get 取得 tags
func (l *GetLogic) Get(in *product.TagsReq) (*product.Tags, error) {
tag, err := l.svcCtx.TagsUseCase.GetByID(l.ctx, in.GetId())
if err != nil {
return nil, err
}
result := &product.Tags{Id: tag.ID.Hex(),
Types: int32(tag.Types),
Types: tag.Types.ToString(),
Name: tag.Name,
ShowType: int64(tag.ShowType),
ShowType: tag.ShowType.ToString(),
UpdateAt: tag.UpdatedAt,
CreatedAt: tag.CreatedAt,
}

View File

@ -0,0 +1,91 @@
package tagservicelogic
import (
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity"
domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"code.30cm.net/digimon/library-go/errs"
"context"
"github.com/zeromicro/go-zero/core/logx"
)
type ListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
return &ListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListLogic) List(in *product.ListTagsReq) (*product.ListTagsResp, error) {
if len(in.GetIds()) > 0 {
tags, err := l.svcCtx.TagsUseCase.GetByIDs(l.ctx, in.GetIds())
if err != nil {
return nil, err
}
return buildTagResp(tags, int64(len(tags))), nil
}
// 查詢條件轉換
q := usecase.TagQueryParams{
PageSize: in.GetPageSize(),
PageIndex: in.GetPageIndex(),
}
if in.Name != nil {
q.Name = in.Name
}
if in.Types != nil {
itemTypes, ok := domain.StringToItemType(in.GetTypes())
if !ok {
return nil, errs.InvalidFormat("failed to convert types")
}
q.Types = &itemTypes
}
if in.ShowType != nil {
showType, ok := domain.StringToShowType(in.GetShowType())
if !ok {
return nil, errs.InvalidFormat("failed to convert show types")
}
q.ShowType = &showType
}
tags, total, err := l.svcCtx.TagsUseCase.List(l.ctx, q)
if err != nil {
return nil, err
}
return buildTagResp(tags, total), nil
}
func buildTagResp(tags []*entity.Tags, total int64) *product.ListTagsResp {
result := make([]*product.Tags, 0, len(tags))
for _, tag := range tags {
r := &product.Tags{
Id: tag.ID.Hex(),
Types: tag.Types.ToString(),
Name: tag.Name,
ShowType: tag.ShowType.ToString(),
UpdateAt: tag.UpdatedAt,
CreatedAt: tag.CreatedAt,
}
if tag.Cover != nil {
r.Cover = *tag.Cover
}
result = append(result, r)
}
return &product.ListTagsResp{
Total: total,
Data: result,
}
}

View File

@ -1,8 +1,9 @@
package productlogic
package tagservicelogic
import (
domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"code.30cm.net/digimon/library-go/errs"
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
@ -11,44 +12,42 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type ModifyTagsLogic struct {
type ModifyLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewModifyTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyTagsLogic {
return &ModifyTagsLogic{
func NewModifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyLogic {
return &ModifyLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ModifyTags 修改 tags
func (l *ModifyTagsLogic) ModifyTags(in *product.ModifyTagsReq) (*product.OKResp, error) {
// Modify 修改 tags
func (l *ModifyLogic) Modify(in *product.ModifyTagsReq) (*product.OKResp, error) {
var params usecase.TagModifyParams
// 處理 typesint32 → ItemType
if in.Types != nil {
t, err := safeItemType(*in.Types)
if err != nil {
return nil, err
itemTypes, ok := domain.StringToItemType(in.GetTypes())
if !ok {
return nil, errs.InvalidFormat("failed to convert types")
}
params.Types = &t
params.Types = &itemTypes
}
if in.ShowType != nil {
showType, ok := domain.StringToShowType(in.GetShowType())
if !ok {
return nil, errs.InvalidFormat("failed to convert show types")
}
params.ShowType = &showType
}
// 處理 name
if in.Name != nil {
params.Name = in.Name
}
// 處理 show_typeint64 → ShowType
if in.ShowType != nil {
st := domain.ShowType(*in.ShowType)
params.ShowType = &st
}
// 處理 cover
if in.Cover != nil {
params.Cover = in.Cover

View File

@ -0,0 +1,54 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package server
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/logic/category_service"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
)
type CategoryServiceServer struct {
svcCtx *svc.ServiceContext
product.UnimplementedCategory_ServiceServer
}
func NewCategoryServiceServer(svcCtx *svc.ServiceContext) *CategoryServiceServer {
return &CategoryServiceServer{
svcCtx: svcCtx,
}
}
// Create 建立 product 分類
func (s *CategoryServiceServer) Create(ctx context.Context, in *product.CreateCategoryReq) (*product.OKResp, error) {
l := categoryservicelogic.NewCreateLogic(ctx, s.svcCtx)
return l.Create(in)
}
// Modify 修改 product 分類名稱
func (s *CategoryServiceServer) Modify(ctx context.Context, in *product.ModifyCategoryReq) (*product.OKResp, error) {
l := categoryservicelogic.NewModifyLogic(ctx, s.svcCtx)
return l.Modify(in)
}
// Delete 刪除 product 分類
func (s *CategoryServiceServer) Delete(ctx context.Context, in *product.CategoryReq) (*product.OKResp, error) {
l := categoryservicelogic.NewDeleteLogic(ctx, s.svcCtx)
return l.Delete(in)
}
// Get 取得 product 分類
func (s *CategoryServiceServer) Get(ctx context.Context, in *product.CategoryReq) (*product.Category, error) {
l := categoryservicelogic.NewGetLogic(ctx, s.svcCtx)
return l.Get(in)
}
// List 建立 product 分類
func (s *CategoryServiceServer) List(ctx context.Context, in *product.ListCategoryReq) (*product.ListCategoryResp, error) {
l := categoryservicelogic.NewListLogic(ctx, s.svcCtx)
return l.List(in)
}

View File

@ -0,0 +1,60 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package server
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/logic/kyc_service"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
)
type KycServiceServer struct {
svcCtx *svc.ServiceContext
product.UnimplementedKyc_ServiceServer
}
func NewKycServiceServer(svcCtx *svc.ServiceContext) *KycServiceServer {
return &KycServiceServer{
svcCtx: svcCtx,
}
}
// Create 建立 KYC 資料
func (s *KycServiceServer) Create(ctx context.Context, in *product.CreateKycReq) (*product.OKResp, error) {
l := kycservicelogic.NewCreateLogic(ctx, s.svcCtx)
return l.Create(in)
}
// FindLatestByUID 根據使用者 UID 查詢最新 KYC 紀錄
func (s *KycServiceServer) FindLatestByUid(ctx context.Context, in *product.FindLatestKycByUIDReq) (*product.Kyc, error) {
l := kycservicelogic.NewFindLatestByUidLogic(ctx, s.svcCtx)
return l.FindLatestByUid(in)
}
// FindByID 根據 KYC ID 查詢
func (s *KycServiceServer) FindById(ctx context.Context, in *product.FindKycByIDReq) (*product.Kyc, error) {
l := kycservicelogic.NewFindByIdLogic(ctx, s.svcCtx)
return l.FindById(in)
}
// List 分頁查詢 Kyc 清單(後台審核用)
func (s *KycServiceServer) List(ctx context.Context, in *product.ListKycReq) (*product.ListKycResp, error) {
l := kycservicelogic.NewListLogic(ctx, s.svcCtx)
return l.List(in)
}
// UpdateStatus 更新 Kyc 審核狀態與原因
func (s *KycServiceServer) UpdateStatus(ctx context.Context, in *product.UpdateKycStatusReq) (*product.OKResp, error) {
l := kycservicelogic.NewUpdateStatusLogic(ctx, s.svcCtx)
return l.UpdateStatus(in)
}
// Update 更新使用者的 Kyc尚未審核
func (s *KycServiceServer) Update(ctx context.Context, in *product.UpdateKycInfoReq) (*product.OKResp, error) {
l := kycservicelogic.NewUpdateLogic(ctx, s.svcCtx)
return l.Update(in)
}

View File

@ -1,174 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package server
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/logic/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
)
type ProductServer struct {
svcCtx *svc.ServiceContext
product.UnimplementedProductServer
}
func NewProductServer(svcCtx *svc.ServiceContext) *ProductServer {
return &ProductServer{
svcCtx: svcCtx,
}
}
// ====================== Category Service Start ======================
func (s *ProductServer) CreateCategory(ctx context.Context, in *product.CreateCategoryReq) (*product.OKResp, error) {
l := productlogic.NewCreateCategoryLogic(ctx, s.svcCtx)
return l.CreateCategory(in)
}
// ModifyCategory 修改 product 分類名稱
func (s *ProductServer) ModifyCategory(ctx context.Context, in *product.ModifyCategoryReq) (*product.OKResp, error) {
l := productlogic.NewModifyCategoryLogic(ctx, s.svcCtx)
return l.ModifyCategory(in)
}
// DeleteCategory 刪除 product 分類
func (s *ProductServer) DeleteCategory(ctx context.Context, in *product.CategoryReq) (*product.OKResp, error) {
l := productlogic.NewDeleteCategoryLogic(ctx, s.svcCtx)
return l.DeleteCategory(in)
}
// GetCategory 取得 product 分類
func (s *ProductServer) GetCategory(ctx context.Context, in *product.CategoryReq) (*product.Category, error) {
l := productlogic.NewGetCategoryLogic(ctx, s.svcCtx)
return l.GetCategory(in)
}
// ListCategory 建立 product 分類
func (s *ProductServer) ListCategory(ctx context.Context, in *product.ListCategoryReq) (*product.ListCategoryResp, error) {
l := productlogic.NewListCategoryLogic(ctx, s.svcCtx)
return l.ListCategory(in)
}
// ====================== Category Service End ======================
func (s *ProductServer) CreateTags(ctx context.Context, in *product.CreateTagsReq) (*product.OKResp, error) {
l := productlogic.NewCreateTagsLogic(ctx, s.svcCtx)
return l.CreateTags(in)
}
// ModifyTags 修改 tags
func (s *ProductServer) ModifyTags(ctx context.Context, in *product.ModifyTagsReq) (*product.OKResp, error) {
l := productlogic.NewModifyTagsLogic(ctx, s.svcCtx)
return l.ModifyTags(in)
}
// DeleteTags 刪除tags
func (s *ProductServer) DeleteTags(ctx context.Context, in *product.TagsReq) (*product.OKResp, error) {
l := productlogic.NewDeleteTagsLogic(ctx, s.svcCtx)
return l.DeleteTags(in)
}
// GetTags 取得 tags
func (s *ProductServer) GetTags(ctx context.Context, in *product.TagsReq) (*product.Tags, error) {
l := productlogic.NewGetTagsLogic(ctx, s.svcCtx)
return l.GetTags(in)
}
// ListTags 建立 tags
func (s *ProductServer) ListTags(ctx context.Context, in *product.ListTagsReq) (*product.ListTagsResp, error) {
l := productlogic.NewListTagsLogic(ctx, s.svcCtx)
return l.ListTags(in)
}
// ====================== Tags Service End ======================
func (s *ProductServer) CreateKYC(ctx context.Context, in *product.CreateKYCReq) (*product.OKResp, error) {
l := productlogic.NewCreateKYCLogic(ctx, s.svcCtx)
return l.CreateKYC(in)
}
// FindLatestKYCByUID 根據使用者 UID 查詢最新 KYC 紀錄
func (s *ProductServer) FindLatestKYCByUID(ctx context.Context, in *product.FindLatestKYCByUIDReq) (*product.KYC, error) {
l := productlogic.NewFindLatestKYCByUIDLogic(ctx, s.svcCtx)
return l.FindLatestKYCByUID(in)
}
// FindKYCByID 根據 KYC ID 查詢
func (s *ProductServer) FindKYCByID(ctx context.Context, in *product.FindKYCByIDReq) (*product.KYC, error) {
l := productlogic.NewFindKYCByIDLogic(ctx, s.svcCtx)
return l.FindKYCByID(in)
}
// ListKYC 分頁查詢 KYC 清單(後台審核用)
func (s *ProductServer) ListKYC(ctx context.Context, in *product.ListKYCReq) (*product.ListKYCResp, error) {
l := productlogic.NewListKYCLogic(ctx, s.svcCtx)
return l.ListKYC(in)
}
// UpdateKYCStatus 更新 KYC 審核狀態與原因
func (s *ProductServer) UpdateKYCStatus(ctx context.Context, in *product.UpdateKYCStatusReq) (*product.OKResp, error) {
l := productlogic.NewUpdateKYCStatusLogic(ctx, s.svcCtx)
return l.UpdateKYCStatus(in)
}
// UpdateKYCInfo 更新使用者的 KYC尚未審核
func (s *ProductServer) UpdateKYCInfo(ctx context.Context, in *product.UpdateKYCInfoReq) (*product.OKResp, error) {
l := productlogic.NewUpdateKYCInfoLogic(ctx, s.svcCtx)
return l.UpdateKYCInfo(in)
}
// ====================== Know You Customer Service End ======================
func (s *ProductServer) CreateItem(ctx context.Context, in *product.CreateProductItemRequest) (*product.OKResp, error) {
l := productlogic.NewCreateItemLogic(ctx, s.svcCtx)
return l.CreateItem(in)
}
// GetProductItem 取得 ProductItem
func (s *ProductServer) GetProductItem(ctx context.Context, in *product.GetProductItemRequest) (*product.ProductItem, error) {
l := productlogic.NewGetProductItemLogic(ctx, s.svcCtx)
return l.GetProductItem(in)
}
// GetProductItemsByProductID 使用 ProductID 取得 ProductItems
func (s *ProductServer) GetProductItemsByProductID(ctx context.Context, in *product.ListProductItemRequest) (*product.ListProductItemResponse, error) {
l := productlogic.NewGetProductItemsByProductIDLogic(ctx, s.svcCtx)
return l.GetProductItemsByProductID(in)
}
// DeleteProductItems 刪除 Delete Product Item
func (s *ProductServer) DeleteProductItems(ctx context.Context, in *product.DeleteProductItemRequest) (*product.OKResp, error) {
l := productlogic.NewDeleteProductItemsLogic(ctx, s.svcCtx)
return l.DeleteProductItems(in)
}
// DeleteProductItemsByReferenceID 使用 ProductID 刪除所有 Item
func (s *ProductServer) DeleteProductItemsByReferenceID(ctx context.Context, in *product.DeleteProductItemsByReferenceIDReq) (*product.OKResp, error) {
l := productlogic.NewDeleteProductItemsByReferenceIDLogic(ctx, s.svcCtx)
return l.DeleteProductItemsByReferenceID(in)
}
// IncSalesCount 增加賣出數量
func (s *ProductServer) IncSalesCount(ctx context.Context, in *product.IncDecSalesCountRequest) (*product.OKResp, error) {
l := productlogic.NewIncSalesCountLogic(ctx, s.svcCtx)
return l.IncSalesCount(in)
}
// DecSalesCount 減少賣出數量
func (s *ProductServer) DecSalesCount(ctx context.Context, in *product.IncDecSalesCountRequest) (*product.OKResp, error) {
l := productlogic.NewDecSalesCountLogic(ctx, s.svcCtx)
return l.DecSalesCount(in)
}
// Update 更新 Item
func (s *ProductServer) Update(ctx context.Context, in *product.UpdateProductItemRequest) (*product.OKResp, error) {
l := productlogic.NewUpdateLogic(ctx, s.svcCtx)
return l.Update(in)
}
// UpdateStatus 更新 Item status
func (s *ProductServer) UpdateStatus(ctx context.Context, in *product.UpdateStatusRequest) (*product.OKResp, error) {
l := productlogic.NewUpdateStatusLogic(ctx, s.svcCtx)
return l.UpdateStatus(in)
}

View File

@ -0,0 +1,78 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package server
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/logic/product_item_service"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
)
type ProductItemServiceServer struct {
svcCtx *svc.ServiceContext
product.UnimplementedProduct_Item_ServiceServer
}
func NewProductItemServiceServer(svcCtx *svc.ServiceContext) *ProductItemServiceServer {
return &ProductItemServiceServer{
svcCtx: svcCtx,
}
}
// Create 建立 ProductItem
func (s *ProductItemServiceServer) Create(ctx context.Context, in *product.CreateProductItemRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewCreateLogic(ctx, s.svcCtx)
return l.Create(in)
}
// GetProductItem 取得 ProductItem
func (s *ProductItemServiceServer) Get(ctx context.Context, in *product.GetProductItemRequest) (*product.ProductItem, error) {
l := productitemservicelogic.NewGetLogic(ctx, s.svcCtx)
return l.Get(in)
}
// ListByProductId 使用 ProductID 取得 ProductItems
func (s *ProductItemServiceServer) ListByProductId(ctx context.Context, in *product.ListProductItemRequest) (*product.ListProductItemResponse, error) {
l := productitemservicelogic.NewListByProductIdLogic(ctx, s.svcCtx)
return l.ListByProductId(in)
}
// Delete 刪除 Delete Product Item
func (s *ProductItemServiceServer) Delete(ctx context.Context, in *product.DeleteProductItemRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewDeleteLogic(ctx, s.svcCtx)
return l.Delete(in)
}
// DeleteByReferenceId 使用 ProductID 刪除所有 Item
func (s *ProductItemServiceServer) DeleteByReferenceId(ctx context.Context, in *product.DeleteProductItemsByReferenceIDReq) (*product.OKResp, error) {
l := productitemservicelogic.NewDeleteByReferenceIdLogic(ctx, s.svcCtx)
return l.DeleteByReferenceId(in)
}
// IncSalesCount 增加賣出數量
func (s *ProductItemServiceServer) IncSalesCount(ctx context.Context, in *product.IncDecSalesCountRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewIncSalesCountLogic(ctx, s.svcCtx)
return l.IncSalesCount(in)
}
// DecSalesCount 減少賣出數量
func (s *ProductItemServiceServer) DecSalesCount(ctx context.Context, in *product.IncDecSalesCountRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewDecSalesCountLogic(ctx, s.svcCtx)
return l.DecSalesCount(in)
}
// Update 更新 Item
func (s *ProductItemServiceServer) Update(ctx context.Context, in *product.UpdateProductItemRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewUpdateLogic(ctx, s.svcCtx)
return l.Update(in)
}
// UpdateStatus 更新 Item status
func (s *ProductItemServiceServer) UpdateStatus(ctx context.Context, in *product.UpdateStatusRequest) (*product.OKResp, error) {
l := productitemservicelogic.NewUpdateStatusLogic(ctx, s.svcCtx)
return l.UpdateStatus(in)
}

View File

@ -0,0 +1,54 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.1
// Source: product.proto
package server
import (
"context"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/logic/tag_service"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
)
type TagServiceServer struct {
svcCtx *svc.ServiceContext
product.UnimplementedTag_ServiceServer
}
func NewTagServiceServer(svcCtx *svc.ServiceContext) *TagServiceServer {
return &TagServiceServer{
svcCtx: svcCtx,
}
}
// CreateTags 建立 tags
func (s *TagServiceServer) Create(ctx context.Context, in *product.CreateTagsReq) (*product.OKResp, error) {
l := tagservicelogic.NewCreateLogic(ctx, s.svcCtx)
return l.Create(in)
}
// ModifyTags 修改 tags
func (s *TagServiceServer) Modify(ctx context.Context, in *product.ModifyTagsReq) (*product.OKResp, error) {
l := tagservicelogic.NewModifyLogic(ctx, s.svcCtx)
return l.Modify(in)
}
// DeleteTags 刪除tags
func (s *TagServiceServer) Delete(ctx context.Context, in *product.TagsReq) (*product.OKResp, error) {
l := tagservicelogic.NewDeleteLogic(ctx, s.svcCtx)
return l.Delete(in)
}
// GetTags 取得 tags
func (s *TagServiceServer) Get(ctx context.Context, in *product.TagsReq) (*product.Tags, error) {
l := tagservicelogic.NewGetLogic(ctx, s.svcCtx)
return l.Get(in)
}
// ListTags 建立 tags
func (s *TagServiceServer) List(ctx context.Context, in *product.ListTagsReq) (*product.ListTagsResp, error) {
l := tagservicelogic.NewListLogic(ctx, s.svcCtx)
return l.List(in)
}

View File

@ -8,3 +8,41 @@ const (
ItemTypeSkill // 技能專用 tag
ItemTypeProduct // 專案用
)
func (t *ItemType) ToString() string {
s, _ := ItemTypeToString(*t)
return s
}
const (
ItemTypeUnknownStr = "unknown"
ItemTypeNormalStr = "normal"
ItemTypeSkillStr = "skill"
ItemTypeProductStr = "product"
)
var itemTypeToStringMap = map[ItemType]string{
ItemTypeUnknown: ItemTypeUnknownStr,
ItemTypeNormal: ItemTypeNormalStr,
ItemTypeSkill: ItemTypeSkillStr,
ItemTypeProduct: ItemTypeProductStr,
}
var stringToItemTypeMap = map[string]ItemType{
ItemTypeUnknownStr: ItemTypeUnknown,
ItemTypeNormalStr: ItemTypeNormal,
ItemTypeSkillStr: ItemTypeSkill,
ItemTypeProductStr: ItemTypeProduct,
}
// ItemTypeToString 將 ItemType 轉換為字串
func ItemTypeToString(it ItemType) (string, bool) {
str, ok := itemTypeToStringMap[it]
return str, ok
}
// StringToItemType 將字串轉換為 ItemType
func StringToItemType(str string) (ItemType, bool) {
it, ok := stringToItemTypeMap[str]
return it, ok
}

View File

@ -5,3 +5,32 @@ type ShowType int64
const (
ShowTypeNormal ShowType = iota // 沒有任何外匡
)
func (s *ShowType) ToString() string {
str, _ := ShowTypeToString(*s)
return str
}
const (
ShowTypeNormalStr = "normal"
)
var showTypeToStringMap = map[ShowType]string{
ShowTypeNormal: ShowTypeNormalStr,
}
var stringToShowTypeMap = map[string]ShowType{
ShowTypeNormalStr: ShowTypeNormal,
}
// ShowTypeToString 將 ShowType 轉換為字串
func ShowTypeToString(st ShowType) (string, bool) {
str, ok := showTypeToStringMap[st]
return str, ok
}
// StringToShowType 將字串轉換為 ShowType
func StringToShowType(str string) (ShowType, bool) {
st, ok := stringToShowTypeMap[str]
return st, ok
}

View File

@ -44,8 +44,8 @@ type ProductItems struct {
Freight []CustomFields `json:"freight,omitempty"` // 運費
CustomFields []CustomFields `json:"custom_fields,omitempty"` // 自定義屬性
SalesCount uint64 `json:"sales_count" ` // 已賣出數量(相反,減到零就不能在賣)
UpdatedAt string `json:"updated_at"` // 更新時間
CreatedAt string `json:"created_at"` // 創建時間
UpdatedAt int64 `json:"updated_at"` // 更新時間
CreatedAt int64 `json:"created_at"` // 創建時間
}
type UpdateProductItems struct {

View File

@ -8,7 +8,6 @@ import (
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/repository"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase"
"code.30cm.net/digimon/app-cloudep-product-service/pkg/utils"
"code.30cm.net/digimon/library-go/errs"
"github.com/shopspring/decimal"
"github.com/zeromicro/go-zero/core/logx"
@ -77,8 +76,8 @@ func fromEntity(e *entity.ProductItems) *usecase.ProductItems {
Freight: convertEntityCustomFields(e.Freight),
CustomFields: convertEntityCustomFields(e.CustomFields),
SalesCount: e.SalesCount,
UpdatedAt: utils.UnixToRfc3339(e.UpdatedAt),
CreatedAt: utils.UnixToRfc3339(e.CreatedAt),
UpdatedAt: e.UpdatedAt,
CreatedAt: e.CreatedAt,
}
}

View File

@ -2,12 +2,14 @@ package main
import (
"flag"
"github.com/zeromicro/go-zero/core/logx"
"fmt"
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
"code.30cm.net/digimon/app-cloudep-product-service/internal/config"
productServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/product"
category_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/category_service"
kyc_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/kyc_service"
product_item_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/product_item_service"
tag_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/tag_service"
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
@ -27,7 +29,10 @@ func main() {
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
product.RegisterProductServer(grpcServer, productServer.NewProductServer(ctx))
product.RegisterCategory_ServiceServer(grpcServer, category_serviceServer.NewCategoryServiceServer(ctx))
product.RegisterTag_ServiceServer(grpcServer, tag_serviceServer.NewTagServiceServer(ctx))
product.RegisterKyc_ServiceServer(grpcServer, kyc_serviceServer.NewKycServiceServer(ctx))
product.RegisterProduct_Item_ServiceServer(grpcServer, product_item_serviceServer.NewProductItemServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
@ -35,6 +40,6 @@ func main() {
})
defer s.Stop()
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}