|
@@ -48,7 +48,7 @@ func initFwKeyWordRoot(ctx context.Context) *seoFwKeyWordRoot {
|
|
|
mapping, nameMapping = map[string]*FWKeyWordNode{}, map[string]*FWKeyWordNode{}
|
|
|
allKeyword, hotKeyWord, commonKeyword []*FWKeyWordNode
|
|
|
)
|
|
|
- res, err := g.DB().Query(ctx, "SELECT id,keyword,configJson FROM new_keyword_unified WHERE unifiedSign=? AND state=1", "fw")
|
|
|
+ res, err := g.DB().Query(ctx, "SELECT id,keyword,configJson FROM new_keyword_unified WHERE unifiedSign=? AND state=1 order by id asc", "fw")
|
|
|
if err != nil {
|
|
|
g.Log().Errorf(ctx, "initFwKeyWordRoot 获取服务异常 %v", err)
|
|
|
}
|
|
@@ -233,3 +233,31 @@ func (aRoot *seoFwKeyWordRoot) GetZimuGroup() []*ziMuGroup {
|
|
|
aRoot.ziMuGroup = finalVal
|
|
|
return finalVal
|
|
|
}
|
|
|
+
|
|
|
+func (aRoot *seoFwKeyWordRoot) GetSortFw(code string, limit int) []*FWKeyWordNode {
|
|
|
+ var (
|
|
|
+ returnArr []*FWKeyWordNode
|
|
|
+ find = false
|
|
|
+ )
|
|
|
+ for _, node := range aRoot.commonKeyword {
|
|
|
+ if node.Code == code {
|
|
|
+ find = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if find {
|
|
|
+ returnArr = append(returnArr, node)
|
|
|
+ }
|
|
|
+ if len(returnArr) >= limit {
|
|
|
+ return returnArr
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, node := range aRoot.commonKeyword {
|
|
|
+ returnArr = append(returnArr, node)
|
|
|
+ if len(returnArr) >= limit {
|
|
|
+ return returnArr
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return returnArr
|
|
|
+}
|