feat: refs #7322 add optional addressFk parameter to transferClient method
This commit is contained in:
parent
48ad72ac98
commit
ec14281a82
|
@ -12,6 +12,10 @@ module.exports = Self => {
|
|||
arg: 'clientFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
}, {
|
||||
arg: 'addressFk',
|
||||
type: 'number',
|
||||
required: false,
|
||||
}],
|
||||
http: {
|
||||
path: `/:id/transferClient`,
|
||||
|
@ -19,7 +23,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.transferClient = async(ctx, id, clientFk, options) => {
|
||||
Self.transferClient = async(ctx, id, clientFk, addressFk, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
@ -43,10 +47,10 @@ module.exports = Self => {
|
|||
const client = await models.Client.findById(clientFk,
|
||||
{fields: ['id', 'defaultAddressFk']}, myOptions);
|
||||
|
||||
const address = await models.Address.findById(client.defaultAddressFk,
|
||||
const address = await models.Address.findById(addressFk ? addressFk : client.defaultAddressFk,
|
||||
{fields: ['id', 'nickname']}, myOptions);
|
||||
|
||||
const attributes = {clientFk, addressFk: client.defaultAddressFk, nickname: address.nickname};
|
||||
const attributes = {clientFk, addressFk: address.id, nickname: address.nickname};
|
||||
|
||||
const tickets = [];
|
||||
const ticketIds = [];
|
||||
|
|
Loading…
Reference in New Issue