43 lines
1009 B
Go
43 lines
1009 B
Go
package product
|
|
|
|
import (
|
|
"context"
|
|
"tianyuan-api/apps/sentinel/client/product"
|
|
|
|
"tianyuan-api/apps/admin/internal/svc"
|
|
"tianyuan-api/apps/admin/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdateProductLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUpdateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProductLogic {
|
|
return &UpdateProductLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UpdateProductLogic) UpdateProduct(req *types.UpdateProductReq) error {
|
|
_, err := l.svcCtx.ProductRpc.UpdateProduct(l.ctx, &product.UpdateProductRequest{
|
|
Id: req.ProductId,
|
|
ProductName: req.ProductName,
|
|
ProductCode: req.ProductCode,
|
|
ProductDescription: req.ProductDescription,
|
|
ProductContent: req.ProductContent,
|
|
ProductPrice: req.ProductPrice,
|
|
ProductGroup: req.ProductGroup,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|