2022-05-17 20:23:08 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
2022-09-09 18:26:08 +08:00
|
|
|
"mayfly-go/internal/mongo/domain/entity"
|
|
|
|
|
"mayfly-go/internal/mongo/domain/repository"
|
2023-10-26 17:15:49 +08:00
|
|
|
"mayfly-go/pkg/base"
|
2023-07-01 14:34:42 +08:00
|
|
|
"mayfly-go/pkg/gormx"
|
2022-06-02 17:41:11 +08:00
|
|
|
"mayfly-go/pkg/model"
|
2022-05-17 20:23:08 +08:00
|
|
|
)
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
type mongoRepoImpl struct {
|
|
|
|
|
base.RepoImpl[*entity.Mongo]
|
|
|
|
|
}
|
2022-05-17 20:23:08 +08:00
|
|
|
|
2022-09-09 18:26:08 +08:00
|
|
|
func newMongoRepo() repository.Mongo {
|
2023-10-26 17:15:49 +08:00
|
|
|
return &mongoRepoImpl{base.RepoImpl[*entity.Mongo]{M: new(entity.Mongo)}}
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
2022-05-17 20:23:08 +08:00
|
|
|
|
|
|
|
|
// 分页获取数据库信息列表
|
2023-10-26 17:15:49 +08:00
|
|
|
func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2023-07-01 14:34:42 +08:00
|
|
|
qd := gormx.NewQuery(new(entity.Mongo)).
|
|
|
|
|
Like("name", condition.Name).
|
2023-12-05 23:03:51 +08:00
|
|
|
In("code", condition.Codes)
|
2023-07-01 14:34:42 +08:00
|
|
|
return gormx.PageQuery(qd, pageParam, toEntity)
|
2022-05-17 20:23:08 +08:00
|
|
|
}
|