restauarant list in sup
This commit is contained in:
@@ -5,13 +5,15 @@ import { Restaurant } from '../entities/restaurant.entity';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { RestRepository } from '../repositories/rest.repository';
|
||||
import { RestMessage } from 'src/common/enums/message.enum';
|
||||
import { FindRestaurantsDto } from '../dto/find-restaurants.dto';
|
||||
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
||||
|
||||
@Injectable()
|
||||
export class RestaurantsService {
|
||||
constructor(
|
||||
private readonly em: EntityManager,
|
||||
private readonly restRepository: RestRepository,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async create(dto: CreateRestaurantDto): Promise<Restaurant> {
|
||||
const restaurant = this.em.create(Restaurant, {
|
||||
@@ -24,8 +26,16 @@ export class RestaurantsService {
|
||||
return restaurant;
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.restRepository.findAll();
|
||||
async findAll(dto: FindRestaurantsDto): Promise<PaginatedResult<Restaurant>> {
|
||||
return this.restRepository.findAllPaginated({
|
||||
page: dto.page,
|
||||
limit: dto.limit,
|
||||
search: dto.search,
|
||||
isActive: dto.isActive,
|
||||
plan: dto.plan,
|
||||
orderBy: dto.orderBy,
|
||||
order: dto.order,
|
||||
});
|
||||
}
|
||||
|
||||
async findBySlug(slug: string): Promise<Restaurant> {
|
||||
|
||||
Reference in New Issue
Block a user