feat: add signatureBase64 to document insertion and implement deletion of signature documents for user
This commit is contained in:
parent
d7fd62d6b4
commit
f286d44353
@ -10,6 +10,7 @@ class UserDocumentRepository {
|
|||||||
documentType,
|
documentType,
|
||||||
contractType = 'contract',
|
contractType = 'contract',
|
||||||
objectStorageId,
|
objectStorageId,
|
||||||
|
signatureBase64 = null,
|
||||||
originalFilename,
|
originalFilename,
|
||||||
fileSize,
|
fileSize,
|
||||||
mimeType
|
mimeType
|
||||||
@ -18,9 +19,9 @@ class UserDocumentRepository {
|
|||||||
const conn = this.unitOfWork.connection;
|
const conn = this.unitOfWork.connection;
|
||||||
const query = `
|
const query = `
|
||||||
INSERT INTO user_documents (
|
INSERT INTO user_documents (
|
||||||
user_id, document_type, contract_type, object_storage_id,
|
user_id, document_type, contract_type, object_storage_id, signatureBase64,
|
||||||
original_filename, file_size, mime_type
|
original_filename, file_size, mime_type
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`;
|
`;
|
||||||
try {
|
try {
|
||||||
const [result] = await conn.query(query, [
|
const [result] = await conn.query(query, [
|
||||||
@ -28,6 +29,7 @@ class UserDocumentRepository {
|
|||||||
documentType,
|
documentType,
|
||||||
contractType,
|
contractType,
|
||||||
objectStorageId,
|
objectStorageId,
|
||||||
|
signatureBase64,
|
||||||
originalFilename,
|
originalFilename,
|
||||||
fileSize,
|
fileSize,
|
||||||
mimeType
|
mimeType
|
||||||
@ -147,6 +149,22 @@ class UserDocumentRepository {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteSignatureDocumentsForUser(userId) {
|
||||||
|
logger.info('UserDocumentRepository.deleteSignatureDocumentsForUser:start', { userId });
|
||||||
|
const conn = this.unitOfWork.connection;
|
||||||
|
try {
|
||||||
|
const [result] = await conn.query(
|
||||||
|
`DELETE FROM user_documents WHERE user_id = ? AND document_type = 'signature'`,
|
||||||
|
[userId]
|
||||||
|
);
|
||||||
|
logger.info('UserDocumentRepository.deleteSignatureDocumentsForUser:success', { userId, affectedRows: result.affectedRows });
|
||||||
|
return result.affectedRows;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('UserDocumentRepository.deleteSignatureDocumentsForUser:error', { userId, error: error.message });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserDocumentRepository;
|
module.exports = UserDocumentRepository;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user