feat: update user code that has no associated branch
This commit is contained in:
parent
721f3bce6e
commit
d8034e221c
1 changed files with 26 additions and 0 deletions
|
|
@ -157,6 +157,12 @@ export class BranchUserController extends Controller {
|
|||
await prisma.$transaction(
|
||||
body.user.map((v) => prisma.branchUser.deleteMany({ where: { branchId, userId: v } })),
|
||||
);
|
||||
await prisma.user.updateMany({
|
||||
where: {
|
||||
branch: { none: {} },
|
||||
},
|
||||
data: { code: null },
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("{userId}")
|
||||
|
|
@ -164,6 +170,13 @@ export class BranchUserController extends Controller {
|
|||
await prisma.branchUser.deleteMany({
|
||||
where: { branchId, userId },
|
||||
});
|
||||
await prisma.user.updateMany({
|
||||
where: {
|
||||
id: userId,
|
||||
branch: { none: {} },
|
||||
},
|
||||
data: { code: null },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -253,6 +266,12 @@ export class UserBranchController extends Controller {
|
|||
await prisma.$transaction(
|
||||
body.branch.map((v) => prisma.branchUser.deleteMany({ where: { userId, branchId: v } })),
|
||||
);
|
||||
await prisma.user.updateMany({
|
||||
where: {
|
||||
branch: { none: {} },
|
||||
},
|
||||
data: { code: null },
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("{branchId}")
|
||||
|
|
@ -260,5 +279,12 @@ export class UserBranchController extends Controller {
|
|||
await prisma.branchUser.deleteMany({
|
||||
where: { branchId, userId },
|
||||
});
|
||||
await prisma.user.updateMany({
|
||||
where: {
|
||||
id: userId,
|
||||
branch: { none: {} },
|
||||
},
|
||||
data: { code: null },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue