it should throw the error before it deletes the ticket
This commit is contained in:
parent
cb86e63e71
commit
9ce502551f
|
@ -22,13 +22,13 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.deleted = async (ctx, params) => {
|
||||
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||
await currentTicket.updateAttributes({isDeleted: '1'});
|
||||
|
||||
let claimOfATicket = await Self.app.models.Claim.findOne({where: {ticketFk: params.id}});
|
||||
if (claimOfATicket)
|
||||
throw new UserError('You must delete the claim id %d first', claimOfATicket.id);
|
||||
|
||||
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||
await currentTicket.updateAttributes({isDeleted: '1'});
|
||||
|
||||
if (ctx.req.accessToken) {
|
||||
let token = ctx.req.accessToken;
|
||||
let currentUserId = token && token.userId;
|
||||
|
|
Loading…
Reference in New Issue