|
@@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common'
|
|
|
import { Repository } from 'typeorm'
|
|
import { Repository } from 'typeorm'
|
|
|
import { Gallery } from './entities/gallery.entity'
|
|
import { Gallery } from './entities/gallery.entity'
|
|
|
import { InjectRepository } from '@nestjs/typeorm'
|
|
import { InjectRepository } from '@nestjs/typeorm'
|
|
|
|
|
+import { PageRequest } from '../common/dto/page-request'
|
|
|
|
|
+import { Pagination, paginate } from 'nestjs-typeorm-paginate'
|
|
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
|
export class GalleryService {
|
|
export class GalleryService {
|
|
@@ -10,11 +12,11 @@ export class GalleryService {
|
|
|
private readonly galleryRepository: Repository<Gallery>
|
|
private readonly galleryRepository: Repository<Gallery>
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
- async findAll(): Promise<Gallery[]> {
|
|
|
|
|
- return await this.galleryRepository.find()
|
|
|
|
|
|
|
+ async findAll(req: PageRequest<Gallery>): Promise<Pagination<Gallery>> {
|
|
|
|
|
+ return await paginate<Gallery>(this.galleryRepository, req.page, req.search)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async save(gallery: Gallery): Promise<Gallery> {
|
|
|
|
|
|
|
+ async save(gallery: Partial<Gallery>): Promise<Gallery> {
|
|
|
return await this.galleryRepository.save(gallery)
|
|
return await this.galleryRepository.save(gallery)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|