package data_manage

import (
	"eta_gn/eta_api/global"
)

type ManualSysUser struct {
	ItemId   int              `description:"部门/组/用户 id"`
	ItemName string           `description:"部门/组/用户 名称"`
	Children []*ManualSysUser `gorm:"-"`
}

type ManualClassifyEdbInfoCount struct {
	ClassifyId int
	Total      int
}

func GetManualClassifyEdbInfoCount() (items []*ManualClassifyEdbInfoCount, err error) {
	sql := ` SELECT a.classify_id,COUNT(1) AS total FROM edbdata_classify AS a
			INNER JOIN edbinfo AS b ON a.classify_id=b.classify_id
			WHERE a.is_show=1
			GROUP BY a.classify_id `
	err = global.DmSQL["edb"].Raw(sql).Find(&items).Error
	return
}

// GetManualEdbInfoCountByClassifyId 根据手工指标分类id获取指标数
func GetManualEdbInfoCountByClassifyId(classifyId int) (total int, err error) {
	sql := ` SELECT COUNT(1) AS total FROM edbdata_classify AS a
			INNER JOIN edbinfo AS b ON a.classify_id=b.classify_id
			WHERE a.is_show=1 AND b.classify_id = ?`
	err = global.DmSQL["edb"].Raw(sql, classifyId).Scan(&total).Error
	return
}