|
@@ -0,0 +1,29 @@
|
|
|
|
|
+import { Injectable } from '@nestjs/common'
|
|
|
|
|
+import { Repository } from 'typeorm'
|
|
|
|
|
+import { Channel } from './entities/channel.entities'
|
|
|
|
|
+import { InjectRepository } from '@nestjs/typeorm'
|
|
|
|
|
+import { PageRequest } from '../common/dto/page-request'
|
|
|
|
|
+import { paginate, Pagination } from 'nestjs-typeorm-paginate'
|
|
|
|
|
+
|
|
|
|
|
+@Injectable()
|
|
|
|
|
+export class ChannelService {
|
|
|
|
|
+
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ @InjectRepository(Channel)
|
|
|
|
|
+ private channelRepository: Repository<Channel>
|
|
|
|
|
+ ) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async findAll(req: PageRequest<Channel>): Promise<Pagination<Channel>> {
|
|
|
|
|
+ return await paginate<Channel>(this.channelRepository, req.page, req.search)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async create(channel: Channel): Promise<Channel> {
|
|
|
|
|
+ return await this.channelRepository.save(channel)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async delete(id: number): Promise<void> {
|
|
|
|
|
+ await this.channelRepository.delete(id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|