2019-06-06 11:59:11 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('removeFile', {
|
|
|
|
description: 'Removes a client document',
|
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: {
|
|
|
|
arg: 'id',
|
|
|
|
type: 'Number',
|
|
|
|
description: 'The document id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
},
|
|
|
|
returns: {
|
|
|
|
type: 'Object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:id/removeFile`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.removeFile = async(ctx, id) => {
|
|
|
|
const models = Self.app.models;
|
2019-06-20 05:46:30 +00:00
|
|
|
const clientDms = await models.ClientDms.findById(id);
|
2019-06-06 11:59:11 +00:00
|
|
|
|
2019-06-20 05:46:30 +00:00
|
|
|
await models.Dms.removeFile(ctx, clientDms.dmsFk);
|
2019-06-06 11:59:11 +00:00
|
|
|
|
2019-06-20 05:46:30 +00:00
|
|
|
return clientDms.destroy();
|
2019-06-06 11:59:11 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|