From 293b6d664512c30d2e6b2ce80487ba6fa16598c3 Mon Sep 17 00:00:00 2001
From: huchanghua <huchanghua@basic.com>
Date: 星期五, 22 七月 2022 17:21:16 +0800
Subject: [PATCH] add SaveNotExistOrUpdate
---
dicApi.go | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/dicApi.go b/dicApi.go
index e56c940..72563c3 100644
--- a/dicApi.go
+++ b/dicApi.go
@@ -1,6 +1,7 @@
-package dbapi
+package bhomedbapi
import (
+ "basic.com/pubsub/protomsg.git"
"encoding/json"
)
@@ -11,9 +12,6 @@
func (api DicApi) FindByType(dicType string) (bool,interface{}) {
url := DATA_URL_PREFIX + "/dictionary/findByType"
netNode := getNetNode(url2Topic(Topic_System_Service, url))
- if netNode == nil {
- return false,nil
- }
client := NewClient(WithNodes(netNode))
paramMap := make(map[string]string)
paramMap["type"] = dicType
@@ -32,9 +30,6 @@
func (api DicApi) FindByParentId(parentId string) (bool,interface{}){
url := DATA_URL_PREFIX + "/dictionary/findByParentId"
netNode := getNetNode(url2Topic(Topic_System_Service, url))
- if netNode == nil {
- return false,nil
- }
client := NewClient(WithNodes(netNode))
paramMap := make(map[string]string)
paramMap["parentId"] = parentId
@@ -48,4 +43,29 @@
return false,nil
}
return res.Success,res.Data
+}
+
+func (api DicApi) ListByType(typ string) (flag bool,list []protomsg.Dic){
+ url := DATA_URL_PREFIX + "/dictionary/listByType"
+ netNode := getNetNode(url2Topic(Topic_System_Service, url))
+ client := NewClient(WithNodes(netNode))
+ paramMap := make(map[string]string)
+ paramMap["type"] = typ
+ respBody, err := client.DoGetRequest(url, paramMap, nil)
+ if err !=nil {
+ return false,nil
+ }
+ var res Result
+ if err = json.Unmarshal(respBody, &res); err != nil {
+ logPrint(err)
+ return false,nil
+ }
+ if res.Success {
+ dataBytes, _ := json.Marshal(res.Data)
+ if err = json.Unmarshal(dataBytes, &list);err !=nil {
+ return false,nil
+ }
+ return true, list
+ }
+ return false, nil
}
\ No newline at end of file
--
Gitblit v1.8.0