mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 18:20:57 +00:00
configer the stamp
This commit is contained in:
@@ -7,12 +7,14 @@ export class SaveSignatureDto {
|
||||
@MinLength(1)
|
||||
signerDisplayName!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'PNG signature image as base64 (with or without data URL prefix)',
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'PNG signature image as base64 (with or without data URL prefix). Omit to keep the existing saved signature (stamp-only update).',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(20)
|
||||
signatureImageBase64!: string;
|
||||
signatureImageBase64?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
|
||||
@@ -12,7 +12,8 @@ import { SavedSignatureDto } from './dto/save-signature.dto';
|
||||
export interface UpsertSignatureInput {
|
||||
userId: string;
|
||||
signerDisplayName: string;
|
||||
signatureImageBase64: string;
|
||||
/** Optional; omitted = keep the existing saved signature (stamp-only update). */
|
||||
signatureImageBase64?: string;
|
||||
/** Optional company stamp/seal; omitted = keep the existing saved stamp. */
|
||||
stampImageBase64?: string;
|
||||
}
|
||||
@@ -46,12 +47,14 @@ export class SignaturesService {
|
||||
const previousFileId = existing?.signatureFileId ?? null;
|
||||
const previousStampFileId = existing?.stampFileId ?? null;
|
||||
|
||||
const fileRecord = await this.filesService.upload({
|
||||
resourceId: input.userId,
|
||||
resource: 'saved_signatures',
|
||||
code: 'signature',
|
||||
file: this.toUploadFile('signature', input.userId, input.signatureImageBase64),
|
||||
});
|
||||
const fileRecord = input.signatureImageBase64
|
||||
? await this.filesService.upload({
|
||||
resourceId: input.userId,
|
||||
resource: 'saved_signatures',
|
||||
code: 'signature',
|
||||
file: this.toUploadFile('signature', input.userId, input.signatureImageBase64),
|
||||
})
|
||||
: null;
|
||||
|
||||
const stampRecord = input.stampImageBase64
|
||||
? await this.filesService.upload({
|
||||
@@ -65,13 +68,13 @@ export class SignaturesService {
|
||||
const saved = await this.signaturesRepository.upsert({
|
||||
userId: input.userId,
|
||||
signerDisplayName: input.signerDisplayName,
|
||||
signatureFileId: fileRecord.id,
|
||||
// Omitted stamp keeps whatever was saved before.
|
||||
// Omitted image keeps whatever was saved before.
|
||||
...(fileRecord ? { signatureFileId: fileRecord.id } : {}),
|
||||
...(stampRecord ? { stampFileId: stampRecord.id } : {}),
|
||||
});
|
||||
|
||||
const staleIds = [
|
||||
previousFileId !== fileRecord.id ? previousFileId : null,
|
||||
fileRecord && previousFileId !== fileRecord.id ? previousFileId : null,
|
||||
stampRecord && previousStampFileId !== stampRecord.id
|
||||
? previousStampFileId
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user