refs #5890 feat: add userId in rawSql
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-09-28 13:26:05 +02:00
parent 75e54bd82f
commit e51df063d3
2 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethod('itemShelvingSaleByCollection', {
Self.remoteMethodCtx('itemShelvingSaleByCollection', {
description: 'Insert sales of the collection in itemShelvingSale',
accessType: 'WRITE',
accepts: [
@ -17,7 +17,12 @@ module.exports = Self => {
}
});
Self.itemShelvingSaleByCollection = async id => {
await Self.rawSql(`CALL vn.itemShelvingSale_addByCollection(?)`, [id]);
Self.itemShelvingSaleByCollection = async(ctx, id, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.rawSql(`CALL vn.itemShelvingSale_addByCollection(?)`, [id], myOptions);
};
};

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethod('itemShelvingSaleSetQuantity', {
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
description: 'Set quanitity of a sale in itemShelvingSale',
accessType: 'WRITE',
accepts: [
@ -28,7 +28,14 @@ module.exports = Self => {
}
});
Self.itemShelvingSaleSetQuantity = async(id, quantity, isItemShelvingSaleEmpty) => {
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`, [id, quantity, isItemShelvingSaleEmpty]);
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`,
[id, quantity, isItemShelvingSaleEmpty],
myOptions);
};
};