2882 - Replaced worker userFk property by user id
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8c9ad39762
commit
dac95805e8
|
@ -3,7 +3,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('mySubordinates', {
|
Self.remoteMethod('mySubordinates', {
|
||||||
description: 'Returns a list of a subordinate workers',
|
description: 'Returns a list of a subordinated workers',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'ctx',
|
arg: 'ctx',
|
||||||
|
@ -11,7 +11,7 @@ module.exports = Self => {
|
||||||
http: {source: 'context'}
|
http: {source: 'context'}
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['Object'],
|
type: ['object'],
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -22,19 +22,16 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.mySubordinates = async ctx => {
|
Self.mySubordinates = async ctx => {
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const myUserId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const myWorker = await Self.app.models.Worker.findOne({
|
|
||||||
where: {userFk: myUserId}
|
|
||||||
});
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
|
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.subordinateGetList(?)', [myWorker.id]));
|
stmts.push(new ParameterizedSQL('CALL vn.subordinateGetList(?)', [userId]));
|
||||||
stmts.push('SELECT * FROM tmp.subordinate');
|
const queryIndex = stmts.push('SELECT * FROM tmp.subordinate') - 1;
|
||||||
stmts.push('DROP TEMPORARY TABLE tmp.subordinate');
|
stmts.push('DROP TEMPORARY TABLE tmp.subordinate');
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
let result = await conn.executeStmt(sql);
|
const result = await conn.executeStmt(sql);
|
||||||
|
|
||||||
return result[1];
|
return result[queryIndex];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue