forked from UKSOURCE/cms.hailearning.edu.vn
upload pdf
This commit is contained in:
@@ -57,8 +57,8 @@ exports.createForm = async (req, res) => {
|
||||
exports.create = async (req, res) => {
|
||||
try {
|
||||
const data = { ...req.body };
|
||||
const imgPath = req.files?.degree_image?.[0]?.path;
|
||||
if (imgPath) data.degree_image = normalizePath(imgPath);
|
||||
const imgFiles = req.files?.degree_image;
|
||||
if (imgFiles?.length) data.degree_image = imgFiles.map(f => normalizePath(f.path));
|
||||
|
||||
const qual = new Qualification(data);
|
||||
await qual.save();
|
||||
@@ -104,8 +104,8 @@ exports.update = async (req, res) => {
|
||||
'issued_date','status','passport_number','address','topic_name','topic_short_desc'];
|
||||
fields.forEach(f => { if (req.body[f] !== undefined) qual[f] = req.body[f]; });
|
||||
|
||||
const imgPath = req.files?.degree_image?.[0]?.path;
|
||||
if (imgPath) qual.degree_image = normalizePath(imgPath);
|
||||
const imgFiles = req.files?.degree_image;
|
||||
if (imgFiles?.length) qual.degree_image = imgFiles.map(f => normalizePath(f.path));
|
||||
|
||||
await qual.save();
|
||||
await writeAuditLog({ model: 'Qualification', documentId: qual._id, action: AUDIT_ACTIONS.UPDATE_QUALIFICATION, before, after: qual.toObject(), req });
|
||||
@@ -142,7 +142,10 @@ exports.apiVerify = async (req, res) => {
|
||||
if (qual.status === 'revoked') return res.status(404).json({ error: 'Degree has been revoked' });
|
||||
|
||||
const baseUrl = process.env.BACKEND_URL ?? `${req.protocol}://${req.get('host')}`;
|
||||
const buildUrl = (f) => f ? [generateSignedUrl(baseUrl, path.basename(f))] : undefined;
|
||||
const buildUrl = (files) => {
|
||||
if (!files?.length) return undefined;
|
||||
return files.map(f => generateSignedUrl(baseUrl, path.basename(f)));
|
||||
};
|
||||
|
||||
const response = {
|
||||
full_name: qual.student_name,
|
||||
|
||||
Reference in New Issue
Block a user