package logic import ( "context" "errors" "juwan-backend/app/shop/rpc/internal/models/shopinvitations" "juwan-backend/app/shop/rpc/internal/svc" "juwan-backend/app/shop/rpc/pb" "github.com/jinzhu/copier" "github.com/zeromicro/go-zero/core/logx" ) type UpdateShopInvitationsLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUpdateShopInvitationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateShopInvitationsLogic { return &UpdateShopInvitationsLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *UpdateShopInvitationsLogic) UpdateShopInvitations(in *pb.UpdateShopInvitationsReq) (*pb.UpdateShopInvitationsResp, error) { update, err := l.svcCtx.ShopModelRW.ShopInvitations.UpdateOneID(in.Id). Where(shopinvitations.PlayerIDEQ(in.PlayerId)). SetStatus(in.Status).Save(l.ctx) if err != nil { logx.Errorf("failed to update shop invitation: %v", err) return nil, errors.New("failed to update shop invitation") } resp := &pb.ShopInvitations{} err = copier.Copy(resp, update) if err != nil { logx.Errorf("failed to copy update: %v", err) return nil, errors.New("failed to update shop invitation") } return &pb.UpdateShopInvitationsResp{ShopInvitations: resp}, nil }