2021-09-11 14:04:09 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
2023-12-05 23:03:51 +08:00
|
|
|
"mayfly-go/internal/common/consts"
|
2022-09-09 18:26:08 +08:00
|
|
|
dbapp "mayfly-go/internal/db/application"
|
|
|
|
|
machineapp "mayfly-go/internal/machine/application"
|
2022-10-26 20:49:29 +08:00
|
|
|
mongoapp "mayfly-go/internal/mongo/application"
|
2022-09-09 18:26:08 +08:00
|
|
|
redisapp "mayfly-go/internal/redis/application"
|
2022-10-26 20:49:29 +08:00
|
|
|
tagapp "mayfly-go/internal/tag/application"
|
2023-01-14 16:29:52 +08:00
|
|
|
"mayfly-go/pkg/req"
|
2023-10-12 12:14:56 +08:00
|
|
|
"mayfly-go/pkg/utils/collx"
|
2021-09-11 14:04:09 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Index struct {
|
2024-01-21 22:52:20 +08:00
|
|
|
TagApp tagapp.TagTree `inject:"TagTreeApp"`
|
|
|
|
|
MachineApp machineapp.Machine `inject:""`
|
|
|
|
|
DbApp dbapp.Db `inject:""`
|
|
|
|
|
RedisApp redisapp.Redis `inject:""`
|
|
|
|
|
MongoApp mongoapp.Mongo `inject:""`
|
2021-09-11 14:04:09 +08:00
|
|
|
}
|
|
|
|
|
|
2023-01-14 16:29:52 +08:00
|
|
|
func (i *Index) Count(rc *req.Ctx) {
|
2023-11-07 21:05:21 +08:00
|
|
|
accountId := rc.GetLoginAccount().Id
|
2022-10-26 20:49:29 +08:00
|
|
|
|
2023-12-05 23:03:51 +08:00
|
|
|
mongoNum := len(i.TagApp.GetAccountResourceCodes(accountId, consts.TagResourceTypeMongo, ""))
|
|
|
|
|
machienNum := len(i.TagApp.GetAccountResourceCodes(accountId, consts.TagResourceTypeMachine, ""))
|
|
|
|
|
dbNum := len(i.TagApp.GetAccountResourceCodes(accountId, consts.TagResourceTypeDb, ""))
|
|
|
|
|
redisNum := len(i.TagApp.GetAccountResourceCodes(accountId, consts.TagResourceTypeRedis, ""))
|
2022-10-26 20:49:29 +08:00
|
|
|
|
2023-10-12 12:14:56 +08:00
|
|
|
rc.ResData = collx.M{
|
2022-10-26 20:49:29 +08:00
|
|
|
"mongoNum": mongoNum,
|
|
|
|
|
"machineNum": machienNum,
|
|
|
|
|
"dbNum": dbNum,
|
|
|
|
|
"redisNum": redisNum,
|
2021-09-11 14:04:09 +08:00
|
|
|
}
|
|
|
|
|
}
|