This commit is contained in:
parent
5b541aa804
commit
adeca2bb22
|
@ -1,25 +1,25 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('myLastModified', {
|
||||
description: 'Get list of last tickets which user has modified',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getLastTicketsByWorker`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getLastTicketsByWorker = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const query =
|
||||
`SELECT ticketFk, MAX(created) created
|
||||
FROM ticketTracking tt
|
||||
WHERE tt.userFk = ?
|
||||
GROUP BY ticketFk
|
||||
LIMIT 5;`;
|
||||
return await Self.rawSql(query, [userId]);
|
||||
};
|
||||
};
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('myLastModified', {
|
||||
description: 'Get list of last tickets which user has modified',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/myLastModified`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.myLastModified = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const query =
|
||||
`SELECT ticketFk, MAX(created) created
|
||||
FROM ticketTracking tt
|
||||
WHERE tt.userFk = ?
|
||||
GROUP BY ticketFk
|
||||
LIMIT 5;`;
|
||||
return await Self.rawSql(query, [userId]);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getLastTicketsByWorker()', () => {
|
||||
it('return list of last tickets which user has modified', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 100}}};
|
||||
let response = await models.Ticket.getLastTicketsByWorker(ctx);
|
||||
|
||||
expect(response.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('myLastModified()', () => {
|
||||
it('return list of last tickets which user has modified', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 100}}};
|
||||
let response = await models.Ticket.myLastModified(ctx);
|
||||
|
||||
expect(response.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue