resturant module
This commit is contained in:
@@ -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 { Module } from '@nestjs/common';
|
||||||
import { RestaurantsService } from './restaurants.service';
|
import { RestaurantsService } from './restaurants.service';
|
||||||
import { RestaurantsController } from './restaurants.controller';
|
import { RestaurantsController } from './restaurants.controller';
|
||||||
|
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
||||||
|
import { Restaurant } from './entities/restaurant.entity';
|
||||||
|
import { RestRepository } from './repositories/rest.repository';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [RestaurantsController],
|
controllers: [RestaurantsController],
|
||||||
providers: [RestaurantsService],
|
providers: [RestaurantsService, RestRepository],
|
||||||
|
imports: [MikroOrmModule.forFeature([Restaurant])],
|
||||||
|
exports: [RestRepository],
|
||||||
})
|
})
|
||||||
export class RestaurantsModule {}
|
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";
|
export class UserRepository extends EntityRepository<User> {}
|
||||||
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" },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user