feat: add tags api

This commit is contained in:
王性驊 2025-04-08 11:49:07 +08:00
parent ae920e4f77
commit a2729b95ca
11 changed files with 1212 additions and 46 deletions

View File

@ -17,11 +17,17 @@ type (
Category = product.Category Category = product.Category
CategoryReq = product.CategoryReq CategoryReq = product.CategoryReq
CreateCategoryReq = product.CreateCategoryReq CreateCategoryReq = product.CreateCategoryReq
CreateTagsReq = product.CreateTagsReq
ListCategoryReq = product.ListCategoryReq ListCategoryReq = product.ListCategoryReq
ListCategoryResp = product.ListCategoryResp ListCategoryResp = product.ListCategoryResp
ListTagsReq = product.ListTagsReq
ListTagsResp = product.ListTagsResp
ModifyCategoryReq = product.ModifyCategoryReq ModifyCategoryReq = product.ModifyCategoryReq
ModifyTagsReq = product.ModifyTagsReq
NoneReq = product.NoneReq NoneReq = product.NoneReq
OKResp = product.OKResp OKResp = product.OKResp
Tags = product.Tags
TagsReq = product.TagsReq
Product interface { Product interface {
// ====================== Category Service Start ====================== // ====================== Category Service Start ======================
@ -32,8 +38,18 @@ type (
DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error) DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// GetCategory 取得 product 分類 // GetCategory 取得 product 分類
GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error) GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error)
// CreateCategory 建立 product 分類 // ListCategory 建立 product 分類
ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) 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)
} }
defaultProduct struct { defaultProduct struct {
@ -71,8 +87,38 @@ func (m *defaultProduct) GetCategory(ctx context.Context, in *CategoryReq, opts
return client.GetCategory(ctx, in, opts...) return client.GetCategory(ctx, in, opts...)
} }
// CreateCategory 建立 product 分類 // ListCategory 建立 product 分類
func (m *defaultProduct) ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) { func (m *defaultProduct) ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) {
client := product.NewProductClient(m.cli.Conn()) client := product.NewProductClient(m.cli.Conn())
return client.ListCategory(ctx, in, opts...) 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...)
}

View File

@ -416,6 +416,422 @@ func (x *ListCategoryResp) GetData() []*Category {
return nil return nil
} }
type CreateTagsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Types int32 `protobuf:"varint,1,opt,name=types,proto3" json:"types,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
ShowType int64 `protobuf:"varint,3,opt,name=show_type,json=showType,proto3" json:"show_type,omitempty"`
Cover *string `protobuf:"bytes,4,opt,name=cover,proto3,oneof" json:"cover,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateTagsReq) Reset() {
*x = CreateTagsReq{}
mi := &file_generate_protobuf_product_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateTagsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateTagsReq) ProtoMessage() {}
func (x *CreateTagsReq) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateTagsReq.ProtoReflect.Descriptor instead.
func (*CreateTagsReq) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{8}
}
func (x *CreateTagsReq) GetTypes() int32 {
if x != nil {
return x.Types
}
return 0
}
func (x *CreateTagsReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateTagsReq) GetShowType() int64 {
if x != nil {
return x.ShowType
}
return 0
}
func (x *CreateTagsReq) GetCover() string {
if x != nil && x.Cover != nil {
return *x.Cover
}
return ""
}
type ModifyTagsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Types *int32 `protobuf:"varint,2,opt,name=types,proto3,oneof" json:"types,omitempty"`
Name *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"`
ShowType *int64 `protobuf:"varint,4,opt,name=show_type,json=showType,proto3,oneof" json:"show_type,omitempty"`
Cover *string `protobuf:"bytes,5,opt,name=cover,proto3,oneof" json:"cover,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ModifyTagsReq) Reset() {
*x = ModifyTagsReq{}
mi := &file_generate_protobuf_product_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyTagsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyTagsReq) ProtoMessage() {}
func (x *ModifyTagsReq) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyTagsReq.ProtoReflect.Descriptor instead.
func (*ModifyTagsReq) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{9}
}
func (x *ModifyTagsReq) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *ModifyTagsReq) GetTypes() int32 {
if x != nil && x.Types != nil {
return *x.Types
}
return 0
}
func (x *ModifyTagsReq) GetName() string {
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
func (x *ModifyTagsReq) GetShowType() int64 {
if x != nil && x.ShowType != nil {
return *x.ShowType
}
return 0
}
func (x *ModifyTagsReq) GetCover() string {
if x != nil && x.Cover != nil {
return *x.Cover
}
return ""
}
type TagsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TagsReq) Reset() {
*x = TagsReq{}
mi := &file_generate_protobuf_product_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TagsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TagsReq) ProtoMessage() {}
func (x *TagsReq) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TagsReq.ProtoReflect.Descriptor instead.
func (*TagsReq) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{10}
}
func (x *TagsReq) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type Tags struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Types int32 `protobuf:"varint,2,opt,name=types,proto3" json:"types,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
ShowType int64 `protobuf:"varint,4,opt,name=show_type,json=showType,proto3" json:"show_type,omitempty"`
Cover string `protobuf:"bytes,5,opt,name=cover,proto3" json:"cover,omitempty"`
UpdateAt int64 `protobuf:"varint,6,opt,name=update_at,json=updateAt,proto3" json:"update_at,omitempty"`
CreatedAt int64 `protobuf:"varint,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Tags) Reset() {
*x = Tags{}
mi := &file_generate_protobuf_product_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Tags) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Tags) ProtoMessage() {}
func (x *Tags) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Tags.ProtoReflect.Descriptor instead.
func (*Tags) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{11}
}
func (x *Tags) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Tags) GetTypes() int32 {
if x != nil {
return x.Types
}
return 0
}
func (x *Tags) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Tags) GetShowType() int64 {
if x != nil {
return x.ShowType
}
return 0
}
func (x *Tags) GetCover() string {
if x != nil {
return x.Cover
}
return ""
}
func (x *Tags) GetUpdateAt() int64 {
if x != nil {
return x.UpdateAt
}
return 0
}
func (x *Tags) GetCreatedAt() int64 {
if x != nil {
return x.CreatedAt
}
return 0
}
type ListTagsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
PageIndex int64 `protobuf:"varint,1,opt,name=page_index,json=pageIndex,proto3" json:"page_index,omitempty"`
PageSize int64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
Ids []string `protobuf:"bytes,3,rep,name=ids,proto3" json:"ids,omitempty"`
Name *string `protobuf:"bytes,4,opt,name=name,proto3,oneof" json:"name,omitempty"`
Types *int32 `protobuf:"varint,5,opt,name=types,proto3,oneof" json:"types,omitempty"`
ShowType *int64 `protobuf:"varint,6,opt,name=show_type,json=showType,proto3,oneof" json:"show_type,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListTagsReq) Reset() {
*x = ListTagsReq{}
mi := &file_generate_protobuf_product_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListTagsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTagsReq) ProtoMessage() {}
func (x *ListTagsReq) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTagsReq.ProtoReflect.Descriptor instead.
func (*ListTagsReq) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{12}
}
func (x *ListTagsReq) GetPageIndex() int64 {
if x != nil {
return x.PageIndex
}
return 0
}
func (x *ListTagsReq) GetPageSize() int64 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *ListTagsReq) GetIds() []string {
if x != nil {
return x.Ids
}
return nil
}
func (x *ListTagsReq) GetName() string {
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
func (x *ListTagsReq) GetTypes() int32 {
if x != nil && x.Types != nil {
return *x.Types
}
return 0
}
func (x *ListTagsReq) GetShowType() int64 {
if x != nil && x.ShowType != nil {
return *x.ShowType
}
return 0
}
type ListTagsResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"`
Data []*Tags `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListTagsResp) Reset() {
*x = ListTagsResp{}
mi := &file_generate_protobuf_product_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListTagsResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTagsResp) ProtoMessage() {}
func (x *ListTagsResp) ProtoReflect() protoreflect.Message {
mi := &file_generate_protobuf_product_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTagsResp.ProtoReflect.Descriptor instead.
func (*ListTagsResp) Descriptor() ([]byte, []int) {
return file_generate_protobuf_product_proto_rawDescGZIP(), []int{13}
}
func (x *ListTagsResp) GetTotal() int64 {
if x != nil {
return x.Total
}
return 0
}
func (x *ListTagsResp) GetData() []*Tags {
if x != nil {
return x.Data
}
return nil
}
var File_generate_protobuf_product_proto protoreflect.FileDescriptor var File_generate_protobuf_product_proto protoreflect.FileDescriptor
var file_generate_protobuf_product_proto_rawDesc = string([]byte{ var file_generate_protobuf_product_proto_rawDesc = string([]byte{
@ -449,28 +865,95 @@ var file_generate_protobuf_product_proto_rawDesc = string([]byte{
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x25, 0x0a, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x25, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72,
0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x04, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x32, 0xbd, 0x02, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x64, 0x61, 0x74, 0x61, 0x22, 0x7b, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61,
0x12, 0x3d, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x01,
0x72, 0x79, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e,
0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01,
0x3d, 0x0a, 0x0e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x28, 0x03, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x05,
0x79, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x63,
0x66, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x6f, 0x76, 0x65, 0x72, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x63, 0x6f, 0x76, 0x65,
0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x72, 0x22, 0xbb, 0x01, 0x0a, 0x0d, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x61, 0x67, 0x73,
0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01,
0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x28, 0x05, 0x48, 0x00, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x17,
0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x36, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x43, 0x61, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x73, 0x68, 0x6f, 0x77, 0x5f,
0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x48, 0x02, 0x52, 0x08, 0x73, 0x68,
0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x63, 0x6f, 0x76,
0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x76, 0x65,
0x72, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, 0x07,
0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x73, 0x68, 0x6f, 0x77,
0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x22,
0x19, 0x0a, 0x07, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xaf, 0x01, 0x0a, 0x04, 0x54,
0x61, 0x67, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01,
0x28, 0x05, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a,
0x09, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03,
0x52, 0x08, 0x73, 0x68, 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f,
0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6f, 0x76, 0x65, 0x72,
0x12, 0x1b, 0x0a, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20,
0x01, 0x28, 0x03, 0x52, 0x08, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x74, 0x12, 0x1d, 0x0a,
0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28,
0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xd2, 0x01, 0x0a,
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x0a,
0x70, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x70,
0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08,
0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18,
0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01,
0x28, 0x05, 0x48, 0x01, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x20,
0x0a, 0x09, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28,
0x03, 0x48, 0x02, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01,
0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x22, 0x47, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73,
0x70, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e,
0x54, 0x61, 0x67, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xc1, 0x04, 0x0a, 0x07, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x3d, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
0x79, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f,
0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3d, 0x0a, 0x0e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43,
0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f, 0x4b,
0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x70, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x36, 0x0a,
0x43, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0b, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x2e, 0x70,
0x18, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x43, 0x61, 0x74,
0x75, 0x63, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x43, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x74,
0x52, 0x65, 0x73, 0x70, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e,
0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a,
0x19, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x35, 0x0a, 0x0a, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71,
0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73,
0x70, 0x12, 0x35, 0x0a, 0x0a, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x61, 0x67, 0x73, 0x12,
0x16, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79,
0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2f, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x54, 0x61, 0x67, 0x73, 0x12, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x2e, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x2e, 0x4f, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a, 0x07, 0x47, 0x65, 0x74,
0x54, 0x61, 0x67, 0x73, 0x12, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x54,
0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x2e, 0x54, 0x61, 0x67, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67,
0x73, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0b,
0x5a, 0x09, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}) })
var ( var (
@ -485,7 +968,7 @@ func file_generate_protobuf_product_proto_rawDescGZIP() []byte {
return file_generate_protobuf_product_proto_rawDescData return file_generate_protobuf_product_proto_rawDescData
} }
var file_generate_protobuf_product_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_generate_protobuf_product_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_generate_protobuf_product_proto_goTypes = []any{ var file_generate_protobuf_product_proto_goTypes = []any{
(*OKResp)(nil), // 0: product.OKResp (*OKResp)(nil), // 0: product.OKResp
(*NoneReq)(nil), // 1: product.NoneReq (*NoneReq)(nil), // 1: product.NoneReq
@ -495,24 +978,41 @@ var file_generate_protobuf_product_proto_goTypes = []any{
(*Category)(nil), // 5: product.Category (*Category)(nil), // 5: product.Category
(*ListCategoryReq)(nil), // 6: product.ListCategoryReq (*ListCategoryReq)(nil), // 6: product.ListCategoryReq
(*ListCategoryResp)(nil), // 7: product.ListCategoryResp (*ListCategoryResp)(nil), // 7: product.ListCategoryResp
(*CreateTagsReq)(nil), // 8: product.CreateTagsReq
(*ModifyTagsReq)(nil), // 9: product.ModifyTagsReq
(*TagsReq)(nil), // 10: product.TagsReq
(*Tags)(nil), // 11: product.Tags
(*ListTagsReq)(nil), // 12: product.ListTagsReq
(*ListTagsResp)(nil), // 13: product.ListTagsResp
} }
var file_generate_protobuf_product_proto_depIdxs = []int32{ var file_generate_protobuf_product_proto_depIdxs = []int32{
5, // 0: product.ListCategoryResp.data:type_name -> product.Category 5, // 0: product.ListCategoryResp.data:type_name -> product.Category
2, // 1: product.Product.CreateCategory:input_type -> product.CreateCategoryReq 11, // 1: product.ListTagsResp.data:type_name -> product.Tags
3, // 2: product.Product.ModifyCategory:input_type -> product.ModifyCategoryReq 2, // 2: product.Product.CreateCategory:input_type -> product.CreateCategoryReq
4, // 3: product.Product.DeleteCategory:input_type -> product.CategoryReq 3, // 3: product.Product.ModifyCategory:input_type -> product.ModifyCategoryReq
4, // 4: product.Product.GetCategory:input_type -> product.CategoryReq 4, // 4: product.Product.DeleteCategory:input_type -> product.CategoryReq
6, // 5: product.Product.ListCategory:input_type -> product.ListCategoryReq 4, // 5: product.Product.GetCategory:input_type -> product.CategoryReq
0, // 6: product.Product.CreateCategory:output_type -> product.OKResp 6, // 6: product.Product.ListCategory:input_type -> product.ListCategoryReq
0, // 7: product.Product.ModifyCategory:output_type -> product.OKResp 8, // 7: product.Product.CreateTags:input_type -> product.CreateTagsReq
0, // 8: product.Product.DeleteCategory:output_type -> product.OKResp 9, // 8: product.Product.ModifyTags:input_type -> product.ModifyTagsReq
5, // 9: product.Product.GetCategory:output_type -> product.Category 10, // 9: product.Product.DeleteTags:input_type -> product.TagsReq
7, // 10: product.Product.ListCategory:output_type -> product.ListCategoryResp 10, // 10: product.Product.GetTags:input_type -> product.TagsReq
6, // [6:11] is the sub-list for method output_type 12, // 11: product.Product.ListTags:input_type -> product.ListTagsReq
1, // [1:6] is the sub-list for method input_type 0, // 12: product.Product.CreateCategory:output_type -> product.OKResp
1, // [1:1] is the sub-list for extension type_name 0, // 13: product.Product.ModifyCategory:output_type -> product.OKResp
1, // [1:1] is the sub-list for extension extendee 0, // 14: product.Product.DeleteCategory:output_type -> product.OKResp
0, // [0:1] is the sub-list for field type_name 5, // 15: product.Product.GetCategory:output_type -> product.Category
7, // 16: product.Product.ListCategory:output_type -> product.ListCategoryResp
0, // 17: product.Product.CreateTags:output_type -> product.OKResp
0, // 18: product.Product.ModifyTags:output_type -> product.OKResp
0, // 19: product.Product.DeleteTags:output_type -> product.OKResp
11, // 20: product.Product.GetTags:output_type -> product.Tags
13, // 21: product.Product.ListTags:output_type -> product.ListTagsResp
12, // [12:22] is the sub-list for method output_type
2, // [2:12] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_generate_protobuf_product_proto_init() } func init() { file_generate_protobuf_product_proto_init() }
@ -520,13 +1020,16 @@ func file_generate_protobuf_product_proto_init() {
if File_generate_protobuf_product_proto != nil { if File_generate_protobuf_product_proto != nil {
return return
} }
file_generate_protobuf_product_proto_msgTypes[8].OneofWrappers = []any{}
file_generate_protobuf_product_proto_msgTypes[9].OneofWrappers = []any{}
file_generate_protobuf_product_proto_msgTypes[12].OneofWrappers = []any{}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_generate_protobuf_product_proto_rawDesc), len(file_generate_protobuf_product_proto_rawDesc)), RawDescriptor: unsafe.Slice(unsafe.StringData(file_generate_protobuf_product_proto_rawDesc), len(file_generate_protobuf_product_proto_rawDesc)),
NumEnums: 0, NumEnums: 0,
NumMessages: 8, NumMessages: 14,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -24,6 +24,11 @@ const (
Product_DeleteCategory_FullMethodName = "/product.Product/DeleteCategory" Product_DeleteCategory_FullMethodName = "/product.Product/DeleteCategory"
Product_GetCategory_FullMethodName = "/product.Product/GetCategory" Product_GetCategory_FullMethodName = "/product.Product/GetCategory"
Product_ListCategory_FullMethodName = "/product.Product/ListCategory" Product_ListCategory_FullMethodName = "/product.Product/ListCategory"
Product_CreateTags_FullMethodName = "/product.Product/CreateTags"
Product_ModifyTags_FullMethodName = "/product.Product/ModifyTags"
Product_DeleteTags_FullMethodName = "/product.Product/DeleteTags"
Product_GetTags_FullMethodName = "/product.Product/GetTags"
Product_ListTags_FullMethodName = "/product.Product/ListTags"
) )
// ProductClient is the client API for Product service. // ProductClient is the client API for Product service.
@ -39,8 +44,20 @@ type ProductClient interface {
DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error) DeleteCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*OKResp, error)
// GetCategory 取得 product 分類 // GetCategory 取得 product 分類
GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error) GetCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*Category, error)
// CreateCategory 建立 product 分類 // ListCategory 建立 product 分類
ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error) ListCategory(ctx context.Context, in *ListCategoryReq, opts ...grpc.CallOption) (*ListCategoryResp, error)
// ====================== Category Service End ======================
// ====================== Tags Service Start ======================
// CreateTags 建立 tags
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)
} }
type productClient struct { type productClient struct {
@ -101,6 +118,56 @@ func (c *productClient) ListCategory(ctx context.Context, in *ListCategoryReq, o
return out, nil return out, nil
} }
func (c *productClient) CreateTags(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Product_CreateTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *productClient) ModifyTags(ctx context.Context, in *ModifyTagsReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Product_ModifyTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *productClient) DeleteTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Product_DeleteTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *productClient) GetTags(ctx context.Context, in *TagsReq, opts ...grpc.CallOption) (*Tags, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Tags)
err := c.cc.Invoke(ctx, Product_GetTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *productClient) ListTags(ctx context.Context, in *ListTagsReq, opts ...grpc.CallOption) (*ListTagsResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListTagsResp)
err := c.cc.Invoke(ctx, Product_ListTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ProductServer is the server API for Product service. // ProductServer is the server API for Product service.
// All implementations must embed UnimplementedProductServer // All implementations must embed UnimplementedProductServer
// for forward compatibility. // for forward compatibility.
@ -114,8 +181,20 @@ type ProductServer interface {
DeleteCategory(context.Context, *CategoryReq) (*OKResp, error) DeleteCategory(context.Context, *CategoryReq) (*OKResp, error)
// GetCategory 取得 product 分類 // GetCategory 取得 product 分類
GetCategory(context.Context, *CategoryReq) (*Category, error) GetCategory(context.Context, *CategoryReq) (*Category, error)
// CreateCategory 建立 product 分類 // ListCategory 建立 product 分類
ListCategory(context.Context, *ListCategoryReq) (*ListCategoryResp, error) ListCategory(context.Context, *ListCategoryReq) (*ListCategoryResp, error)
// ====================== Category Service End ======================
// ====================== Tags Service Start ======================
// CreateTags 建立 tags
CreateTags(context.Context, *CreateTagsReq) (*OKResp, error)
// ModifyTags 修改 tags
ModifyTags(context.Context, *ModifyTagsReq) (*OKResp, error)
// DeleteTags 刪除tags
DeleteTags(context.Context, *TagsReq) (*OKResp, error)
// GetTags 取得 tags
GetTags(context.Context, *TagsReq) (*Tags, error)
// ListTags 建立 tags
ListTags(context.Context, *ListTagsReq) (*ListTagsResp, error)
mustEmbedUnimplementedProductServer() mustEmbedUnimplementedProductServer()
} }
@ -141,6 +220,21 @@ func (UnimplementedProductServer) GetCategory(context.Context, *CategoryReq) (*C
func (UnimplementedProductServer) ListCategory(context.Context, *ListCategoryReq) (*ListCategoryResp, error) { func (UnimplementedProductServer) ListCategory(context.Context, *ListCategoryReq) (*ListCategoryResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListCategory not implemented") return nil, status.Errorf(codes.Unimplemented, "method ListCategory not implemented")
} }
func (UnimplementedProductServer) CreateTags(context.Context, *CreateTagsReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateTags not implemented")
}
func (UnimplementedProductServer) ModifyTags(context.Context, *ModifyTagsReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyTags not implemented")
}
func (UnimplementedProductServer) DeleteTags(context.Context, *TagsReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteTags not implemented")
}
func (UnimplementedProductServer) GetTags(context.Context, *TagsReq) (*Tags, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetTags not implemented")
}
func (UnimplementedProductServer) ListTags(context.Context, *ListTagsReq) (*ListTagsResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListTags not implemented")
}
func (UnimplementedProductServer) mustEmbedUnimplementedProductServer() {} func (UnimplementedProductServer) mustEmbedUnimplementedProductServer() {}
func (UnimplementedProductServer) testEmbeddedByValue() {} func (UnimplementedProductServer) testEmbeddedByValue() {}
@ -252,6 +346,96 @@ func _Product_ListCategory_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Product_CreateTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateTagsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProductServer).CreateTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Product_CreateTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProductServer).CreateTags(ctx, req.(*CreateTagsReq))
}
return interceptor(ctx, in, info, handler)
}
func _Product_ModifyTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ModifyTagsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProductServer).ModifyTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Product_ModifyTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProductServer).ModifyTags(ctx, req.(*ModifyTagsReq))
}
return interceptor(ctx, in, info, handler)
}
func _Product_DeleteTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TagsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProductServer).DeleteTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Product_DeleteTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProductServer).DeleteTags(ctx, req.(*TagsReq))
}
return interceptor(ctx, in, info, handler)
}
func _Product_GetTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TagsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProductServer).GetTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Product_GetTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProductServer).GetTags(ctx, req.(*TagsReq))
}
return interceptor(ctx, in, info, handler)
}
func _Product_ListTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListTagsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProductServer).ListTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Product_ListTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProductServer).ListTags(ctx, req.(*ListTagsReq))
}
return interceptor(ctx, in, info, handler)
}
// Product_ServiceDesc is the grpc.ServiceDesc for Product service. // Product_ServiceDesc is the grpc.ServiceDesc for Product service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -279,6 +463,26 @@ var Product_ServiceDesc = grpc.ServiceDesc{
MethodName: "ListCategory", MethodName: "ListCategory",
Handler: _Product_ListCategory_Handler, Handler: _Product_ListCategory_Handler,
}, },
{
MethodName: "CreateTags",
Handler: _Product_CreateTags_Handler,
},
{
MethodName: "ModifyTags",
Handler: _Product_ModifyTags_Handler,
},
{
MethodName: "DeleteTags",
Handler: _Product_DeleteTags_Handler,
},
{
MethodName: "GetTags",
Handler: _Product_GetTags_Handler,
},
{
MethodName: "ListTags",
Handler: _Product_ListTags_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "generate/protobuf/product.proto", Metadata: "generate/protobuf/product.proto",

View File

@ -41,9 +41,50 @@ message ListCategoryResp {
repeated Category data=3; repeated Category data=3;
} }
// ====================== Tags Param ======================
message CreateTagsReq{
int32 types=1;
string name=2;
int64 show_type=3;
optional string cover=4;
}
// ====================== Category Param ====================== message ModifyTagsReq{
string id=1;
optional int32 types=2;
optional string name=3;
optional int64 show_type=4;
optional string cover=5;
}
message TagsReq {
string id =1;
}
message Tags{
string id=1;
int32 types=2;
string name=3;
int64 show_type=4;
string cover=5;
int64 update_at=6;
int64 created_at=7;
}
message ListTagsReq {
int64 page_index =1;
int64 page_size =2;
repeated string ids=3;
optional string name=4;
optional int32 types=5;
optional int64 show_type=6;
}
message ListTagsResp {
int64 total =1;
repeated Tags data=3;
}
service Product { service Product {
@ -56,7 +97,20 @@ service Product {
rpc DeleteCategory(CategoryReq) returns(OKResp); rpc DeleteCategory(CategoryReq) returns(OKResp);
// GetCategory product // GetCategory product
rpc GetCategory(CategoryReq) returns(Category); rpc GetCategory(CategoryReq) returns(Category);
// CreateCategory product // ListCategory product
rpc ListCategory(ListCategoryReq) returns(ListCategoryResp); rpc ListCategory(ListCategoryReq) returns(ListCategoryResp);
// ====================== Category Service End ====================== // ====================== 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 ======================
} }

View File

@ -0,0 +1,59 @@
package productlogic
import (
"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 {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTagsLogic {
return &CreateTagsLogic{
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")
}
insert := &entity.Tags{
Types: t,
Name: in.GetName(),
ShowType: domainProduct.ShowType(in.GetShowType()),
}
if in.Cover != nil {
insert.Cover = in.Cover
}
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

@ -0,0 +1,34 @@
package productlogic
import (
"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 DeleteTagsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTagsLogic {
return &DeleteTagsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeleteTags 刪除tags
func (l *DeleteTagsLogic) DeleteTags(in *product.TagsReq) (*product.OKResp, error) {
err := l.svcCtx.TagsUseCase.Delete(l.ctx, in.GetId())
if err != nil {
return nil, err
}
return &product.OKResp{}, nil
}

View File

@ -0,0 +1,45 @@
package productlogic
import (
"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 GetTagsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagsLogic {
return &GetTagsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetTags 取得 tags
func (l *GetTagsLogic) GetTags(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),
Name: tag.Name,
ShowType: int64(tag.ShowType),
UpdateAt: tag.UpdatedAt,
CreatedAt: tag.CreatedAt,
}
if tag.Cover != nil {
result.Cover = *tag.Cover
}
return result, nil
}

View File

@ -0,0 +1,85 @@
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

@ -0,0 +1,64 @@
package productlogic
import (
domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
"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 ModifyTagsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewModifyTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyTagsLogic {
return &ModifyTagsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ModifyTags 修改 tags
func (l *ModifyTagsLogic) ModifyTags(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
}
params.Types = &t
}
// 處理 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
}
// 執行更新
err := l.svcCtx.TagsUseCase.Update(l.ctx, in.GetId(), params)
if err != nil {
return nil, err
}
return &product.OKResp{}, nil
}

View File

@ -47,8 +47,38 @@ func (s *ProductServer) GetCategory(ctx context.Context, in *product.CategoryReq
return l.GetCategory(in) return l.GetCategory(in)
} }
// CreateCategory 建立 product 分類 // ListCategory 建立 product 分類
func (s *ProductServer) ListCategory(ctx context.Context, in *product.ListCategoryReq) (*product.ListCategoryResp, error) { func (s *ProductServer) ListCategory(ctx context.Context, in *product.ListCategoryReq) (*product.ListCategoryResp, error) {
l := productlogic.NewListCategoryLogic(ctx, s.svcCtx) l := productlogic.NewListCategoryLogic(ctx, s.svcCtx)
return l.ListCategory(in) 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)
}

View File

@ -13,11 +13,13 @@ import (
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
CategoryUseCase usecase.CategoryUseCase CategoryUseCase usecase.CategoryUseCase
TagsUseCase usecase.ProductBaseTags
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
CategoryUseCase: MustCategory(c), CategoryUseCase: MustCategory(c),
TagsUseCase: MustTags(c),
Config: c, Config: c,
} }
} }
@ -61,3 +63,43 @@ func MustCategory(c config.Config) usecase.CategoryUseCase {
return uc.MustCategoryUseCase(uc.CategoryUseCaseParam{ return uc.MustCategoryUseCase(uc.CategoryUseCaseParam{
CategoryRepo: categoryRepo}) CategoryRepo: categoryRepo})
} }
func MustTags(c config.Config) usecase.ProductBaseTags {
// 準備Mongo Config
conf := &mgo.Conf{
Schema: c.Mongo.Schema,
Host: c.Mongo.Host,
Database: c.Mongo.Database,
MaxStaleness: c.Mongo.MaxStaleness,
MaxPoolSize: c.Mongo.MaxPoolSize,
MinPoolSize: c.Mongo.MinPoolSize,
MaxConnIdleTime: c.Mongo.MaxConnIdleTime,
Compressors: c.Mongo.Compressors,
EnableStandardReadWriteSplitMode: c.Mongo.EnableStandardReadWriteSplitMode,
ConnectTimeoutMs: c.Mongo.ConnectTimeoutMs,
}
if c.Mongo.User != "" {
conf.User = c.Mongo.User
conf.Password = c.Mongo.Password
}
// 快取選項
cacheOpts := []cache.Option{
cache.WithExpiry(c.CacheExpireTime),
cache.WithNotFoundExpiry(c.CacheWithNotFoundExpiry),
}
dbOpts := []mon.Option{
mgo.SetCustomDecimalType(),
mgo.InitMongoOptions(*conf),
}
tagsRepo := repo.NewTagsRepository(repo.TagsRepositoryParam{
Conf: conf,
CacheConf: c.Cache,
CacheOpts: cacheOpts,
DBOpts: dbOpts,
})
return uc.MustTagsUseCase(uc.TagsUseCaseParam{
TagsRepo: tagsRepo})
}