From ef51da5404827e826e979ad614950a9e0192f4c6 Mon Sep 17 00:00:00 2001
From: qixiaoning <jony.kee@outlook.com>
Date: 星期五, 08 八月 2025 09:15:26 +0800
Subject: [PATCH] 调整数据推送相关接口

---
 system-service/controllers/dictionary.go |  118 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/system-service/controllers/dictionary.go b/system-service/controllers/dictionary.go
index 416f211..a670cc7 100644
--- a/system-service/controllers/dictionary.go
+++ b/system-service/controllers/dictionary.go
@@ -8,36 +8,37 @@
 	"basic.com/valib/bhomeclient.git"
 	"basic.com/valib/bhomedbapi.git"
 	"basic.com/valib/logger.git"
-	"github.com/satori/go.uuid"
+	uuid "github.com/satori/go.uuid"
 )
 
 type DictionaryController struct {
 }
 
 type DicTypeVo struct {
-	Type string              	`json:"type"`
-	Dics []DicWithChildren 		`json:"dics"`
+	Type string            `json:"type"`
+	Dics []DicWithChildren `json:"dics"`
 }
 
 type DicWithChildren struct {
 	models.Dictionary
-	Children 	[]DicWithChildren 	`json:"children"`
+	Children []DicWithChildren `json:"children"`
 }
 
 type DicList []DicWithChildren
-func (dl DicList) Len()int {
+
+func (dl DicList) Len() int {
 	return len(dl)
 }
-func (dl DicList) Swap(i,j int) {
-	dl[i],dl[j] = dl[j],dl[i]
+func (dl DicList) Swap(i, j int) {
+	dl[i], dl[j] = dl[j], dl[i]
 }
-func (dl DicList) Less(i,j int) bool {
+func (dl DicList) Less(i, j int) bool {
 	return dl[i].Sort < dl[j].Sort
 }
 
 func recursiveChildren(parentId string, allList *[]models.Dictionary) []DicWithChildren {
 	var children = make([]DicWithChildren, 0)
-	for _,d := range *allList {
+	for _, d := range *allList {
 		if d.ParentId == parentId {
 			dwc := DicWithChildren{}
 			dwc.Dictionary = d
@@ -70,7 +71,7 @@
 	resMap := make(map[string]DicList, 0)
 
 	wg := &sync.WaitGroup{}
-	wg.Add(4)
+	wg.Add(2)
 	go func() {
 		defer wg.Done()
 		for _, dic := range allDics {
@@ -102,47 +103,47 @@
 			}
 		}
 	}()
-	//浜哄憳搴曞簱
-	personTableList := make(DicList, 0)
-	var tableApi bhomedbapi.DbTableApi
-	go func() {
-		defer wg.Done()
-		personTables, dtErr := tableApi.FindAllDbTablesByType("0", "person")
-		if dtErr == nil && personTables != nil {
-			for idx, t := range personTables {
-				dwc := DicWithChildren{}
-				dwc.Dictionary = models.Dictionary{
-					Value: t.Id,
-					Name:  t.TableName,
-					Sort:  idx + 1,
-				}
-				personTableList = append(personTableList, dwc)
-			}
-		}
-	}()
-	// 杞﹁締搴曞簱
-	carTableList := make(DicList, 0)
-	go func() {
-		defer wg.Done()
-		carTables, _ := tableApi.FindAllDbTablesByType("0", "car")
-		if carTables != nil {
-			for idx, t := range carTables {
-				dwc := DicWithChildren{}
-				dwc.Dictionary = models.Dictionary{
-					Value: t.Id,
-					Name:  t.TableName,
-					Sort:  idx + 1,
-				}
-				carTableList = append(carTableList, dwc)
-			}
-		}
-	}()
+	// //浜哄憳搴曞簱
+	// personTableList := make(DicList, 0)
+	// var tableApi bhomedbapi.DbTableApi
+	// go func() {
+	// 	defer wg.Done()
+	// 	personTables, dtErr := tableApi.FindAllDbTablesByType("0", "person")
+	// 	if dtErr == nil && personTables != nil {
+	// 		for idx, t := range personTables {
+	// 			dwc := DicWithChildren{}
+	// 			dwc.Dictionary = models.Dictionary{
+	// 				Value: t.Id,
+	// 				Name:  t.TableName,
+	// 				Sort:  idx + 1,
+	// 			}
+	// 			personTableList = append(personTableList, dwc)
+	// 		}
+	// 	}
+	// }()
+	// // 杞﹁締搴曞簱
+	// carTableList := make(DicList, 0)
+	// go func() {
+	// 	defer wg.Done()
+	// 	carTables, _ := tableApi.FindAllDbTablesByType("0", "car")
+	// 	if carTables != nil {
+	// 		for idx, t := range carTables {
+	// 			dwc := DicWithChildren{}
+	// 			dwc.Dictionary = models.Dictionary{
+	// 				Value: t.Id,
+	// 				Name:  t.TableName,
+	// 				Sort:  idx + 1,
+	// 			}
+	// 			carTableList = append(carTableList, dwc)
+	// 		}
+	// 	}
+	// }()
 
 	wg.Wait()
 
 	resMap["time_rule"] = timeList
-	resMap["compareBase"] = personTableList
-	resMap["compareCarBase"] = carTableList
+	// resMap["compareBase"] = personTableList
+	// resMap["compareCarBase"] = carTableList
 
 	for k, dList := range resMap {
 		v := dList
@@ -164,7 +165,7 @@
 func (controller DictionaryController) FindByParentId(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
 	parentId := c.Query("parentId")
 	if parentId == "" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+		return &bhomeclient.Reply{Msg: "鍙傛暟鏈夎"}
 	}
 	var model models.Dictionary
 	if flag, err := model.SelectById(parentId); !flag && err == nil {
@@ -174,20 +175,19 @@
 				Value: "",
 				Name:  "绌�",
 			}
-			return &bhomeclient.Reply{ Success: true, Data: []models.Dictionary{empty} }
+			return &bhomeclient.Reply{Success: true, Data: []models.Dictionary{empty}}
 		} else {
 			dics, err := model.FindByParentId(parentId)
 			if err != nil {
-				return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
+				return &bhomeclient.Reply{Msg: "鏌ヨ澶辫触"}
 			} else {
-				return &bhomeclient.Reply{ Success:true, Data: dics }
+				return &bhomeclient.Reply{Success: true, Data: dics}
 			}
 		}
 	} else {
-		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
+		return &bhomeclient.Reply{Msg: "鏌ヨ澶辫触"}
 	}
 }
-
 
 // @Summary 鏍规嵁type鏌ユ壘瀛楀吀鍒楄〃
 // @Description  鏍规嵁type鏌ユ壘瀛楀吀鍒楄〃
@@ -200,14 +200,14 @@
 func (controller DictionaryController) ListByType(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
 	typ := c.Query("type")
 	if typ == "" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+		return &bhomeclient.Reply{Msg: "鍙傛暟鏈夎"}
 	}
 	var model models.Dictionary
 	dics, err := model.FindByType(typ)
 	if err == nil {
-		return &bhomeclient.Reply{ Success:true, Data: dics }
+		return &bhomeclient.Reply{Success: true, Data: dics}
 	} else {
-		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
+		return &bhomeclient.Reply{Msg: "鏌ヨ澶辫触"}
 	}
 }
 
@@ -223,7 +223,7 @@
 func (controller DictionaryController) Save(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
 	var model models.Dictionary
 	if err := c.BindJSON(&model); err != nil {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+		return &bhomeclient.Reply{Msg: "鍙傛暟鏈夎"}
 	}
 	var flag bool
 	if model.Id == "" {
@@ -234,8 +234,8 @@
 	}
 
 	if !flag {
-		return &bhomeclient.Reply{ Msg: "淇濆瓨澶辫触"}
+		return &bhomeclient.Reply{Msg: "淇濆瓨澶辫触"}
 	} else {
-		return &bhomeclient.Reply{ Success:true, Msg: "淇濆瓨鎴愬姛"}
+		return &bhomeclient.Reply{Success: true, Msg: "淇濆瓨鎴愬姛"}
 	}
 }

--
Gitblit v1.8.0