This commit is contained in:
SunYF
2026-10-26 16:32:35 +08:00
parent 4b14f9540a
commit f86feb2271
99 changed files with 1652 additions and 521 deletions
+7 -2
View File
@@ -535,8 +535,13 @@ func (s *Service) DeleteRole(ctx context.Context, id int) error {
return s.ctx.EntClient.Role.DeleteOneID(id).Exec(ctx)
}
func (s *Service) ListRoles(ctx context.Context) ([]*ent.Role, error) {
return s.ctx.EntClient.Role.Query().Order(ent.Asc(role.FieldID)).All(ctx)
func (s *Service) ListRoles(ctx context.Context, keyword string) ([]*ent.Role, error) {
q := s.ctx.EntClient.Role.Query().Order(ent.Asc(role.FieldID))
if keyword != "" {
kw := keyword
q = q.Where(role.Or(role.NameContainsFold(kw), role.CodeContainsFold(kw)))
}
return q.All(ctx)
}
type PermissionReq struct {