package bus

import (
	"encoding/json"
	"queencount/db/model"

	"github.com/nats-io/nats.go"
	"infish.cn/comm"
)

func AssetAddedEnvent(bus *comm.NatsBus) {
	bus.Subscribe("asset.added", AssetAddHandler)

}

func AssetAddHandler(msg *nats.Msg) {
	var req model.AssetEvent
	err := json.Unmarshal(msg.Data, &req)
	if err != nil {
		return
	}
	AssetCountAction("add", &req)
}
