mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-07 06:55:48 +08:00
refactor: interface{} -> any
feat: 新增外链菜单
This commit is contained in:
@@ -10,30 +10,30 @@ type Mongo struct {
|
||||
}
|
||||
|
||||
type MongoCommand struct {
|
||||
Database string `binding:"required" json:"database"`
|
||||
Collection string `binding:"required" json:"collection"`
|
||||
Filter map[string]interface{} `json:"filter"`
|
||||
Database string `binding:"required" json:"database"`
|
||||
Collection string `binding:"required" json:"collection"`
|
||||
Filter map[string]any `json:"filter"`
|
||||
}
|
||||
|
||||
type MongoRunCommand struct {
|
||||
Database string `binding:"required" json:"database"`
|
||||
Command map[string]interface{} `json:"command"`
|
||||
Database string `binding:"required" json:"database"`
|
||||
Command map[string]any `json:"command"`
|
||||
}
|
||||
|
||||
type MongoFindCommand struct {
|
||||
MongoCommand
|
||||
Sort map[string]interface{} `json:"sort"`
|
||||
Sort map[string]any `json:"sort"`
|
||||
Skip int64
|
||||
Limit int64
|
||||
}
|
||||
|
||||
type MongoUpdateByIdCommand struct {
|
||||
MongoCommand
|
||||
DocId interface{} `binding:"required" json:"docId"`
|
||||
Update map[string]interface{} `json:"update"`
|
||||
DocId any `binding:"required" json:"docId"`
|
||||
Update map[string]any `json:"update"`
|
||||
}
|
||||
|
||||
type MongoInsertCommand struct {
|
||||
MongoCommand
|
||||
Doc map[string]interface{} `json:"doc"`
|
||||
Doc map[string]any `json:"doc"`
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
type Mongo interface {
|
||||
// 分页获取机器脚本信息列表
|
||||
GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
||||
GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
|
||||
|
||||
Count(condition *entity.MongoQuery) int64
|
||||
|
||||
@@ -54,7 +54,7 @@ type mongoAppImpl struct {
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *mongoAppImpl) GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
func (d *mongoAppImpl) GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
|
||||
return d.mongoRepo.GetList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (d *mongoAppImpl) GetMongoCli(id uint64) *mongo.Client {
|
||||
// mongo客户端连接缓存,指定时间内没有访问则会被关闭
|
||||
var mongoCliCache = cache.NewTimedCache(constant.MongoConnExpireTime, 5*time.Second).
|
||||
WithUpdateAccessTime(true).
|
||||
OnEvicted(func(key interface{}, value interface{}) {
|
||||
OnEvicted(func(key any, value any) {
|
||||
global.Log.Info("删除mongo连接缓存: id = ", key)
|
||||
value.(*MongoInstance).Close()
|
||||
})
|
||||
@@ -122,7 +122,7 @@ func init() {
|
||||
|
||||
// 获取mongo的连接实例
|
||||
func GetMongoInstance(mongoId uint64, getMongoEntity func(uint64) *entity.Mongo) (*MongoInstance, error) {
|
||||
mi, err := mongoCliCache.ComputeIfAbsent(mongoId, func(_ interface{}) (interface{}, error) {
|
||||
mi, err := mongoCliCache.ComputeIfAbsent(mongoId, func(_ any) (any, error) {
|
||||
c, err := connect(getMongoEntity(mongoId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Mongo interface {
|
||||
// 分页获取列表
|
||||
GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
||||
GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
|
||||
|
||||
Count(condition *entity.MongoQuery) int64
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ func newMongoRepo() repository.Mongo {
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
|
||||
sql := "SELECT d.* FROM t_mongo d WHERE 1=1 "
|
||||
|
||||
if len(condition.TagIds) > 0 {
|
||||
sql = sql + " AND d.tag_id IN " + fmt.Sprintf("(%s)", strings.Join(utils.NumberArr2StrArr(condition.TagIds), ","))
|
||||
}
|
||||
|
||||
values := make([]interface{}, 0)
|
||||
values := make([]any, 0)
|
||||
if condition.TagPathLike != "" {
|
||||
values = append(values, condition.TagPathLike+"%")
|
||||
sql = sql + " AND d.tag_path LIKE ?"
|
||||
@@ -34,7 +34,7 @@ func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.P
|
||||
}
|
||||
|
||||
func (d *mongoRepoImpl) Count(condition *entity.MongoQuery) int64 {
|
||||
where := make(map[string]interface{})
|
||||
where := make(map[string]any)
|
||||
if len(condition.TagIds) > 0 {
|
||||
where["tag_id"] = condition.TagIds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user