53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Put, Query, UseGuards } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
import { OriginGoodsService } from './origin-goods.service';
|
|
import { QueryOriginGoodDto } from './dto/query-origin-good.dto';
|
|
import { UpdateOriginGoodTagsDto } from './dto/update-origin-good-tags.dto';
|
|
|
|
@ApiTags('origin-goods')
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
@Controller('origin-goods')
|
|
export class OriginGoodsController {
|
|
constructor(private readonly service: OriginGoodsService) {}
|
|
|
|
@Get('tree')
|
|
@ApiOperation({
|
|
summary: 'Origin goods grouped by SDS category with config status',
|
|
})
|
|
getTree() {
|
|
return this.service.getTree();
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'Paginated list of origin goods (read-only)' })
|
|
findAll(@Query() query: QueryOriginGoodDto) {
|
|
return this.service.findAll(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: '单链接详情(detail + variants,成员展开面板用)' })
|
|
findOne(@Param('id') id: string) {
|
|
return this.service.findOne(BigInt(id));
|
|
}
|
|
|
|
@Get(':id/tags')
|
|
@ApiOperation({ summary: '链接当前标签(含 manual 标记)' })
|
|
getTags(@Param('id') id: string) {
|
|
return this.service.getTags(BigInt(id));
|
|
}
|
|
|
|
@Put(':id/tags')
|
|
@ApiOperation({ summary: '人工接管链接标签(全量替换,自动同步不再覆盖)' })
|
|
updateTags(@Param('id') id: string, @Body() dto: UpdateOriginGoodTagsDto) {
|
|
return this.service.updateTags(BigInt(id), dto.tagIds);
|
|
}
|
|
|
|
@Delete(':id/tags')
|
|
@ApiOperation({ summary: '恢复自动派生(清掉人工标签)' })
|
|
resetTags(@Param('id') id: string) {
|
|
return this.service.resetTags(BigInt(id));
|
|
}
|
|
}
|