| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-02-15 20:59:55 |
| 4 | * @LastEditTime: 2025-04-27 18:00:18 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: signIn SignIn 签到 |
| 7 | */ |
| 8 | import { |
| 9 | Body, |
| 10 | Controller, |
| 11 | Get, |
| 12 | Param, |
| 13 | Post, |
| 14 | Query, |
| 15 | UploadedFile, |
| 16 | UseInterceptors, |
| 17 | } from '@nestjs/common'; |
| 18 | import { ApiOperation, ApiTags } from '@nestjs/swagger'; |
| 19 | import { |
| 20 | AccessBackDto, |
| 21 | ArchiveAddByUtokenBodyDto, |
| 22 | ArchiveAddByUtokenQueryDto, |
| 23 | } from './dto/bilibili.dto'; |
| 24 | import { GzhService } from './gzh.service'; |
| 25 | import { Public } from 'src/auth/auth.guard'; |
| 26 | import { FileInterceptor } from '@nestjs/platform-express'; |
| 27 | |
| 28 | @ApiTags('plat/gzh - B站平台') |
| 29 | @Controller('plat/gzh') |
| 30 | export class GzhController { |
| 31 | constructor(private readonly bilibiliService: GzhService) {} |
| 32 | |
| 33 | @ApiOperation({ summary: '获取AccessToken' }) |
| 34 | @Public() |
| 35 | @Get('accessToken') |
| 36 | async getAccessToken(@Query() query: AccessBackDto) { |
| 37 | // const res = await this.bilibiliService.getAccessToken(query.code); |
| 38 | // return res; |
| 39 | } |
| 40 | |
| 41 | @ApiOperation({ summary: '刷新授权Token' }) |
| 42 | @Get('refreshAccessToken/:refreshToken') |
| 43 | async refreshAccessToken(@Param('refreshToken') refreshToken: string) { |
| 44 | return this.bilibiliService.refreshAccessToken(refreshToken); |
| 45 | } |
| 46 | |
| 47 | @ApiOperation({ summary: '查询用户已授权权限列表' }) |
| 48 | @Get('account/scopes/:accessToken') |
| 49 | async getAccountScopes(@Param('accessToken') accessToken: string) { |
| 50 | return this.bilibiliService.getAccountScopes(accessToken); |
| 51 | } |
| 52 | |
| 53 | @ApiOperation({ summary: '视频初始化' }) |
| 54 | @Post('video/init/:accessToken') |
| 55 | async videoInit(@Param('accessToken') accessToken: string) { |
| 56 | return this.bilibiliService.videoInit(accessToken); |
| 57 | } |
| 58 | |
| 59 | @ApiOperation({ summary: '封面上传' }) |
| 60 | @UseInterceptors(FileInterceptor('file')) |
| 61 | @Post('cover/upload') |
| 62 | async coverUpload( |
| 63 | @Param('accessToken') accessToken: string, |
| 64 | @UploadedFile() file: Express.Multer.File, |
| 65 | ) { |
| 66 | return this.bilibiliService.coverUpload(accessToken, file); |
| 67 | } |
| 68 | |
| 69 | @ApiOperation({ summary: '视频稿件提交' }) |
| 70 | @Post('archive/add-by-utoken') |
| 71 | async archiveAddByUtoken( |
| 72 | @Query() query: ArchiveAddByUtokenQueryDto, |
| 73 | @Body() body: ArchiveAddByUtokenBodyDto, |
| 74 | ) { |
| 75 | const data = { |
| 76 | ...body, |
| 77 | no_reprint: body.noReprint, |
| 78 | tag: body.tag.join(','), |
| 79 | }; |
| 80 | const { accessToken, uploadToken } = query; |
| 81 | // return this.bilibiliService.archiveAddByUtoken( |
| 82 | // accessToken, |
| 83 | // uploadToken, |
| 84 | // data, |
| 85 | // ); |
| 86 | } |
| 87 | |
| 88 | @ApiOperation({ summary: '分区查询' }) |
| 89 | @Get('archive/type/list/:accessToken') |
| 90 | async archiveTypeList(@Param('accessToken') accessToken: string) { |
| 91 | return this.bilibiliService.archiveTypeList(accessToken); |
| 92 | } |
| 93 | } |
| 94 |