41 lines
971 B
Go
41 lines
971 B
Go
|
package product
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"tianyuan-api/apps/admin/internal/svc"
|
||
|
"tianyuan-api/apps/admin/internal/types"
|
||
|
"tianyuan-api/apps/sentinel/client/product"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
)
|
||
|
|
||
|
type CreateProductLogic struct {
|
||
|
logx.Logger
|
||
|
ctx context.Context
|
||
|
svcCtx *svc.ServiceContext
|
||
|
}
|
||
|
|
||
|
func NewCreateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProductLogic {
|
||
|
return &CreateProductLogic{
|
||
|
Logger: logx.WithContext(ctx),
|
||
|
ctx: ctx,
|
||
|
svcCtx: svcCtx,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (l *CreateProductLogic) CreateProduct(req *types.CreateProductReq) error {
|
||
|
_, err := l.svcCtx.ProductRpc.CreateProduct(l.ctx, &product.CreateProductRequest{
|
||
|
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
|
||
|
}
|