mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	refactor: 引入日志切割库、indexApi拆分等
This commit is contained in:
		@@ -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,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -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)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -4,5 +4,4 @@ import "github.com/gin-gonic/gin"
 | 
			
		||||
 | 
			
		||||
func Init(router *gin.RouterGroup) {
 | 
			
		||||
	InitCommonRouter(router)
 | 
			
		||||
	InitIndexRouter(router)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user