feat: 完成分类、worksheet 接口开发,资源迁移到七牛
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import {
|
||||
ApiNotFoundResponse,
|
||||
ApiOkResponse,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import type {
|
||||
ApiSuccess,
|
||||
PublicWorksheet,
|
||||
WorksheetPage,
|
||||
} from '@doodle/contracts';
|
||||
import { Public } from '../auth/auth.decorators';
|
||||
import { WorksheetQueryDto } from './worksheet-query.dto';
|
||||
import { WorksheetService } from './worksheet.service';
|
||||
|
||||
@Controller('worksheets')
|
||||
@ApiTags('worksheets')
|
||||
@Public()
|
||||
/** 小程序与未来 Web 共用的公开只读接口,不提供管理状态或原始统计的查询开关。 */
|
||||
export class WorksheetController {
|
||||
constructor(private readonly worksheets: WorksheetService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary: '分页查询全部/分类/年级/年龄段/Tag,支持最新和热门排序',
|
||||
security: [],
|
||||
description:
|
||||
'条件可组合,题型及全部上级分类必须 active;sort=hot 按下载展示值降序;isHot 为运营标记筛选。预览未就绪返回 null。',
|
||||
})
|
||||
@ApiOkResponse({
|
||||
description:
|
||||
'{code:0,message:"ok",data:{items,total,page,pageSize,hasNext}};downloads/likes 为含 seed 的十进制字符串。',
|
||||
})
|
||||
async list(
|
||||
@Query() query: WorksheetQueryDto,
|
||||
): Promise<ApiSuccess<WorksheetPage>> {
|
||||
return {
|
||||
code: 0,
|
||||
message: 'ok',
|
||||
data: await this.worksheets.list(query),
|
||||
};
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({
|
||||
summary: '公开题型详情;不存在或未发布返回 404',
|
||||
security: [],
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
example: 'number-find',
|
||||
description: '使用题型列表 data.items 中的 id,例如 number-find',
|
||||
})
|
||||
@ApiNotFoundResponse({
|
||||
description: '题型不存在,或题型及所属分类链尚未全部上线',
|
||||
})
|
||||
async get(@Param('id') id: string): Promise<ApiSuccess<PublicWorksheet>> {
|
||||
return { code: 0, message: 'ok', data: await this.worksheets.get(id) };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user