This commit is contained in:
parent
71937699a4
commit
4d3d38ebe3
|
@ -0,0 +1,61 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('executeRoutine', {
|
||||
description: 'Return the routes by worker',
|
||||
accessType: '*',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'routine',
|
||||
type: 'string',
|
||||
description: 'The routine sql',
|
||||
required: true,
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'params',
|
||||
type: ['any'],
|
||||
description: 'The array of params',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'any',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:routine/execute-routine`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.executeRoutine = async(ctx, routine, params, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const user = await Self.app.models.VnUser.findById(userId, {
|
||||
fields: ['id', 'roleFk'],
|
||||
include: {
|
||||
relation: 'role',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const inherits = await Self.app.models.RoleRole.find({
|
||||
where: {
|
||||
|
||||
}
|
||||
});
|
||||
console.log(user.role.name);
|
||||
|
||||
const checkACL = await models.ACL.checkAccessAcl(ctx, 'Application', routine, '*');
|
||||
if (!checkACL) throw error;
|
||||
|
||||
const requestParams = [routine];
|
||||
requestParams.concat(params);
|
||||
return Self.app.models.Route.rawSql(`CALL ?(...)`, requestParams, myOptions);
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue