2023-08-27 11:07:29 +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-08-27 11:07:29 +08:00
|
|
|
"mayfly-go/pkg/model"
|
|
|
|
|
)
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
type instanceRepoImpl struct {
|
2023-10-27 17:41:45 +08:00
|
|
|
base.RepoImpl[*entity.DbInstance]
|
2023-10-26 17:15:49 +08:00
|
|
|
}
|
2023-08-27 11:07:29 +08:00
|
|
|
|
2024-02-06 07:16:56 +00:00
|
|
|
func NewInstanceRepo() repository.Instance {
|
2024-12-08 13:04:23 +08:00
|
|
|
return &instanceRepoImpl{}
|
2023-08-27 11:07:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分页获取数据库信息列表
|
2023-10-26 17:15:49 +08:00
|
|
|
func (d *instanceRepoImpl) GetInstanceList(condition *entity.InstanceQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2024-04-28 23:45:57 +08:00
|
|
|
qd := model.NewCond().
|
2023-09-05 12:49:12 +08:00
|
|
|
Eq("id", condition.Id).
|
2023-08-27 11:07:29 +08:00
|
|
|
Eq("host", condition.Host).
|
2024-04-12 13:24:20 +08:00
|
|
|
Like("name", condition.Name).
|
2024-04-17 21:28:28 +08:00
|
|
|
Like("code", condition.Code).
|
|
|
|
|
In("code", condition.Codes)
|
2024-10-16 17:24:50 +08:00
|
|
|
|
|
|
|
|
keyword := condition.Keyword
|
|
|
|
|
if keyword != "" {
|
|
|
|
|
keyword = "%" + keyword + "%"
|
|
|
|
|
qd.And("host like ? or name like ? or code like ?", keyword, keyword, keyword)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-05 14:53:30 +08:00
|
|
|
return d.PageByCondToAny(qd, pageParam, toEntity)
|
2023-08-27 11:07:29 +08:00
|
|
|
}
|