| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2024-06-17 19:19:20 |
| 4 | * @LastEditTime: 2024-12-23 12:45:22 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: video |
| 7 | */ |
| 8 | import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common'; |
| 9 | import { ApiOperation, ApiTags } from '@nestjs/swagger'; |
| 10 | import { ParamsValidationPipe } from 'src/validation.pipe'; |
| 11 | import { TokenInfo } from 'src/auth/interfaces/auth.interfaces'; |
| 12 | import { GetToken } from 'src/auth/auth.guard'; |
| 13 | import { VideoService } from './video.service'; |
| 14 | import { AccountType } from 'src/db/schema/account.schema'; |
| 15 | import { TableDto } from 'src/global/dto/table.dto'; |
| 16 | import { |
| 17 | CreateVideoPulDto, |
| 18 | PubRecordIdDto, |
| 19 | VideoPulIdDto, |
| 20 | VideoPulListDto, |
| 21 | } from '../dto/video.dto'; |
| 22 | |
| 23 | @ApiTags('视频发布') |
| 24 | @Controller('video') |
| 25 | export class VideoController { |
| 26 | constructor(private readonly videoService: VideoService) {} |
| 27 | |
| 28 | @ApiOperation({ |
| 29 | description: '获取发布记录', |
| 30 | summary: '获取发布记录', |
| 31 | }) |
| 32 | @Get('list/:pubRecordId') |
| 33 | async getVideoRecord( |
| 34 | @Param(new ParamsValidationPipe()) param: PubRecordIdDto, |
| 35 | ) { |
| 36 | return this.videoService.getVideoPulListByPubRecordId(param.pubRecordId); |
| 37 | } |
| 38 | |
| 39 | @ApiOperation({ |
| 40 | description: '获取发布记录列表', |
| 41 | summary: '获取发布记录列表', |
| 42 | }) |
| 43 | @Get('list/:pageNo/:pageSize') |
| 44 | async getVideoPulList( |
| 45 | @GetToken() token: TokenInfo, |
| 46 | @Param(new ParamsValidationPipe()) param: TableDto, |
| 47 | @Query(new ParamsValidationPipe()) query: VideoPulListDto, |
| 48 | ) { |
| 49 | const res = await this.videoService.getVideoPulList(token.id, param, query); |
| 50 | return res; |
| 51 | } |
| 52 | |
| 53 | @ApiOperation({ |
| 54 | description: '获取视频发布信息', |
| 55 | summary: '获取视频发布信息', |
| 56 | }) |
| 57 | @Get('info/:id') |
| 58 | async getVideoPulInfo( |
| 59 | @Param(new ParamsValidationPipe()) param: VideoPulIdDto, |
| 60 | ) { |
| 61 | const res = await this.videoService.getVideoPulInfo(param.id); |
| 62 | return res; |
| 63 | } |
| 64 | |
| 65 | @ApiOperation({ |
| 66 | description: '创建视频发布记录', |
| 67 | summary: '创建视频发布记录', |
| 68 | }) |
| 69 | @Post('') |
| 70 | async newVideoPul( |
| 71 | @GetToken() token: TokenInfo, |
| 72 | @Body(new ParamsValidationPipe()) body: CreateVideoPulDto, |
| 73 | ) { |
| 74 | const res = await this.videoService.newVideoPul(token.id, body); |
| 75 | return res; |
| 76 | } |
| 77 | |
| 78 | @ApiOperation({ |
| 79 | description: '获取视频发布记录类型统计', |
| 80 | summary: '获取视频发布记录类型统计', |
| 81 | }) |
| 82 | @Get('count') |
| 83 | async getVideoPulTypeCount( |
| 84 | @GetToken() token: TokenInfo, |
| 85 | @Query(new ParamsValidationPipe()) |
| 86 | query: { |
| 87 | type?: AccountType; |
| 88 | }, |
| 89 | ) { |
| 90 | const res = await this.videoService.getVideoPulTypeCount( |
| 91 | token.id, |
| 92 | query.type, |
| 93 | ); |
| 94 | return res; |
| 95 | } |
| 96 | |
| 97 | @ApiOperation({ |
| 98 | description: '更新视频发布数据', |
| 99 | summary: '更新视频发布数据', |
| 100 | }) |
| 101 | @Post('up/:id') |
| 102 | async updateVideoPul( |
| 103 | @Param(new ParamsValidationPipe()) param: VideoPulIdDto, |
| 104 | @Body(new ParamsValidationPipe()) body: CreateVideoPulDto, |
| 105 | ) { |
| 106 | const res = await this.videoService.updateVideoPul(param.id, body); |
| 107 | return res; |
| 108 | } |
| 109 | |
| 110 | @ApiOperation({ |
| 111 | description: '删除发布记录', |
| 112 | summary: '删除发布记录', |
| 113 | }) |
| 114 | @Post('del/:id') |
| 115 | async delVideoPul(@Param(new ParamsValidationPipe()) param: VideoPulIdDto) { |
| 116 | const res = await this.videoService.deleteVideoPulByPubRecordId(param.id); |
| 117 | return res; |
| 118 | } |
| 119 | } |
| 120 |