fix: member commumication update
This commit is contained in:
parent
a660642bbb
commit
e3ff3456ad
1 changed files with 22 additions and 20 deletions
|
@ -18,6 +18,17 @@ export default abstract class CommunicationCommandHandler {
|
||||||
let insertId = -1;
|
let insertId = -1;
|
||||||
return await dataSource
|
return await dataSource
|
||||||
.transaction(async (manager) => {
|
.transaction(async (manager) => {
|
||||||
|
if (createCommunication.isSendNewsletter) {
|
||||||
|
await manager
|
||||||
|
.createQueryBuilder()
|
||||||
|
.update(communication)
|
||||||
|
.set({
|
||||||
|
isSendNewsletter: false,
|
||||||
|
})
|
||||||
|
.where("memberId = :memberId", { memberId: createCommunication.memberId })
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
await manager
|
await manager
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.insert()
|
.insert()
|
||||||
|
@ -40,16 +51,6 @@ export default abstract class CommunicationCommandHandler {
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
insertId = result.identifiers[0].id;
|
insertId = result.identifiers[0].id;
|
||||||
});
|
});
|
||||||
|
|
||||||
await manager
|
|
||||||
.createQueryBuilder()
|
|
||||||
.update(communication)
|
|
||||||
.set({
|
|
||||||
isSendNewsletter: false,
|
|
||||||
})
|
|
||||||
.where("memberId = :memberId", { memberId: createCommunication.memberId })
|
|
||||||
.andWhere("id <> :id", { id: insertId })
|
|
||||||
.execute();
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return insertId;
|
return insertId;
|
||||||
|
@ -67,6 +68,17 @@ export default abstract class CommunicationCommandHandler {
|
||||||
static async update(updateCommunication: UpdateCommunicationCommand): Promise<void> {
|
static async update(updateCommunication: UpdateCommunicationCommand): Promise<void> {
|
||||||
return await dataSource
|
return await dataSource
|
||||||
.transaction(async (manager) => {
|
.transaction(async (manager) => {
|
||||||
|
if (updateCommunication.isSendNewsletter) {
|
||||||
|
await manager
|
||||||
|
.createQueryBuilder()
|
||||||
|
.update(communication)
|
||||||
|
.set({
|
||||||
|
isSendNewsletter: false,
|
||||||
|
})
|
||||||
|
.where("memberId = :memberId", { memberId: updateCommunication.memberId })
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
await manager
|
await manager
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.update(communication)
|
.update(communication)
|
||||||
|
@ -85,16 +97,6 @@ export default abstract class CommunicationCommandHandler {
|
||||||
.where("id = :id", { id: updateCommunication.id })
|
.where("id = :id", { id: updateCommunication.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: updateCommunication.memberId })
|
.andWhere("memberId = :memberId", { memberId: updateCommunication.memberId })
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
await manager
|
|
||||||
.createQueryBuilder()
|
|
||||||
.update(communication)
|
|
||||||
.set({
|
|
||||||
isSendNewsletter: false,
|
|
||||||
})
|
|
||||||
.where("memberId = :memberId", { memberId: updateCommunication.memberId })
|
|
||||||
.andWhere("id <> :id", { id: updateCommunication.id })
|
|
||||||
.execute();
|
|
||||||
})
|
})
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue