refactor: change the role to roles and many to many

This commit is contained in:
mahyargdz
2025-02-16 16:58:51 +03:30
parent 9cdd7ef28e
commit ad673613d9
32 changed files with 264 additions and 88 deletions
@@ -7,7 +7,6 @@ import { DataSource, Not, QueryRunner } from "typeorm";
import { PaginationDto } from "../../../common/DTO/pagination.dto";
import { CommonMessage, PaymentMessage, UserMessage, WalletMessage } from "../../../common/enums/message.enum";
import { Role } from "../../users/entities/role.entity";
import { User } from "../../users/entities/user.entity";
import { RoleEnum } from "../../users/enums/role.enum";
import { PaginationUtils } from "../../utils/providers/pagination.utils";
@@ -263,11 +262,10 @@ export class PaymentsService {
await this.bankAccountsRepository.save({ ...bankAccount, ...updateDto });
}
//*********************************** */
async getBankAccounts(role: Role) {
const userRole = role as unknown as RoleEnum;
async getBankAccounts(roles: RoleEnum[]) {
let bankAccounts: BankAccount[];
if (userRole === RoleEnum.USER) {
if (roles.includes(RoleEnum.USER)) {
bankAccounts = await this.bankAccountsRepository.find({ where: { isActive: true } });
} else {
bankAccounts = await this.bankAccountsRepository.find();