修复产品修改、删除
This commit is contained in:
@@ -24,7 +24,9 @@ func NewDeleteProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
||||
}
|
||||
|
||||
func (l *DeleteProductLogic) DeleteProduct(in *sentinel.DeleteProductRequest) (*sentinel.Product, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
err := l.svcCtx.ProductsModel.Delete(l.ctx, in.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &sentinel.Product{}, nil
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package productlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"tianyuan-api/apps/sentinel/internal/model"
|
||||
"tianyuan-api/apps/sentinel/internal/svc"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
"tianyuan-api/pkg/sqlutil"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -24,7 +25,17 @@ func NewUpdateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
|
||||
}
|
||||
|
||||
func (l *UpdateProductLogic) UpdateProduct(in *sentinel.UpdateProductRequest) (*sentinel.Product, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
err := l.svcCtx.ProductsModel.Update(l.ctx, &model.Products{
|
||||
Id: in.Id,
|
||||
ProductName: in.ProductName,
|
||||
ProductCode: in.ProductCode,
|
||||
ProductDescription: sqlutil.StringToNullString(in.ProductDescription),
|
||||
ProductContent: sqlutil.StringToNullString(in.ProductContent),
|
||||
ProductPrice: in.ProductPrice,
|
||||
ProductGroup: in.ProductGroup,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &sentinel.Product{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user