From 01dfd9dc8de7b19f9dfa4284722e01bbd5837801 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 19 一月 2024 09:10:30 +0800
Subject: [PATCH] replace json to json-iterator

---
 dbpersonApi.go |  226 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 120 insertions(+), 106 deletions(-)

diff --git a/dbpersonApi.go b/dbpersonApi.go
index efc1c92..443a294 100644
--- a/dbpersonApi.go
+++ b/dbpersonApi.go
@@ -2,319 +2,333 @@
 
 import (
 	"basic.com/pubsub/protomsg.git"
-	json "github.com/json-iterator/go"
+	jsoniter "github.com/json-iterator/go"
 	"strconv"
 )
 
 type DbPersonApi struct {
-
 }
 
-func (api DbPersonApi) QueryDbPersonsByTbId(paramBody map[string]interface{}) (bool,interface{}) {
+func (api DbPersonApi) QueryDbPersonsByTbId(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/queryDbPersonsByTbId"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) UpdateDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
+func (api DbPersonApi) UpdateDbPerson(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/updateDbPerson"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) UpdateFace(id string,faceFeature string, pic string) (bool,interface{}) {
+func (api DbPersonApi) UpdateFace(id string, faceFeature string, pic string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/updateFace"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
-		"id": id,
-		"faceFeature": faceFeature,
+		"id":           id,
+		"faceFeature":  faceFeature,
 		"personPicUrl": pic,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) AddDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
+func (api DbPersonApi) AddDbPerson(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/addDbPerson"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body,err := client.DoPutRequest(url,CONTENT_TYPE_JSON, paramBody,nil)
+	body, err := client.DoPutRequest(url, CONTENT_TYPE_JSON, paramBody, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) DeleteDbPerson(id string) (bool,interface{}) {
+func (api DbPersonApi) DeleteDbPerson(id string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/deleteDbPersonById"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramQuery := map[string]string {
+	paramQuery := map[string]string{
 		"id": id,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,paramQuery,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, nil, paramQuery, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) DeleteMoreDbPerson(paramBody map[string]interface{}) (bool,interface{}) {
+func (api DbPersonApi) DeleteMoreDbPerson(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/deleteMoreDbPerson"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) DeletePersonsByTbId(tableId string) (bool,interface{}) {
+func (api DbPersonApi) DeletePersonsByTbId(tableId string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/deletePersonsByTbId"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramQuery := map[string]string {
+	paramQuery := map[string]string{
 		"tableId": tableId,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,paramQuery,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, nil, paramQuery, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
 //鏍规嵁搴曞簱浜哄憳id鏌ヨ浜哄憳淇℃伅璇︽儏
-func (api DbPersonApi) Dbpersoninfosbyid (ids []string) (persons []protomsg.Dbperson,err error) {
+func (api DbPersonApi) Dbpersoninfosbyid(ids []string) (persons []protomsg.Dbperson, err error) {
 	url := DATA_URL_PREFIX + "/dbperson/dbPersonInfoByIds"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
 		"ids": ids,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return nil,err
+		return nil, err
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return nil,err
+		return nil, err
 	}
 	dataBytes, _ := json.Marshal(res.Data)
-	if err = json.Unmarshal(dataBytes, &persons);err !=nil {
-		return nil,err
+	if err = json.Unmarshal(dataBytes, &persons); err != nil {
+		return nil, err
 	}
-	return persons,nil
+	return persons, nil
 }
 
-func (api DbPersonApi) GetPersonTotal (tableId string) (total int64,err error) {
+func (api DbPersonApi) GetPersonTotal(tableId string) (total int64, err error) {
 	url := DATA_URL_PREFIX + "/dbperson/getPersonTotal"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]string{
 		"tableId": tableId,
 	}
-	body,err := client.DoGetRequest(url, paramBody,nil)
+	body, err := client.DoGetRequest(url, paramBody, nil)
 	if err != nil {
-		return 0,err
+		return 0, err
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return 0,err
+		return 0, err
 	}
 
-	return int64(res.Data.(float64)),nil
+	return int64(res.Data.(float64)), nil
 }
 
-func (api DbPersonApi) GetPersonsCompareCacheBase (from int,size int) (persons []*protomsg.Esinfo,err error) {
+func (api DbPersonApi) GetPersonsCompareCacheBase(from int, size int) (persons []*protomsg.Esinfo, err error) {
 	url := DATA_URL_PREFIX + "/dbperson/getPersonsCompareCacheBase"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]string{
 		"from": strconv.Itoa(from),
 		"size": strconv.Itoa(size),
 	}
-	body,err := client.DoGetRequest(url, paramBody,nil)
+	body, err := client.DoGetRequest(url, paramBody, nil)
 	if err != nil {
-		return nil,err
+		return nil, err
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return nil,err
+		return nil, err
 	}
 	dataBytes, _ := json.Marshal(res.Data)
 
 	var arr []protomsg.Esinfo
-	if err = json.Unmarshal(dataBytes, &arr);err !=nil {
-		return nil,err
+	if err = json.Unmarshal(dataBytes, &arr); err != nil {
+		return nil, err
 	}
-	for _,ei :=range arr {
-		persons = append(persons,&protomsg.Esinfo{
-			Id: ei.Id,
-			Tableid: ei.Tableid,
+	for _, ei := range arr {
+		persons = append(persons, &protomsg.Esinfo{
+			Id:          ei.Id,
+			Tableid:     ei.Tableid,
 			FaceFeature: ei.FaceFeature,
-			Enable: ei.Enable,
+			Enable:      ei.Enable,
 
 			CarNo: ei.CarNo,
 		})
 	}
-	return persons,nil
+	return persons, nil
 }
 
-func (api DbPersonApi) FindLikePersonIds (tableIds  []string,inputValue string) (interface{},error) {
+func (api DbPersonApi) FindLikePersonIds(tableIds []string, inputValue string) (interface{}, error) {
 	url := DATA_URL_PREFIX + "/dbperson/findLikePersonIds"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
-		"tableIds": tableIds,
+		"tableIds":   tableIds,
 		"inputValue": inputValue,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return nil,err
+		return nil, err
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return nil,err
+		return nil, err
 	}
-	return res.Data,nil
+	return res.Data, nil
 }
 
-func (api DbPersonApi) JoinDbTable (tableIds  []string,faceFeature string, personPicUrl string) (bool,interface{}) {
+func (api DbPersonApi) JoinDbTable(tableIds []string, faceFeature string, personPicUrl string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/joinDbTable"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
-		"tableIds": tableIds,
-		"faceFeature": faceFeature,
+		"tableIds":     tableIds,
+		"faceFeature":  faceFeature,
 		"personPicUrl": personPicUrl,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) Move (personId string,tableIds []string) (bool,interface{}) {
+func (api DbPersonApi) Move(personId string, tableIds []string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/move"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
 		"personId": personId,
 		"tableIds": tableIds,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api DbPersonApi) Copy (personId string,tableIds []string) (bool,interface{}) {
+func (api DbPersonApi) Copy(personId string, tableIds []string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/dbperson/copy"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
 		"personId": personId,
 		"tableIds": tableIds,
 	}
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
 func (api DbPersonApi) MultiUploadCarNo(paramBody map[string]interface{}) bool {
 	url := DATA_URL_PREFIX + "/dbperson/multiUploadCarNo"
-	netNode := getNetNode(url2Topic(Topic_CompTable_Service,url))
+	netNode := getNetNode(url2Topic(Topic_CompTable_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
 		logPrint("multiUploadCarNo err:", err)
 		return false
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		logPrint("unmarshal err:",err)
+		logPrint("unmarshal err:", err)
 		return false
 	}
 	return res.Success
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0