refactor: user relation
This commit is contained in:
parent
a74d8b63b1
commit
2bd30b735d
21 changed files with 607 additions and 185 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Branch, Prisma, Status, User, UserType } from "@prisma/client";
|
||||
import { Branch, Prisma, Status, User } from "@prisma/client";
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
|
|
@ -113,11 +113,7 @@ export class BranchUserController extends Controller {
|
|||
]);
|
||||
|
||||
if (!branch) {
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Branch cannot be found.",
|
||||
"branchBadReq",
|
||||
);
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "Branch cannot be found.", "branchBadReq");
|
||||
}
|
||||
|
||||
if (user.length !== body.user.length) {
|
||||
|
|
@ -139,8 +135,8 @@ export class BranchUserController extends Controller {
|
|||
.map((v) => ({
|
||||
branchId,
|
||||
userId: v.id,
|
||||
createdBy: req.user.name,
|
||||
updatedBy: req.user.name,
|
||||
createdByUserId: req.user.sub,
|
||||
updatedByUserId: req.user.sub,
|
||||
})),
|
||||
}),
|
||||
]);
|
||||
|
|
@ -249,8 +245,8 @@ export class UserBranchController extends Controller {
|
|||
.map((v) => ({
|
||||
branchId: v.id,
|
||||
userId,
|
||||
createdBy: req.user.name,
|
||||
updatedBy: req.user.name,
|
||||
createdByUserId: req.user.sub,
|
||||
updatedByUserId: req.user.sub,
|
||||
})),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue