2021-06-07 17:22:07 +08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
2022-06-02 17:41:11 +08:00
|
|
|
"mayfly-go/internal/sys/domain/entity"
|
|
|
|
|
"mayfly-go/internal/sys/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-06-07 17:22:07 +08:00
|
|
|
)
|
|
|
|
|
|
2023-10-26 17:15:49 +08:00
|
|
|
type roleRepoImpl struct {
|
|
|
|
|
base.RepoImpl[*entity.Role]
|
|
|
|
|
}
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-09-09 18:26:08 +08:00
|
|
|
func newRoleRepo() repository.Role {
|
2023-10-26 17:15:49 +08:00
|
|
|
return &roleRepoImpl{base.RepoImpl[*entity.Role]{M: new(entity.Role)}}
|
2022-09-09 18:26:08 +08:00
|
|
|
}
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2023-12-18 22:39:32 +08:00
|
|
|
func (m *roleRepoImpl) GetPageList(condition *entity.RoleQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
2024-04-28 23:45:57 +08:00
|
|
|
qd := model.NewCond().
|
2023-12-18 22:39:32 +08:00
|
|
|
Like("name", condition.Name).
|
|
|
|
|
Like("code", condition.Code).
|
|
|
|
|
In("id", condition.Ids).
|
|
|
|
|
NotIn("id", condition.NotIds).
|
2024-04-28 23:45:57 +08:00
|
|
|
OrderBy(orderBy...)
|
|
|
|
|
return m.PageByCond(qd, pageParam, toEntity)
|
2021-06-07 17:22:07 +08:00
|
|
|
}
|
|
|
|
|
|
2023-12-18 22:39:32 +08:00
|
|
|
func (m *roleRepoImpl) ListByQuery(condition *entity.RoleQuery) ([]*entity.Role, error) {
|
|
|
|
|
var res []*entity.Role
|
2024-04-28 23:45:57 +08:00
|
|
|
qd := model.NewCond().
|
2023-12-18 22:39:32 +08:00
|
|
|
Like("name", condition.Name).
|
|
|
|
|
Like("code", condition.Code).
|
|
|
|
|
In("id", condition.Ids).
|
|
|
|
|
NotIn("id", condition.NotIds).
|
|
|
|
|
OrderByDesc("id")
|
2024-04-28 23:45:57 +08:00
|
|
|
err := m.SelectByCond(qd, &res)
|
2023-12-18 22:39:32 +08:00
|
|
|
return res, err
|
|
|
|
|
}
|