refactor: 系统模块角色分配相关优化

This commit is contained in:
meilin.huang
2023-12-18 22:39:32 +08:00
parent 574d27f6da
commit 1f6c14ee2f
28 changed files with 695 additions and 386 deletions

View File

@@ -0,0 +1,30 @@
package persistence
import (
"mayfly-go/internal/sys/domain/entity"
"mayfly-go/internal/sys/domain/repository"
"mayfly-go/pkg/base"
"mayfly-go/pkg/gormx"
"mayfly-go/pkg/model"
)
type accountRoleRepoImpl struct {
base.RepoImpl[*entity.AccountRole]
}
func newAccountRoleRepo() repository.AccountRole {
return &accountRoleRepoImpl{base.RepoImpl[*entity.AccountRole]{M: new(entity.AccountRole)}}
}
func (m *accountRoleRepoImpl) GetPageList(condition *entity.RoleAccountQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
qd := gormx.NewQueryWithTableName("t_sys_account_role t").
Select("t.creator, t.create_time, a.username, a.name accountName, a.status accountStatus, a.id accountId").
Joins("JOIN t_sys_account a ON t.account_id = a.id AND a.status = 1").
Eq0("a.is_deleted", model.ModelUndeleted).
Eq0("t.is_deleted", model.ModelUndeleted).
RLike("a.username", condition.Username).
RLike("a.name", condition.Name).
Eq("t.role_id", condition.RoleId).
OrderByDesc("t.id")
return gormx.PageQuery(qd, pageParam, toEntity)
}