2024-10-02 00:57:17 +08:00
|
|
|
package productlogic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-10-15 00:23:07 +08:00
|
|
|
"tianyuan-api/apps/sentinel/internal/model"
|
2024-10-02 00:57:17 +08:00
|
|
|
"tianyuan-api/apps/sentinel/internal/svc"
|
|
|
|
"tianyuan-api/apps/sentinel/sentinel"
|
2024-10-15 00:23:07 +08:00
|
|
|
"tianyuan-api/pkg/sqlutil"
|
2024-10-02 00:57:17 +08:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UpdateProductLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUpdateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProductLogic {
|
|
|
|
return &UpdateProductLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *UpdateProductLogic) UpdateProduct(in *sentinel.UpdateProductRequest) (*sentinel.Product, error) {
|
2024-10-15 00:23:07 +08:00
|
|
|
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
|
|
|
|
}
|
2024-10-02 00:57:17 +08:00
|
|
|
return &sentinel.Product{}, nil
|
|
|
|
}
|