mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-04 21:55:48 +08:00
refactor: 引入日志切割库、indexApi拆分等
This commit is contained in:
21
server/internal/mongo/api/dashbord.go
Normal file
21
server/internal/mongo/api/dashbord.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/common/consts"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/req"
|
||||
"mayfly-go/pkg/utils/collx"
|
||||
)
|
||||
|
||||
type Dashbord struct {
|
||||
TagTreeApp tagapp.TagTree `inject:""`
|
||||
}
|
||||
|
||||
func (m *Dashbord) Dashbord(rc *req.Ctx) {
|
||||
accountId := rc.GetLoginAccount().Id
|
||||
mongoNum := len(m.TagTreeApp.GetAccountResourceCodes(accountId, consts.TagResourceTypeMongo, ""))
|
||||
|
||||
rc.ResData = collx.M{
|
||||
"mongoNum": mongoNum,
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ type Mongo interface {
|
||||
type mongoAppImpl struct {
|
||||
base.AppImpl[*entity.Mongo, repository.Mongo]
|
||||
|
||||
TagApp tagapp.TagTree `inject:"TagTreeApp"`
|
||||
tagApp tagapp.TagTree `inject:"TagTreeApp"`
|
||||
}
|
||||
|
||||
// 注入MongoRepo
|
||||
@@ -60,7 +60,7 @@ func (d *mongoAppImpl) Delete(ctx context.Context, id uint64) error {
|
||||
},
|
||||
func(ctx context.Context) error {
|
||||
var tagIds []uint64
|
||||
return d.TagApp.RelateResource(ctx, mongoEntity.Code, consts.TagResourceTypeMongo, tagIds)
|
||||
return d.tagApp.RelateResource(ctx, mongoEntity.Code, consts.TagResourceTypeMongo, tagIds)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (d *mongoAppImpl) SaveMongo(ctx context.Context, m *entity.Mongo, tagIds ..
|
||||
return d.Tx(ctx, func(ctx context.Context) error {
|
||||
return d.Insert(ctx, m)
|
||||
}, func(ctx context.Context) error {
|
||||
return d.TagApp.RelateResource(ctx, resouceCode, consts.TagResourceTypeMongo, tagIds)
|
||||
return d.tagApp.RelateResource(ctx, resouceCode, consts.TagResourceTypeMongo, tagIds)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func (d *mongoAppImpl) SaveMongo(ctx context.Context, m *entity.Mongo, tagIds ..
|
||||
return d.Tx(ctx, func(ctx context.Context) error {
|
||||
return d.UpdateById(ctx, m)
|
||||
}, func(ctx context.Context) error {
|
||||
return d.TagApp.RelateResource(ctx, oldMongo.Code, consts.TagResourceTypeMongo, tagIds)
|
||||
return d.tagApp.RelateResource(ctx, oldMongo.Code, consts.TagResourceTypeMongo, tagIds)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,6 +116,6 @@ func (d *mongoAppImpl) GetMongoConn(id uint64) (*mgm.MongoConn, error) {
|
||||
if err != nil {
|
||||
return nil, errorx.NewBiz("mongo信息不存在")
|
||||
}
|
||||
return me.ToMongoInfo(d.TagApp.ListTagPathByResource(consts.TagResourceTypeMongo, me.Code)...), nil
|
||||
return me.ToMongoInfo(d.tagApp.ListTagPathByResource(consts.TagResourceTypeMongo, me.Code)...), nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,9 +15,14 @@ func InitMongoRouter(router *gin.RouterGroup) {
|
||||
ma := new(api.Mongo)
|
||||
biz.ErrIsNil(ioc.Inject(ma))
|
||||
|
||||
dashbord := new(api.Dashbord)
|
||||
biz.ErrIsNil(ioc.Inject(dashbord))
|
||||
|
||||
saveDataPerm := req.NewPermission("mongo:data:save")
|
||||
|
||||
reqs := [...]*req.Conf{
|
||||
req.NewGet("dashbord", dashbord.Dashbord),
|
||||
|
||||
// 获取所有mongo列表
|
||||
req.NewGet("", ma.Mongos),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user