|
@@ -3,8 +3,11 @@ package NatsServer
|
|
|
import (
|
|
|
"Cold_GoodsOrder/lib"
|
|
|
"Cold_GoodsOrder/models/Account"
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
+ "github.com/astaxie/beego/logs"
|
|
|
"github.com/vmihailenco/msgpack/v5"
|
|
|
+ "strconv"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -76,3 +79,28 @@ func CheckUserPermissions(Power_Id int, Req_Url string) bool {
|
|
|
|
|
|
return t_R.Pass
|
|
|
}
|
|
|
+
|
|
|
+func Read_Company_ById(T_id int) (d Account.Company, err error) {
|
|
|
+ msg, err := lib.Nats.Request("Cold_ReadCompanyByT_id", []byte(strconv.Itoa(T_id)), 3*time.Second)
|
|
|
+ if err != nil {
|
|
|
+ return d, err
|
|
|
+ }
|
|
|
+ type T_R struct {
|
|
|
+ Code int16 `xml:"Code"`
|
|
|
+ Msg string `xml:"Msg"`
|
|
|
+ Data Account.Company `xml:"Data"` // 泛型
|
|
|
+ }
|
|
|
+ var t_R T_R
|
|
|
+
|
|
|
+ err = msgpack.Unmarshal(msg.Data, &t_R)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
+ return d, err
|
|
|
+ }
|
|
|
+
|
|
|
+ if t_R.Code != 200 {
|
|
|
+ return d, errors.New(t_R.Msg)
|
|
|
+ }
|
|
|
+
|
|
|
+ return t_R.Data, nil
|
|
|
+}
|