resturant module

This commit is contained in:
2025-11-11 15:57:57 +03:30
parent 95191f9b30
commit 111540bb15
3 changed files with 15 additions and 39 deletions
@@ -0,0 +1,6 @@
import { EntityRepository } from '@mikro-orm/postgresql';
import type { Restaurant } from '../entities/restaurant.entity';
// import { PaginationUtils } from '../../utils/services/pagination.utils';
export class RestRepository extends EntityRepository<Restaurant> {}
@@ -1,9 +1,14 @@
import { Module } from '@nestjs/common';
import { RestaurantsService } from './restaurants.service';
import { RestaurantsController } from './restaurants.controller';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Restaurant } from './entities/restaurant.entity';
import { RestRepository } from './repositories/rest.repository';
@Module({
controllers: [RestaurantsController],
providers: [RestaurantsService],
providers: [RestaurantsService, RestRepository],
imports: [MikroOrmModule.forFeature([Restaurant])],
exports: [RestRepository],
})
export class RestaurantsModule {}
@@ -1,39 +1,4 @@
import { EntityRepository, FilterQuery } from "@mikro-orm/postgresql";
import { EntityRepository } from '@mikro-orm/postgresql';
import type { User } from '../entities/user.entity';
import { PaginationUtils } from "../../utils/services/pagination.utils";
import { UserListQueryDto } from "../DTO/user-list-query.dto";
import { User } from "../entities/user.entity";
export class UserRepository extends EntityRepository<User> {
async getUserListForAdmin(businessId: string, queryDto: UserListQueryDto) {
const { limit, skip } = PaginationUtils(queryDto);
const whereClause: FilterQuery<User> = {
business: { id: businessId },
emailEnabled: true,
deletedAt: null,
};
if (queryDto.q) {
whereClause.$or = [
{ userName: { $like: `%${queryDto.q}%` } },
{ emailAddress: { $like: `%${queryDto.q}%` } },
{ displayName: { $like: `%${queryDto.q}%` } },
];
}
if (queryDto.isActive) {
console.log(queryDto.isActive);
whereClause.isActive = queryDto.isActive === 1;
}
return this.findAndCount(whereClause, {
exclude: ["password"],
populate: ["domain", "business"],
limit,
offset: skip,
orderBy: { createdAt: "DESC" },
});
}
}
export class UserRepository extends EntityRepository<User> {}