feat: delete from ticketCollection and sectorCollection when a ticket is deleted
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b64174ff5d
commit
84ffe3f594
|
@ -142,6 +142,25 @@ module.exports = Self => {
|
||||||
|
|
||||||
const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions);
|
const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions);
|
||||||
|
|
||||||
|
const [ticketCollection] = await models.TicketCollection.find({
|
||||||
|
fields: ['id'],
|
||||||
|
where: {
|
||||||
|
ticketFk: ticket.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ticketCollection)
|
||||||
|
await models.TicketCollection.destroyById(ticketCollection.id, myOptions);
|
||||||
|
|
||||||
|
await Self.rawSql(`
|
||||||
|
DELETE sc
|
||||||
|
FROM vn.saleGroup sg
|
||||||
|
JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id
|
||||||
|
JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk
|
||||||
|
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||||
|
JOIN vn.sale s ON s.id = sgd.saleFk
|
||||||
|
WHERE s.ticketFk = ?;`, [ticket.id], myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
return updatedTicket;
|
return updatedTicket;
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
"Ticket": {
|
"Ticket": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"TicketCollection": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"TicketDms": {
|
"TicketDms": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "TicketCollection",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "ticketCollection"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"ticket": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Ticket",
|
||||||
|
"foreignKey": "ticketFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue