fix(authorization): allow querying REVOKED records despite deletedAt being set

撤销授权时会同时设置 status=REVOKED 和 deletedAt(软删除),
导致 findByStatus(REVOKED) 因为 deletedAt IS NULL 条件永远返回空。
修改为查询 REVOKED 状态时不过滤 deletedAt。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-04 02:52:43 -08:00
parent 5026661fa8
commit 0991d5d484
1 changed files with 5 additions and 1 deletions

View File

@ -183,8 +183,12 @@ export class AuthorizationRoleRepositoryImpl implements IAuthorizationRoleReposi
}
async findByStatus(status: AuthorizationStatus): Promise<AuthorizationRole[]> {
// 查询 REVOKED 状态时不过滤 deletedAt因为撤销操作会同时设置 deletedAt
const whereClause = status === AuthorizationStatus.REVOKED
? { status }
: { status, ...this.notDeleted }
const records = await this.prisma.authorizationRole.findMany({
where: { status, ...this.notDeleted },
where: whereClause,
})
return records.map((record) => this.toDomain(record))
}