webadmin增加oss日志

This commit is contained in:
2026-07-12 15:44:17 +08:00
parent 758760eb36
commit 9fc955d81f
12 changed files with 575 additions and 19 deletions
@@ -0,0 +1,41 @@
import type { PrismaService } from '../../common/prisma/prisma.module';
export type OssActorRef = {
refType: string;
refId: bigint;
};
export function ossActorRefFromAuth(
actorType?: string,
actorId?: bigint,
): OssActorRef | undefined {
if (!actorType || actorId == null) return undefined;
return { refType: actorType, refId: actorId };
}
type LogOssUploadInput = {
scene: 'UPLOAD_PUT_OBJECT' | 'UPLOAD_TOKEN';
requestBody?: Record<string, unknown>;
responseBody?: Record<string, unknown>;
externalNo?: string;
status: 'SUCCESS' | 'FAILED';
errorMessage?: string;
actorRef?: OssActorRef;
};
export async function logOssUpload(prisma: PrismaService, input: LogOssUploadInput) {
const row = await prisma.logThirdParty.create({
data: {
provider: 'ALIYUN_OSS',
scene: input.scene,
refType: input.actorRef?.refType,
refId: input.actorRef?.refId,
requestBody: input.requestBody as never,
responseBody: input.responseBody as never,
externalNo: input.externalNo?.slice(0, 128),
status: input.status,
errorMessage: input.errorMessage?.slice(0, 512),
},
});
return row.id;
}