2019-11-22 09:42:05 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('removeFile', {
|
2019-11-22 12:46:38 +00:00
|
|
|
description: 'Removes a worker document',
|
2019-11-22 09:42:05 +00:00
|
|
|
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-11-22 12:46:38 +00:00
|
|
|
const workerDms = await Self.findById(id);
|
2019-11-22 09:42:05 +00:00
|
|
|
|
2019-11-22 12:46:38 +00:00
|
|
|
await models.Dms.removeFile(ctx, workerDms.dmsFk);
|
2019-11-22 09:42:05 +00:00
|
|
|
|
2019-11-22 12:46:38 +00:00
|
|
|
return workerDms.destroy();
|
2019-11-22 09:42:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|