fix(docs): describe tags as grouped array
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
|
||||||
import { plainToInstance, Transform, Type } from 'class-transformer';
|
import { plainToInstance, Transform, Type } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
@@ -74,16 +74,7 @@ export class PublicQueryGoodDto {
|
|||||||
@IsNumberString()
|
@IsNumberString()
|
||||||
categoryId?: string;
|
categoryId?: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiHideProperty()
|
||||||
required: false,
|
|
||||||
type: [PublicTagFilterDto],
|
|
||||||
description:
|
|
||||||
'标签筛选分组。同组 tagIds 按 OR 匹配,不同数组元素按 AND 匹配。GET 请求建议将整个数组 JSON.stringify 后传入 tags',
|
|
||||||
example: [
|
|
||||||
{ tagGroupId: '1', tagIds: ['11', '12'] },
|
|
||||||
{ tagGroupId: '2', tagIds: ['25'] },
|
|
||||||
],
|
|
||||||
})
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Transform(tagFilters)
|
@Transform(tagFilters)
|
||||||
@IsArray()
|
@IsArray()
|
||||||
|
|||||||
@@ -4,18 +4,28 @@ import {
|
|||||||
Param,
|
Param,
|
||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiOkResponse, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
import {
|
||||||
|
ApiExtraModels,
|
||||||
|
ApiOkResponse,
|
||||||
|
ApiOperation,
|
||||||
|
ApiParam,
|
||||||
|
ApiQuery,
|
||||||
|
ApiTags,
|
||||||
|
getSchemaPath,
|
||||||
|
} from '@nestjs/swagger';
|
||||||
import { PublicService } from './public.service';
|
import { PublicService } from './public.service';
|
||||||
import {
|
import {
|
||||||
PublicCountryQueryDto,
|
PublicCountryQueryDto,
|
||||||
PublicHomeGoodsQueryDto,
|
PublicHomeGoodsQueryDto,
|
||||||
PublicQueryGoodDto,
|
PublicQueryGoodDto,
|
||||||
|
PublicTagFilterDto,
|
||||||
} from './dto/public-query-good.dto';
|
} from './dto/public-query-good.dto';
|
||||||
import { PublicTagDto } from './dto/public-tag.dto';
|
import { PublicTagDto } from './dto/public-tag.dto';
|
||||||
import { PublicGoodDetailDto, PublicTagGroupFilterDto } from './dto/public-good-detail.dto';
|
import { PublicGoodDetailDto, PublicTagGroupFilterDto } from './dto/public-good-detail.dto';
|
||||||
import { PublicGoodDto } from './dto/public-good.dto';
|
import { PublicGoodDto } from './dto/public-good.dto';
|
||||||
|
|
||||||
@ApiTags('public')
|
@ApiTags('public')
|
||||||
|
@ApiExtraModels(PublicTagFilterDto)
|
||||||
@Controller('public')
|
@Controller('public')
|
||||||
export class PublicController {
|
export class PublicController {
|
||||||
constructor(private readonly service: PublicService) {}
|
constructor(private readonly service: PublicService) {}
|
||||||
@@ -47,6 +57,24 @@ export class PublicController {
|
|||||||
|
|
||||||
@Get('goods')
|
@Get('goods')
|
||||||
@ApiOperation({ summary: '分页获取商品' })
|
@ApiOperation({ summary: '分页获取商品' })
|
||||||
|
@ApiQuery({
|
||||||
|
name: 'tags',
|
||||||
|
required: false,
|
||||||
|
description:
|
||||||
|
'标签筛选分组。参数值为 JSON 数组;同组 tagIds 按 OR 匹配,不同标签组按 AND 匹配',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: {
|
||||||
|
type: 'array',
|
||||||
|
items: { $ref: getSchemaPath(PublicTagFilterDto) },
|
||||||
|
},
|
||||||
|
example: [
|
||||||
|
{ tagGroupId: '1', tagIds: ['11', '12'] },
|
||||||
|
{ tagGroupId: '2', tagIds: ['25'] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
getGoods(@Query() query: PublicQueryGoodDto) {
|
getGoods(@Query() query: PublicQueryGoodDto) {
|
||||||
return this.service.getGoods(query);
|
return this.service.getGoods(query);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user