2021-07-28 18:03:19 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
2022-09-09 18:26:08 +08:00
|
|
|
"mayfly-go/internal/redis/domain/entity"
|
|
|
|
|
"mayfly-go/internal/redis/domain/repository"
|
2023-10-26 17:15:49 +08:00
|
|
|
"mayfly-go/pkg/base"
|
2022-06-02 17:41:11 +08:00
|
|
|
"mayfly-go/pkg/model"
|
2021-07-28 18:03:19 +08:00
|
|
|
)
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
type redisRepoImpl struct {
|
|
|
|
|
base.RepoImpl[*entity.Redis]
|
|
|
|
|
}
|
2021-07-28 18:03:19 +08:00
|
|
|
|
2022-09-09 18:26:08 +08:00
|
|
|
func newRedisRepo() repository.Redis {
|
2023-10-26 17:15:49 +08:00
|
|
|
return &redisRepoImpl{base.RepoImpl[*entity.Redis]{M: new(entity.Redis)}}
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
2021-07-28 18:03:19 +08:00
|
|
|
|
2024-04-06 18:19:17 +08:00
|
|
|
// 分页获取redis信息列表
|
2023-10-26 17:15:49 +08:00
|
|
|
func (r *redisRepoImpl) GetRedisList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2024-04-28 23:45:57 +08:00
|
|
|
qd := model.NewCond().
|
2024-03-02 19:08:19 +08:00
|
|
|
Eq("id", condition.Id).
|
2023-07-01 14:34:42 +08:00
|
|
|
Like("host", condition.Host).
|
2024-04-06 18:19:17 +08:00
|
|
|
Eq("code", condition.Code).
|
2023-12-05 23:03:51 +08:00
|
|
|
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 r.PageByCondToAny(qd, pageParam, toEntity)
|
2021-07-28 18:03:19 +08:00
|
|
|
}
|