package actions

import (
	"fmt"
	"zzman/clients/jd"
	"zzman/model"
)

func Clear() error {

	gateways, err := FindGateways(model.DB)
	if err != nil {
		return fmt.Errorf("清空网关数据失败：%w", err)
	}

	for _, gateway := range gateways {
		err := jd.GatewayConfigClear(gateway.Macaddr)
		if err != nil {
			return fmt.Errorf("清空网关 %s 配置失败：%w", gateway.Macaddr, err)
		}
	}

	return nil
}
