2022-09-09 18:26:08 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/internal/db/domain/entity"
|
|
|
|
|
"mayfly-go/internal/db/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-09-09 18:26:08 +08:00
|
|
|
"mayfly-go/pkg/model"
|
|
|
|
|
)
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
type dbSqlExecRepoImpl struct {
|
|
|
|
|
base.RepoImpl[*entity.DbSqlExec]
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
func newDbSqlExecRepo() repository.DbSqlExec {
|
|
|
|
|
return &dbSqlExecRepoImpl{base.RepoImpl[*entity.DbSqlExec]{M: new(entity.DbSqlExec)}}
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分页获取
|
2023-10-26 17:15:49 +08:00
|
|
|
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExecQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2023-11-12 20:14:44 +08:00
|
|
|
qd := gormx.NewQuery(new(entity.DbSqlExec)).
|
|
|
|
|
Eq("db_id", condition.DbId).
|
|
|
|
|
Eq("`table`", condition.Table).
|
|
|
|
|
Eq("type", condition.Type).
|
|
|
|
|
Eq("creator_id", condition.CreatorId).
|
|
|
|
|
RLike("db", condition.Db).WithOrderBy(orderBy...)
|
2023-07-01 14:34:42 +08:00
|
|
|
return gormx.PageQuery(qd, pageParam, toEntity)
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|