feat(api): add mini program catalog endpoints and product details

This commit is contained in:
yeuimu
2026-08-21 02:11:20 +08:00
parent fcbf8bb494
commit 7d09077f1d
18 changed files with 1347 additions and 179 deletions
+29 -15
View File
@@ -2,14 +2,18 @@ import {
Controller,
Get,
Param,
ParseIntPipe,
Query,
} from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { ApiOkResponse, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
import { PublicService } from './public.service';
import { PublicQueryGoodDto } from './dto/public-query-good.dto';
import {
PublicCountryQueryDto,
PublicHomeGoodsQueryDto,
PublicQueryGoodDto,
} from './dto/public-query-good.dto';
import { PublicTagDto } from './dto/public-tag.dto';
import { PublicTagGroupDto } from './dto/public-tag-group.dto';
import { PublicGoodDetailDto, PublicTagGroupFilterDto } from './dto/public-good-detail.dto';
import { PublicGoodDto } from './dto/public-good.dto';
@ApiTags('public')
@Controller('public')
@@ -17,9 +21,9 @@ export class PublicController {
constructor(private readonly service: PublicService) {}
@Get('categories')
@ApiOperation({ summary: 'Public list of categories that have goods' })
getCategories() {
return this.service.getCategoriesTree();
@ApiOperation({ summary: '获取商品分类树;countryId 不传时返回全部国家' })
getCategories(@Query() query: PublicCountryQueryDto) {
return this.service.getCategoriesTree(query.countryId);
}
@Get('countries')
@@ -35,20 +39,30 @@ export class PublicController {
}
@Get('tag-groups')
@ApiOperation({ summary: 'Public list of tag groups that have goods' })
getTagGroups(): Promise<PublicTagGroupDto[]> {
return this.service.getTagGroups();
@ApiOperation({ summary: '获取标签组及标签筛选项;countryId 不传时返回全部国家' })
@ApiOkResponse({ type: [PublicTagGroupFilterDto] })
getTagGroups(@Query() query: PublicCountryQueryDto): Promise<PublicTagGroupFilterDto[]> {
return this.service.getTagGroups(query.countryId);
}
@Get('goods')
@ApiOperation({ summary: 'Public paginated goods with filters' })
@ApiOperation({ summary: '分页获取商品' })
getGoods(@Query() query: PublicQueryGoodDto) {
return this.service.getGoods(query);
}
@Get('goods/:id')
@ApiOperation({ summary: 'Public good detail' })
getGood(@Param('id', ParseIntPipe) id: string) {
return this.service.getGood(BigInt(id));
@Get('goods/:goodId')
@ApiOperation({ summary: '获取商品完整详情' })
@ApiParam({ name: 'goodId', type: String, example: '168746' })
@ApiOkResponse({ type: PublicGoodDetailDto })
getGood(@Param('goodId') goodId: string): Promise<PublicGoodDetailDto> {
return this.service.getGood(goodId);
}
@Get('home-goods')
@ApiOperation({ summary: '获取首页商品;可按国家返回' })
@ApiOkResponse({ type: [PublicGoodDto] })
getHomeGoods(@Query() query: PublicHomeGoodsQueryDto): Promise<PublicGoodDto[]> {
return this.service.getHomeGoods(query);
}
}