// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package placement_topic

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

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

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

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

func (l *BatchDeletePlacementTopicScanPostsLogic) BatchDeletePlacementTopicScanPosts(req *types.BatchDeletePlacementTopicScanPostsHandlerReq) (resp *types.BatchDeletePlacementTopicScanPostsData, err 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
	}
	count, err := l.svcCtx.ScanPost.DeleteMany(l.ctx, tenantID, uid, scope.BrandID, scope.TopicID, req.PostIDs)
	if err != nil {
		return nil, err
	}
	return &types.BatchDeletePlacementTopicScanPostsData{DeletedCount: count}, nil
}
