package NatsServer

import (
	"ColdVerify_server/lib"
	"ColdVerify_server/logs"
	"github.com/vmihailenco/msgpack/v5"
)

func Import_TaskData(T_uuid, T_task_id string, TaskData_Num int) {
	logs.Println("Nats =>", lib.FuncName(), T_uuid, T_uuid)

	type T_R struct {
		T_uuid       string `xml:"T_uuid"`
		T_task_id    string `xml:"T_task_id"`
		TaskData_Num int    `xml:"TaskData_Num"`
	}
	t_r := T_R{
		T_uuid:       T_uuid,
		T_task_id:    T_task_id,
		TaskData_Num: TaskData_Num,
	}

	b, err := msgpack.Marshal(&t_r)
	if err != nil {
		logs.Error("Nats =>", "msgpack Marshal err", err)
	}

	err = lib.Nats.Publish("ColdVerify_Local_Import_TaskData", b)
	if err != nil {
		logs.Error("Nats =>", lib.FuncName(), err)
	}
}
func Create_Local_Table(T_task_id string) {
	logs.Println("Nats =>", lib.FuncName(), T_task_id)

	err := lib.Nats.Publish("ColdVerify_Local_Create_Table", []byte(T_task_id))
	if err != nil {
		logs.Error("Nats =>", lib.FuncName(), err)
	}
}

// 同步2。8数据
func Sync1_TaskData(T_task_id string) {
	logs.Println("Nats =>", lib.FuncName(), T_task_id)

	err := lib.Nats.Publish("ColdVerify_Local_Sync1_TaskData", []byte(T_task_id))
	if err != nil {
		logs.Error("Nats =>", lib.FuncName(), err)
	}
}
