first commit
This commit is contained in:
40
apps/admin/internal/logic/product/createproductlogic.go
Normal file
40
apps/admin/internal/logic/product/createproductlogic.go
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user