|
@@ -427,28 +427,34 @@ func GetEdbdataClassify(userId int64) (items []*EdbdataClassifyList, err error)
|
|
|
}
|
|
|
classifyLen := len(newItems)
|
|
|
|
|
|
+ // 获取子集分类
|
|
|
+ var allChildItems []*EdbdataClassify
|
|
|
+ if userId > 0 {
|
|
|
+ userClassifyList, _ := GetManualUserClassify(int(userId))
|
|
|
+ var userIdArr []int
|
|
|
+ for _, v := range userClassifyList {
|
|
|
+ userIdArr = append(userIdArr, v.ClassifyId)
|
|
|
+ }
|
|
|
+ num := len(userClassifyList)
|
|
|
+ if num > 0 {
|
|
|
+ childSql := "SELECT a.classify_id,a.classify_name,a.parent_id FROM edbdata_classify AS a WHERE a.is_show=1 and a.classify_id IN(" + utils.GetOrmInReplace(num) + ") ORDER BY a.create_time ASC "
|
|
|
+ _, err = o.Raw(childSql, userIdArr).QueryRows(&allChildItems)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ childSql := "SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 ORDER BY create_time ASC "
|
|
|
+ _, err = o.Raw(childSql).QueryRows(&allChildItems)
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
for i := 0; i < classifyLen; i++ {
|
|
|
var childItems []*EdbdataClassify
|
|
|
parentId := newItems[i].ClassifyId
|
|
|
- childSql := ``
|
|
|
- if userId > 0 {
|
|
|
- userClassifyList, _ := GetManualUserClassify(int(userId))
|
|
|
- var userIdArr []string
|
|
|
- for _, v := range userClassifyList {
|
|
|
- userIdArr = append(userIdArr, strconv.Itoa(v.ClassifyId))
|
|
|
- }
|
|
|
-
|
|
|
- userIdStr := strings.Join(userIdArr, ",")
|
|
|
- if userIdStr != "" {
|
|
|
- childSql = "SELECT a.classify_id,a.classify_name,a.parent_id FROM edbdata_classify AS a WHERE a.is_show=1 and a.classify_id IN(" + userIdStr + ") AND parent_id=? ORDER BY a.create_time ASC "
|
|
|
- _, err = o.Raw(childSql, parentId).QueryRows(&childItems)
|
|
|
+ for _, v := range allChildItems {
|
|
|
+ if v.ParentId == parentId {
|
|
|
+ childItems = append(childItems, v)
|
|
|
}
|
|
|
- } else {
|
|
|
- childSql = "SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 and parent_id=? ORDER BY create_time ASC "
|
|
|
- _, err = o.Raw(childSql, parentId).QueryRows(&childItems)
|
|
|
- }
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
}
|
|
|
newItems[i].Child = childItems
|
|
|
}
|
|
@@ -1473,13 +1479,17 @@ type EdbInfoGroupCount struct {
|
|
|
}
|
|
|
|
|
|
// GetEdbInfoGroupCountByClassifyIds 根据指标分类id获取当前分类下的指标数量
|
|
|
-func GetEdbInfoGroupCountByClassifyIds(classifyIds string) (list []*EdbInfoGroupCount, err error) {
|
|
|
+func GetEdbInfoGroupCountByClassifyIds(classifyIdList []int) (list []*EdbInfoGroupCount, err error) {
|
|
|
+ num := len(classifyIdList)
|
|
|
+ if num <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT COUNT(1) AS count,classify_id FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a
|
|
|
INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
|
|
|
- WHERE a.classify_id in (` + classifyIds + `) group by a.TRADE_CODE) d
|
|
|
+ WHERE a.classify_id in (` + utils.GetOrmInReplace(num) + `) group by a.TRADE_CODE) d
|
|
|
GROUP BY classify_id `
|
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, classifyIdList).QueryRows(&list)
|
|
|
return
|
|
|
}
|
|
|
|