-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from ArtisanCloud/dev/michaelhu
update(readme): add related recommendation
- Loading branch information
Showing
7 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/disableproducthandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package product | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func DisableProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.DisableProductRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := product.NewDisableProductLogic(r.Context(), svcCtx) | ||
resp, err := l.DisableProduct(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package product | ||
|
||
import ( | ||
product2 "PowerX/internal/model/crm/product" | ||
fmt "PowerX/pkg/printx" | ||
"context" | ||
|
||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type DisableProductLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewDisableProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisableProductLogic { | ||
return &DisableProductLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *DisableProductLogic) DisableProduct(req *types.DisableProductRequest) (resp *types.DisableProductReply, err error) { | ||
p := &product2.Product{ | ||
IsActivated: false, | ||
} | ||
fmt.Dump(p) | ||
l.svcCtx.PowerX.Product.PatchProduct(l.ctx, req.ProductId, p) | ||
|
||
return &types.DisableProductReply{ | ||
ProductId: req.ProductId, | ||
}, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters