Merge branch 'master' into 5339_instance_vs_data
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2023-06-22 05:33:34 +00:00
commit aea32492e3
4 changed files with 22 additions and 28 deletions

View File

@ -200,10 +200,11 @@ module.exports = function(Self) {
const connector = this.dataSource.connector; const connector = this.dataSource.connector;
let conn; let conn;
let res; let res;
const opts = Object.assign({}, options);
try { try {
if (userId) { if (userId) {
if (!options.transaction) {
options = Object.assign({}, options);
conn = await new Promise((resolve, reject) => { conn = await new Promise((resolve, reject) => {
connector.client.getConnection(function(err, conn) { connector.client.getConnection(function(err, conn) {
if (err) if (err)
@ -212,10 +213,7 @@ module.exports = function(Self) {
resolve(conn); resolve(conn);
}); });
}); });
options.transaction = {
const opts = Object.assign({}, options);
if (!opts.transaction) {
opts.transaction = {
connection: conn, connection: conn,
connector connector
}; };
@ -223,15 +221,14 @@ module.exports = function(Self) {
await connector.executeP( await connector.executeP(
'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))', 'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))',
[userId], opts [userId], options
); );
} }
res = await connector.executeP(query, params, opts); res = await connector.executeP(query, params, options);
if (userId) { if (userId)
await connector.executeP('CALL account.myUser_logout()', null, opts); await connector.executeP('CALL account.myUser_logout()', null, options);
}
} finally { } finally {
if (conn) conn.release(); if (conn) conn.release();
} }

View File

@ -21,7 +21,6 @@ module.exports = Self => {
Self.confirm = async(ctx, orderFk) => { Self.confirm = async(ctx, orderFk) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const query = `CALL hedera.order_confirmWithUser(?, ?)`; const query = `CALL hedera.order_confirmWithUser(?, ?)`;
const response = await Self.rawSql(query, [orderFk, userId], {userId}); const response = await Self.rawSql(query, [orderFk, userId], {userId});

View File

@ -81,7 +81,6 @@ module.exports = Self => {
throw new UserError('You must delete all the buy requests first'); throw new UserError('You must delete all the buy requests first');
// removes item shelvings // removes item shelvings
if (hasItemShelvingSales && isSalesAssistant) {
const promises = []; const promises = [];
for (let sale of sales) { for (let sale of sales) {
if (sale.itemShelvingSale()) { if (sale.itemShelvingSale()) {
@ -91,7 +90,6 @@ module.exports = Self => {
} }
} }
await Promise.all(promises); await Promise.all(promises);
}
// Remove ticket greuges // Remove ticket greuges
const ticketGreuges = await models.Greuge.find({where: {ticketFk: id}}, myOptions); const ticketGreuges = await models.Greuge.find({where: {ticketFk: id}}, myOptions);

View File

@ -1,5 +1,5 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx, ('getLeaves', { Self.remoteMethodCtx('getLeaves', {
description: 'Returns the nodes for a department', description: 'Returns the nodes for a department',
accepts: [{ accepts: [{
arg: 'parentId', arg: 'parentId',