42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package productlogic
|
|
|
|
import (
|
|
"code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product"
|
|
"code.30cm.net/digimon/library-go/errs"
|
|
"context"
|
|
|
|
PB "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
|
|
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdateStatusLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
|
|
return &UpdateStatusLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// UpdateStatus 更新 Item status
|
|
func (l *UpdateStatusLogic) UpdateStatus(in *PB.UpdateStatusRequest) (*PB.OKResp, error) {
|
|
status, e := product.StringToItemStatus(in.GetStatus())
|
|
if !e {
|
|
return nil, errs.InvalidFormat("failed to convert string to item status")
|
|
}
|
|
|
|
err := l.svcCtx.ProductItemUseCase.UpdateStatus(l.ctx, in.GetId(), status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &PB.OKResp{}, nil
|
|
}
|