|
@@ -47,7 +47,7 @@ func init() {
|
|
|
func NatsInit() {
|
|
|
|
|
|
// 获取微信二维码 返回结果
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Wx_BasicMessage_Event_QRCode","Wx_BasicMessage_Event_QRCode", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Wx_BasicMessage_Event_QRCode", "Wx_BasicMessage_Event_QRCode", func(m *nats.Msg) {
|
|
|
//fmt.Printf(" => Nats Wx_BasicMessage_Event_QRCode message: %s\n", string(m.Data))
|
|
|
|
|
|
type Person_QRCode struct {
|
|
@@ -113,7 +113,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 验证登录
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_User_verification","Cold_User_verification", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_User_verification", "Cold_User_verification", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_User_verification message: %s\n", string(m.Data))
|
|
|
|
|
|
type T_R struct {
|
|
@@ -154,7 +154,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 通过公司名获取所有公司信息
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_User_CompanyListAllByT_name","Cold_User_CompanyListAllByT_name", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_User_CompanyListAllByT_name", "Cold_User_CompanyListAllByT_name", func(m *nats.Msg) {
|
|
|
fmt.Printf("CompanyListAll message: %s\n", string(m.Data))
|
|
|
|
|
|
type T_R struct {
|
|
@@ -172,7 +172,7 @@ func NatsInit() {
|
|
|
_ = lib.Nats.Publish(m.Reply, b)
|
|
|
})
|
|
|
// 请求-响应 获取公司
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_id","Cold_ReadCompanyByT_id", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_id", "Cold_ReadCompanyByT_id", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_ReadCompanyByT_id message: %s\n", string(m.Data))
|
|
|
|
|
|
type T_R struct {
|
|
@@ -201,8 +201,37 @@ func NatsInit() {
|
|
|
_ = lib.Nats.Publish(m.Reply, b)
|
|
|
})
|
|
|
|
|
|
+ // 请求-响应 获取公司 通过秘钥
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_key", "Cold_ReadCompanyByT_key", func(m *nats.Msg) {
|
|
|
+ fmt.Printf("Cold_ReadCompanyByT_key message: %s\n", string(m.Data))
|
|
|
+
|
|
|
+ type T_R struct {
|
|
|
+ Code int16 `xml:"Code"`
|
|
|
+ Msg string `xml:"Msg"`
|
|
|
+ Data Account.Company `xml:"Data"` // 泛型
|
|
|
+ }
|
|
|
+
|
|
|
+ var t_R T_R
|
|
|
+
|
|
|
+ company, err := Account.Read_Company_ByKey(string(m.Data))
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t_R.Code = 202
|
|
|
+ t_R.Msg = err.Error()
|
|
|
+ b, _ := msgpack.Marshal(&t_R)
|
|
|
+ _ = lib.Nats.Publish(m.Reply, b)
|
|
|
+ }
|
|
|
+
|
|
|
+ t_R.Code = 200
|
|
|
+ t_R.Msg = "ok"
|
|
|
+ t_R.Data = company
|
|
|
+
|
|
|
+ b, _ := msgpack.Marshal(&t_R)
|
|
|
+ _ = lib.Nats.Publish(m.Reply, b)
|
|
|
+ })
|
|
|
+
|
|
|
// 请求-响应 获取所有用户列表
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_User_UserListAll","Cold_User_UserListAll", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_User_UserListAll", "Cold_User_UserListAll", func(m *nats.Msg) {
|
|
|
|
|
|
type T_R struct {
|
|
|
Code int16 `xml:"Code"`
|
|
@@ -219,7 +248,7 @@ func NatsInit() {
|
|
|
_ = lib.Nats.Publish(m.Reply, b)
|
|
|
})
|
|
|
// 请求-响应 检查用户权限
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_User_CheckUserPermissions","Cold_User_CheckUserPermissions", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_User_CheckUserPermissions", "Cold_User_CheckUserPermissions", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_User_CheckUserPermissions message: %s\n", string(m.Data))
|
|
|
type T_Req struct {
|
|
|
Power_Id int `xml:"Power_Id"` // 权限id
|
|
@@ -321,7 +350,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 获取设备
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceByT_sn","Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceByT_sn", "Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
|
|
|
fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
|
|
|
|
|
|
type T_R struct {
|
|
@@ -350,7 +379,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 获取传感器列表
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceSensorALLByT_sn","Cold_ReadDeviceSensorALLByT_sn", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceSensorALLByT_sn", "Cold_ReadDeviceSensorALLByT_sn", func(m *nats.Msg) {
|
|
|
fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
|
|
|
|
|
|
type T_R struct {
|
|
@@ -372,7 +401,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 获取设备数据列表
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataListBy_T_snid","Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataListBy_T_snid", "Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_ReadDeviceDataListBy_T_snid message: %s\n", string(m.Data))
|
|
|
type T_Req struct {
|
|
|
T_snid string `xml:"T_snid"`
|
|
@@ -411,7 +440,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 通过key获取传感器列表
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_CompanyDeviceSensor_List_ByKey","Cold_CompanyDeviceSensor_List_ByKey",func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_CompanyDeviceSensor_List_ByKey", "Cold_CompanyDeviceSensor_List_ByKey", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_CompanyDeviceSensor_List_ByKey message: %s\n", string(m.Data))
|
|
|
type T_Req struct {
|
|
|
T_sn string `xml:"T_sn"`
|
|
@@ -459,8 +488,8 @@ func NatsInit() {
|
|
|
_ = lib.Nats.Publish(m.Reply, b)
|
|
|
})
|
|
|
|
|
|
- // 请求-响应 根据时间获取设备数据(单条)
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataBy_T_snid_T_time","Cold_ReadDeviceDataBy_T_snid_T_time", func(m *nats.Msg) {
|
|
|
+ // 请求-响应 根据时间获取设备数据(单条)最新数据
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataBy_T_snid_T_time", "Cold_ReadDeviceDataBy_T_snid_T_time", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_ReadDeviceDataBy_T_snid_T_time message: %s\n", string(m.Data))
|
|
|
type T_Req struct {
|
|
|
T_sn string `xml:"T_sn"`
|
|
@@ -495,7 +524,7 @@ func NatsInit() {
|
|
|
})
|
|
|
|
|
|
// 请求-响应 获取设备
|
|
|
- _, _ = lib.Nats.QueueSubscribe("Cold_ReadDevice_List","Cold_ReadDevice_List", func(m *nats.Msg) {
|
|
|
+ _, _ = lib.Nats.QueueSubscribe("Cold_ReadDevice_List", "Cold_ReadDevice_List", func(m *nats.Msg) {
|
|
|
fmt.Printf("Cold_ReadDevice_List message: %s\n", string(m.Data))
|
|
|
type T_Req struct {
|
|
|
Key string `xml:"Key"`
|