feat: inserta en la nueva tabla ticketSms
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
84c6604dd9
commit
e540bf7b31
|
@ -0,0 +1,10 @@
|
||||||
|
CREATE TABLE `vn`.`ticketSms` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`ticketFk` int(11) DEFAULT NULL,
|
||||||
|
`smsFk` mediumint(8) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `ticketSms_FK` (`ticketFk`),
|
||||||
|
KEY `ticketSms_FK_1` (`smsFk`),
|
||||||
|
CONSTRAINT `ticketSms_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
|
@ -104,6 +104,9 @@
|
||||||
"SageTransactionType": {
|
"SageTransactionType": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"TicketSms": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"TpvError": {
|
"TpvError": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"name": "TicketSms",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "ticketSms"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"ticket": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Ticket",
|
||||||
|
"foreignKey": "ticketFk"
|
||||||
|
},
|
||||||
|
"sms": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Sms",
|
||||||
|
"foreignKey": "smsFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.sendSms = async(ctx, id, destination, message, options) => {
|
Self.sendSms = async(ctx, id, destination, message, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
|
@ -45,7 +46,14 @@ module.exports = Self => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sms = await Self.app.models.Sms.send(ctx, destination, message);
|
const sms = await models.Sms.send(ctx, destination, message);
|
||||||
|
|
||||||
|
const newTicketSms = {
|
||||||
|
ticketFk: id,
|
||||||
|
smsFk: sms.id
|
||||||
|
};
|
||||||
|
await models.TicketSms.create(newTicketSms);
|
||||||
|
|
||||||
const logRecord = {
|
const logRecord = {
|
||||||
originFk: id,
|
originFk: id,
|
||||||
userFk: userId,
|
userFk: userId,
|
||||||
|
@ -60,7 +68,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticketLog = await Self.app.models.TicketLog.create(logRecord, myOptions);
|
const ticketLog = await models.TicketLog.create(logRecord, myOptions);
|
||||||
|
|
||||||
sms.logId = ticketLog.id;
|
sms.logId = ticketLog.id;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue