refactor: 引入日志切割库、indexApi拆分等

This commit is contained in:
meilin.huang
2024-01-23 19:30:28 +08:00
parent d530365ef9
commit e4d13f3377
43 changed files with 324 additions and 241 deletions

View File

@@ -1,36 +0,0 @@
package api
import (
"mayfly-go/internal/common/consts"
dbapp "mayfly-go/internal/db/application"
machineapp "mayfly-go/internal/machine/application"
mongoapp "mayfly-go/internal/mongo/application"
redisapp "mayfly-go/internal/redis/application"
tagapp "mayfly-go/internal/tag/application"
"mayfly-go/pkg/req"
"mayfly-go/pkg/utils/collx"
)
type Index struct {
TagApp tagapp.TagTree `inject:"TagTreeApp"`
MachineApp machineapp.Machine `inject:""`
DbApp dbapp.Db `inject:""`
RedisApp redisapp.Redis `inject:""`
MongoApp mongoapp.Mongo `inject:""`
}
func (i *Index) Count(rc *req.Ctx) {
accountId := rc.GetLoginAccount().Id
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, ""))
rc.ResData = collx.M{
"mongoNum": mongoNum,
"machineNum": machienNum,
"dbNum": dbNum,
"redisNum": redisNum,
}
}

View File

@@ -1,20 +0,0 @@
package router
import (
"mayfly-go/internal/common/api"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/ioc"
"mayfly-go/pkg/req"
"github.com/gin-gonic/gin"
)
func InitIndexRouter(router *gin.RouterGroup) {
index := router.Group("common/index")
i := new(api.Index)
biz.ErrIsNil(ioc.Inject(i))
{
// 首页基本信息统计
req.NewGet("count", i.Count).Group(index)
}
}

View File

@@ -4,5 +4,4 @@ import "github.com/gin-gonic/gin"
func Init(router *gin.RouterGroup) {
InitCommonRouter(router)
InitIndexRouter(router)
}