add query dbperson info by id
| | |
| | | "sync" |
| | | "encoding/base64" |
| | | |
| | | "cache/esutil" |
| | | "cache/shardmap" |
| | | "basic.com/pubsub/cache.git/esutil" |
| | | "basic.com/pubsub/cache.git/shardmap" |
| | | |
| | | "basic.com/valib/gosdk.git" |
| | | ) |
| | |
| | | } |
| | | |
| | | // 根据底库id查询底库信息 |
| | | //func Dbpersoninfosbyid (id string) (protomsg.Baseinfo, error) { |
| | | // var dbinfo protomsg.Baseinfo |
| | | // |
| | | // url := fmt.Sprintf("http://192.168.1.182:9200/dbtablepersons/dbpersons/_search", id) |
| | | // buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtablepersons/dbpersons/_search",[]byte(dbinfoRequest)) |
| | | // if err != nil { |
| | | // return dbinfo, nil |
| | | // } |
| | | // |
| | | // sources, err := Sourcelist(buf) |
| | | // if err != nil {} |
| | | //} |
| | | func Dbpersoninfosbyid (id string) (protomsg.Baseinfo, error) { |
| | | var dbinfo protomsg.Baseinfo |
| | | |
| | | var dbinfoRequest = ` |
| | | { |
| | | "query":{ |
| | | "terms":{ |
| | | "_id":[ |
| | | "`+ id +`" |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtablepersons/_search",[]byte(dbinfoRequest)) |
| | | if err != nil { |
| | | return dbinfo, err |
| | | } |
| | | |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return dbinfo , err |
| | | } |
| | | |
| | | baseinfo := Dbpersonbyid(sources) |
| | | return baseinfo, nil |
| | | } |
| | | |
| | | |
| | | // 根据tableid 查询tablename |
| | |
| | | return |
| | | } |
| | | |
| | | func Dbpersonbyid(sources []map[string]interface{}) (protomsg.Baseinfo) { |
| | | var ok bool |
| | | |
| | | var tmpinfo protomsg.Baseinfo |
| | | for _, source := range sources{ |
| | | tmpinfo.FaceFeature, ok = source["faceFeature"].(string) |
| | | Isnil("faceFeature", ok) |
| | | tmpinfo.PersonId, ok = source["id"].(string) |
| | | Isnil("id", ok) |
| | | tmpinfo.TableId, ok = source["tableId"].(string) |
| | | Isnil("tableId", ok) |
| | | |
| | | 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) |
| | | |
| | | //根据 tableid 获取 tablename |
| | | name, _:= Dbtablename(tmpinfo.TableId) |
| | | tmpinfo.TableName= name |
| | | } |
| | | |
| | | return tmpinfo |
| | | } |
| | | |
| | | func Sourcelist(buf []byte)(sources []map[string]interface{}, err error){ |
| | | var info interface{} |
| | | json.Unmarshal(buf, &info) |
| | |
| | | if !ok { |
| | | return nil, errors.New("http response interface can not change map[string]interface{}") |
| | | } |
| | | |
| | | middle, ok := out["hits"].(map[string]interface{}) |
| | | if !ok { |
| | | return nil, errors.New("first hits change error!") |