1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package nats_server
- import (
- "cold-logistics/common/nats"
- "cold-logistics/conf"
- "github.com/vmihailenco/msgpack/v5"
- "time"
- )
- func Cold_CompanyDeviceSensor_List_ByKey(T_sn string) (data []DeviceSensor_R, count int64, err error) {
- type T_Req struct {
- T_sn string `xml:"T_sn"`
- T_key string `xml:"T_key"`
- }
- t_Req := T_Req{
- T_sn: T_sn,
- T_key: conf.ExtConfig.Nats.Key,
- }
- b, _ := msgpack.Marshal(&t_Req)
- msg, err := nats.Nats.Request("Cold_CompanyDeviceSensor_List_ByKey", b, 3*time.Second)
- if err != nil {
- return
- }
- type T_R struct {
- Code int16 `xml:"Code"`
- Msg string `xml:"Msg"`
- Count int64 `xml:"Count"`
- Data []DeviceSensor_R `xml:"Data"` // 泛型
- }
- var t_R T_R
- err = msgpack.Unmarshal(msg.Data, &t_R)
- if err != nil {
- return
- }
- return t_R.Data, t_R.Count, nil
- }
|