This commit is contained in:
parent
63888e2d64
commit
9fa6e2df71
|
@ -200,22 +200,20 @@ 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) {
|
||||||
conn = await new Promise((resolve, reject) => {
|
if (!options.transaction) {
|
||||||
connector.client.getConnection(function(err, conn) {
|
options = Object.assign({}, options);
|
||||||
if (err)
|
conn = await new Promise((resolve, reject) => {
|
||||||
reject(err);
|
connector.client.getConnection(function(err, conn) {
|
||||||
else
|
if (err)
|
||||||
resolve(conn);
|
reject(err);
|
||||||
|
else
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
console.log(orderFk, 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});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue