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

package job

import (
	"context"

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

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

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

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

func (l *GetWorkerThreadsAccountSessionLogic) GetWorkerThreadsAccountSession(req *types.WorkerThreadsAccountSessionReq) (resp *types.WorkerThreadsAccountSessionData, err error) {
	session, err := l.svcCtx.ThreadsAccount.GetBrowserSession(l.ctx, req.TenantID, req.OwnerUID, req.ID)
	if err != nil {
		return nil, err
	}
	return &types.WorkerThreadsAccountSessionData{
		AccountID:    session.AccountID,
		StorageState: session.StorageState,
		UpdateAt:     session.UpdateAt,
	}, nil
}
