From 9f0063dfc00a9d74b868c9b6b299fac2103c9c03 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期三, 15 七月 2020 15:54:04 +0800
Subject: [PATCH] cameraRule save ret data
---
dbpersonApi.go | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 153 insertions(+), 14 deletions(-)
diff --git a/dbpersonApi.go b/dbpersonApi.go
index e874769..c30a0b3 100644
--- a/dbpersonApi.go
+++ b/dbpersonApi.go
@@ -7,11 +7,25 @@
)
type DbPersonApi struct {
+ Ip string
+ Port int
+}
+func (api DbPersonApi) getBasicUrl() string {
+ if api.Ip == "" {
+ return BASIC_URL
+ }
+ if api.Ip == "" {
+ api.Ip = DEFAULT_IP
+ }
+ if api.Port == 0 {
+ api.Port = DEFAULT_PORT
+ }
+ return "http://"+api.Ip+":"+strconv.Itoa(api.Port)
}
func (api DbPersonApi) QueryDbPersonsByTbId(paramBody map[string]interface{}) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/queryDbPersonsByTbId"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/queryDbPersonsByTbId"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
if err != nil {
@@ -27,7 +41,7 @@
}
func (api DbPersonApi) UpdateDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/updateDbPerson"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/updateDbPerson"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
if err != nil {
@@ -42,8 +56,29 @@
return res.Success,res.Data
}
+func (api DbPersonApi) UpdateFace(id string,faceFeature string, pic string) (bool,interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/updateFace"
+ client := NewClient()
+ paramBody := map[string]interface{}{
+ "id": id,
+ "faceFeature": faceFeature,
+ "personPicUrl": pic,
+ }
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ return false,nil
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ return false,nil
+ }
+
+ return res.Success,res.Data
+}
+
func (api DbPersonApi) AddDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/addDbPerson"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/addDbPerson"
client := NewClient()
body,err := client.DoPutRequest(url,CONTENT_TYPE_JSON, paramBody,nil)
if err != nil {
@@ -59,7 +94,7 @@
}
func (api DbPersonApi) DeleteDbPerson(id string) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/deleteDbPersonById/"+id
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/deleteDbPersonById/"+id
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,nil,nil)
if err != nil {
@@ -75,7 +110,7 @@
}
func (api DbPersonApi) DeleteMoreDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/deleteMoreDbPerson"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/deleteMoreDbPerson"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
if err != nil {
@@ -91,7 +126,7 @@
}
func (api DbPersonApi) DeletePersonsByTbId(tableId string) (bool,interface{}) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/deletePersonsByTbId/"+tableId
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/deletePersonsByTbId/"+tableId
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,nil,nil)
if err != nil {
@@ -108,7 +143,7 @@
//鏍规嵁搴曞簱浜哄憳id鏌ヨ浜哄憳淇℃伅璇︽儏
func (api DbPersonApi) Dbpersoninfosbyid (ids []string) (persons []protomsg.Dbperson,err error) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/dbPersonInfoByIds"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/dbPersonInfoByIds"
client := NewClient()
paramBody := map[string]interface{}{
"ids": ids,
@@ -129,11 +164,13 @@
return persons,nil
}
-func (api DbPersonApi) GetPersonTotal () (total int64,err error) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/getPersonTotal"
+func (api DbPersonApi) GetPersonTotal (tableId string) (total int64,err error) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/getPersonTotal"
client := NewClient()
-
- body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,nil,nil)
+ paramBody := map[string]string{
+ "tableId": tableId,
+ }
+ body,err := client.DoGetRequest(url, paramBody,nil)
if err != nil {
return 0,err
}
@@ -143,11 +180,11 @@
return 0,err
}
- return res.Data.(int64),nil
+ return int64(res.Data.(float64)),nil
}
func (api DbPersonApi) GetPersonsCompareCacheBase (from int,size int) (persons []*protomsg.Esinfo,err error) {
- url := BASIC_URL + DATA_URL_PREFIX + "/dbperson/getPersonsCompareCacheBase"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/getPersonsCompareCacheBase"
client := NewClient()
paramBody := map[string]string{
"from": strconv.Itoa(from),
@@ -163,12 +200,114 @@
return nil,err
}
dataBytes, _ := json.Marshal(res.Data)
+
var arr []protomsg.Esinfo
if err = json.Unmarshal(dataBytes, &arr);err !=nil {
return nil,err
}
for _,ei :=range arr {
- persons = append(persons,&ei)
+ persons = append(persons,&protomsg.Esinfo{
+ Id: ei.Id,
+ Tableid: ei.Tableid,
+ FaceFeature: ei.FaceFeature,
+ Enable: ei.Enable,
+
+ CarNo: ei.CarNo,
+ })
}
return persons,nil
+}
+
+func (api DbPersonApi) FindLikePersonIds (tableIds []string,inputValue string) (interface{},error) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/findLikePersonIds"
+ client := NewClient()
+ paramBody := map[string]interface{}{
+ "tableIds": tableIds,
+ "inputValue": inputValue,
+ }
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ return nil,err
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ return nil,err
+ }
+ return res.Data,nil
+}
+
+func (api DbPersonApi) JoinDbTable (tableIds []string,faceFeature string, personPicUrl string) (bool,interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/joinDbTable"
+ client := NewClient()
+ paramBody := map[string]interface{}{
+ "tableIds": tableIds,
+ "faceFeature": faceFeature,
+ "personPicUrl": personPicUrl,
+ }
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ return false,nil
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ return false,nil
+ }
+ return res.Success,res.Data
+}
+
+func (api DbPersonApi) Move (personId string,tableIds []string) (bool,interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/move"
+ client := NewClient()
+ paramBody := map[string]interface{}{
+ "personId": personId,
+ "tableIds": tableIds,
+ }
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ return false,nil
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ return false,nil
+ }
+ return res.Success,res.Data
+}
+
+func (api DbPersonApi) Copy (personId string,tableIds []string) (bool,interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/copy"
+ client := NewClient()
+ paramBody := map[string]interface{}{
+ "personId": personId,
+ "tableIds": tableIds,
+ }
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ return false,nil
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ return false,nil
+ }
+ return res.Success,res.Data
+}
+
+func (api DbPersonApi) MultiUploadCarNo(paramBody map[string]interface{}) bool {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbperson/multiUploadCarNo"
+ client := NewClient()
+ body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+ if err != nil {
+ logPrint("multiUploadCarNo err:", err)
+ return false
+ }
+
+ var res Result
+ if err = json.Unmarshal(body, &res); err != nil {
+ logPrint("unmarshal err:",err)
+ return false
+ }
+ return res.Success
}
\ No newline at end of file
--
Gitblit v1.8.0