From 44bfbe0bef22c2364a28d1c34bceae304776ade0 Mon Sep 17 00:00:00 2001 From: developer_liu Date: Wed, 2 Sep 2026 09:49:33 +0800 Subject: [PATCH] v4.0.10 --- .../modules/store/dto/assign-category.dto.ts | 12 ++++++ .../src/modules/store/store.controller.ts | 38 +++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 server/dukang-api/src/modules/store/dto/assign-category.dto.ts diff --git a/server/dukang-api/src/modules/store/dto/assign-category.dto.ts b/server/dukang-api/src/modules/store/dto/assign-category.dto.ts new file mode 100644 index 0000000..fab6c1d --- /dev/null +++ b/server/dukang-api/src/modules/store/dto/assign-category.dto.ts @@ -0,0 +1,12 @@ +import { IsString, IsNotEmpty, IsOptional, IsInt, Min } from 'class-validator'; + +export class AssignCategoryDto { + @IsString() + @IsNotEmpty() + categoryId!: string; + + @IsOptional() + @IsInt() + @Min(0) + priority?: number; +} diff --git a/server/dukang-api/src/modules/store/store.controller.ts b/server/dukang-api/src/modules/store/store.controller.ts index 61731f1..7732c55 100644 --- a/server/dukang-api/src/modules/store/store.controller.ts +++ b/server/dukang-api/src/modules/store/store.controller.ts @@ -109,9 +109,41 @@ export class PartnerStoreController { } @Get(':id') - detail(@CurrentUser() user: AuthUser, @Param('id') id: string) { - return this.storeService.partnerGetStore(user.actorId, BigInt(id)); - } + async detail(@CurrentUser() user: AuthUser, @Param('id') id: string) { + return this.storeService.partnerGetStore(user.actorId, BigInt(id)); + } + + @Get(':id/categories') + async getCategories(@CurrentUser() user: AuthUser, @Param('id') id: string) { + return this.storeService.getStoreCategories(BigInt(id)); + } + + @Post(':id/categories') + async assignCategory( + @CurrentUser() user: AuthUser, + @Param('id') id: string, + @Body() body: { categoryId: string; priority?: number }, + ) { + return this.storeService.assignCategoryToStore(BigInt(id), body.categoryId, body.priority); + } + + @Delete(':id/categories/:categoryId') + async removeCategory( + @CurrentUser() user: AuthUser, + @Param('id') id: string, + @Param('categoryId') categoryId: string, + ) { + return this.storeService.removeCategoryFromStore(BigInt(id), categoryId); + } + + @Put(':id/categories') + async replaceCategories( + @CurrentUser() user: AuthUser, + @Param('id') id: string, + @Body() body: { categoryIds: string[]; priorities?: Record }, + ) { + return this.storeService.replaceStoreCategories(BigInt(id), body.categoryIds, body.priorities); + } @Post() create(@CurrentUser() user: AuthUser, @Body() body: Record) {