From 5c1f2992b5954c012cfcc5ae7ed4725e4b88bcf2 Mon Sep 17 00:00:00 2001 From: liuyun Date: Sun, 11 Oct 2026 16:43:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20created=5Fby=20=E6=B3=A8=E5=85=A5=20+=20?= =?UTF-8?q?=E7=99=BB=E5=87=BA=E5=AE=A1=E8=AE=A1=E8=AE=B0=E5=BD=95=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=20username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- src/auth/auth.service.ts | 3 ++- src/common/base-crud.service.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 566e0ac..16ca0b1 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -223,10 +223,11 @@ export class AuthService { data: { revokedAt: new Date() }, }); await this.redis.del(this.permKey(record.tenantCode, record.userId)); + const user = await this.prisma.client.user.findUnique({ where: { id: record.userId } }); await this.recordAudit({ tenantCode: record.tenantCode, userId: record.userId, - username: null, + username: user?.username ?? null, module: 'auth', action: 'logout', status: 'success', diff --git a/src/common/base-crud.service.ts b/src/common/base-crud.service.ts index 82c351c..8fd8490 100644 --- a/src/common/base-crud.service.ts +++ b/src/common/base-crud.service.ts @@ -53,7 +53,10 @@ export class BaseCrudService { async create(data: Record) { const ctx = getRequestContext(); - if (ctx && this.modelName !== 'tenant') data.tenantCode = ctx.tenantCode; + if (ctx && this.modelName !== 'tenant') { + data.tenantCode = ctx.tenantCode; + data.createdBy = ctx.userId; + } return this.db().create({ data }); }