From 6913e85c87e4686963c643bb95241fafe8d815ba Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Wed, 11 Oct 2023 23:25:31 +0800 Subject: [PATCH] feat(product): add disable product status with api --- .gitignore | 1 + internal/logic/admin/crm/product/disableproductlogic.go | 8 +++----- internal/uc/powerx/crm/product/product.go | 7 +++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 0e4a7b57..96369ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.iml .DS_Store +logs *.log .logs/ .var diff --git a/internal/logic/admin/crm/product/disableproductlogic.go b/internal/logic/admin/crm/product/disableproductlogic.go index 9a3f6f47..17443466 100644 --- a/internal/logic/admin/crm/product/disableproductlogic.go +++ b/internal/logic/admin/crm/product/disableproductlogic.go @@ -1,8 +1,6 @@ package product import ( - product2 "PowerX/internal/model/crm/product" - fmt "PowerX/pkg/printx" "context" "PowerX/internal/svc" @@ -26,10 +24,10 @@ func NewDisableProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Di } func (l *DisableProductLogic) DisableProduct(req *types.DisableProductRequest) (resp *types.DisableProductReply, err error) { - p := &product2.Product{ - IsActivated: false, + p := &map[string]interface{}{ + "is_activated": false, } - fmt.Dump(p) + //fmt.Dump(p) l.svcCtx.PowerX.Product.PatchProduct(l.ctx, req.ProductId, p) return &types.DisableProductReply{ diff --git a/internal/uc/powerx/crm/product/product.go b/internal/uc/powerx/crm/product/product.go index 52834e75..73966857 100644 --- a/internal/uc/powerx/crm/product/product.go +++ b/internal/uc/powerx/crm/product/product.go @@ -7,7 +7,6 @@ import ( "PowerX/internal/model/powermodel" "PowerX/internal/types" "PowerX/internal/types/errorx" - fmt "PowerX/pkg/printx" "PowerX/pkg/slicex" "context" "encoding/json" @@ -185,9 +184,9 @@ func (uc *ProductUseCase) UpsertProducts(ctx context.Context, products []*model. return products, err } -func (uc *ProductUseCase) PatchProduct(ctx context.Context, id int64, product *model.Product) { - fmt.Dump(product) - if err := uc.db.WithContext(ctx).Model(&model.Product{}). +func (uc *ProductUseCase) PatchProduct(ctx context.Context, id int64, product interface{}) { + if err := uc.db.WithContext(ctx). + Model(&model.Product{}). Where(id). Debug(). Updates(product).