package placement_topic

import (
	"context"

	brandlogic "haixun-backend/internal/logic/brand"
	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PatchPlacementTopicScanPostOutreachLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPatchPlacementTopicScanPostOutreachLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PatchPlacementTopicScanPostOutreachLogic {
	return &PatchPlacementTopicScanPostOutreachLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *PatchPlacementTopicScanPostOutreachLogic) PatchPlacementTopicScanPostOutreach(req *types.PatchPlacementTopicScanPostOutreachHandlerReq) (*types.ScanPostData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	scope, err := resolveScope(l.ctx, l.svcCtx, tenantID, uid, req.ID)
	if err != nil {
		return nil, err
	}
	return brandlogic.NewPatchScanPostOutreachLogic(l.ctx, l.svcCtx).PatchScanPostOutreach(&types.PatchScanPostOutreachHandlerReq{
		BrandPath: types.BrandPath{ID: scope.BrandID},
		PostID:    req.PostID,
		PatchScanPostOutreachReq: types.PatchScanPostOutreachReq{
			OutreachStatus: req.OutreachStatus,
		},
	})
}
