package rec_extra

import (
	"ai_scheduler/internal/entitys"
	"ai_scheduler/internal/pkg"
	"encoding/json"
)

func SetTaskRecExt(requireData *entitys.RequireData, rec *entitys.Recognize) {
	TaskExt := entitys.TaskExt{
		Auth:    requireData.Auth,
		Session: requireData.Session,
		Key:     requireData.Key,
		Sys:     requireData.Sys,
	}
	rec.Ext = pkg.JsonByteIgonErr(TaskExt)
}

func GetTaskRecExt(rec *entitys.Recognize) (ext entitys.TaskExt, err error) {
	if rec == nil {
		return
	}
	err = json.Unmarshal(rec.Ext, &ext)
	return ext, err
}
