From b7a57cd830201952d76b5df4c7e10097317d4f10 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期日, 29 九月 2019 15:25:23 +0800
Subject: [PATCH] fix EsApi
---
EsClient.go | 81 +++++++++++++++++++++++++++++++++++++---
1 files changed, 75 insertions(+), 6 deletions(-)
diff --git a/EsClient.go b/EsClient.go
index 5425b87..9a69741 100644
--- a/EsClient.go
+++ b/EsClient.go
@@ -7,7 +7,8 @@
"fmt"
"io/ioutil"
"net/http"
- "time"
+ "strconv"
+ "time"
"basic.com/pubsub/protomsg.git"
)
@@ -16,7 +17,7 @@
func Parsesources(sources []map[string]interface{}) (esinfos []*protomsg.Esinfo) {
var ok bool
for _, source := range sources {
- tmpinfo := protomsg.Esinfo{}
+ var tmpinfo protomsg.Esinfo
tmpinfo.FaceFeature, ok = source["faceFeature"].(string)
if !ok {
continue
@@ -221,13 +222,81 @@
return tmpinfos
}
+//瑙f瀽搴曞簱浜哄憳缁撴瀯
+func Dbpersonbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbperson) {
+ var ok bool
+
+ var tmpinfo protomsg.Dbperson
+ for _, source := range sources{
+ tmpinfo.FaceFeature, ok = source["faceFeature"].(string)
+ if !ok {
+ continue
+ }
+
+ tmpinfo.Id, ok = source["id"].(string)
+ if !ok {
+ continue
+ }
+
+ tmpinfo.TableId, ok = source["tableId"].(string)
+ if !ok {
+ continue
+ }
+
+ tmpinfo.PersonName,ok = source["personName"].(string)
+ Isnil("personName", ok)
+ tmpinfo.PersonPicUrl,ok = source["personPicUrl"].(string)
+ Isnil("personPicUrl", ok)
+ tmpinfo.PhoneNum,ok = source["phoneNum"].(string)
+ Isnil("phoneNum", ok)
+ tmpinfo.Sex,ok = source["sex"].(string)
+ Isnil("sex", ok)
+ tmpinfo.IdCard,ok = source["idCard"].(string)
+ Isnil("idCard", ok)
+ tmpinfo.MonitorLevel,ok = source["monitorLevel"].(string)
+ Isnil("monitorLevel",ok)
+ tmpinfo.UpdateTime,ok = source["updateTime"].(string)
+ Isnil("updateTime",ok)
+ tmpinfo.Age,ok = source["age"].(string)
+ Isnil("age", ok)
+
+ isDelete,ok := source["isDelete"].(float64)
+ if ok {
+ tmpinfo.IsDelete= int32(isDelete)
+ }
+ Isnil("isDelete", ok)
+
+ enable,ok := source["enable"].(float64)
+ if ok {
+ tmpinfo.Enable= int32(enable)
+ }
+ Isnil("endTime", ok)
+
+ tmpinfo.Reserved,ok = source["reserved"].(string)
+ Isnil("reserved",ok)
+ tmpinfo.PicDesc,ok = source["picDesc"].(string)
+ Isnil("picDesc",ok)
+ tmpinfo.CreateTime,ok = source["createTime"].(string)
+ Isnil("createTime",ok)
+ tmpinfo.CreateBy,ok = source["createBy"].(string)
+ Isnil("createBy",ok)
+
+ //鏍规嵁 tableid 鑾峰彇 tablename
+ //name, _:= Dbtablename(tmpinfo.TableId)
+ //tmpinfo.TableName= name
+ tmpinfos = append(tmpinfos, tmpinfo)
+ }
+
+ return tmpinfos
+}
+
//瑙f瀽搴曞簱缁撴瀯
func Dbtablebyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbtable) {
var ok bool
- //var tmpinfo protomsg.Dbtable
+ var tmpinfo protomsg.Dbtable
for _, source := range sources{
- tmpinfo := protomsg.Dbtable{}
+
tmpinfo.Id, ok = source["id"].(string)
if !ok {
continue
@@ -303,7 +372,7 @@
}
return sources,nil
}
-//slice scroll 瑙f瀽宸ュ叿鍑芥暟
+
func Sourcelistforscroll(buf []byte)(datasource map[string]interface{}, err error){
var data = make(map[string]interface{})
var info interface{}
@@ -344,7 +413,7 @@
}
func EsReq(method string, url string, parama []byte) (buf []byte, err error) {
- defer elapsed("page")()
+ //defer elapsed("page")()
timeout := time.Duration(10 * time.Second)
client := http.Client{
Timeout: timeout,
--
Gitblit v1.8.0