feat(pre-planting): 新增 GET /merges/:mergeNo 合并详情接口
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7bad0a8935
commit
b17bf82443
|
|
@ -3,6 +3,7 @@ import {
|
|||
Post,
|
||||
Get,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
Req,
|
||||
HttpCode,
|
||||
|
|
@ -98,4 +99,16 @@ export class PrePlantingController {
|
|||
const userId = BigInt(req.user.id);
|
||||
return this.prePlantingService.getMerges(userId);
|
||||
}
|
||||
|
||||
@Get('merges/:mergeNo')
|
||||
@ApiOperation({ summary: '获取单条合并记录详情' })
|
||||
@ApiResponse({ status: HttpStatus.OK, description: '合并记录详情' })
|
||||
@ApiResponse({ status: HttpStatus.NOT_FOUND, description: '合并记录不存在' })
|
||||
async getMergeDetail(
|
||||
@Req() req: AuthenticatedRequest,
|
||||
@Param('mergeNo') mergeNo: string,
|
||||
) {
|
||||
const userId = BigInt(req.user.id);
|
||||
return this.prePlantingService.getMergeDetail(userId, mergeNo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,6 +358,38 @@ export class PrePlantingApplicationService {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条合并记录详情
|
||||
*/
|
||||
async getMergeDetail(
|
||||
userId: bigint,
|
||||
mergeNo: string,
|
||||
): Promise<{
|
||||
mergeNo: string;
|
||||
sourceOrderNos: string[];
|
||||
treeCount: number;
|
||||
contractStatus: string;
|
||||
contractSignedAt: Date | null;
|
||||
miningEnabledAt: Date | null;
|
||||
mergedAt: Date;
|
||||
}> {
|
||||
return this.prisma.$transaction(async (tx) => {
|
||||
const merge = await this.mergeRepo.findByMergeNo(tx, mergeNo);
|
||||
if (!merge || merge.userId !== userId) {
|
||||
throw new NotFoundException(`合并记录不存在: ${mergeNo}`);
|
||||
}
|
||||
return {
|
||||
mergeNo: merge.mergeNo,
|
||||
sourceOrderNos: merge.sourceOrderNos,
|
||||
treeCount: merge.treeCount,
|
||||
contractStatus: merge.contractStatus,
|
||||
contractSignedAt: merge.contractSignedAt,
|
||||
miningEnabledAt: merge.miningEnabledAt,
|
||||
mergedAt: merge.mergedAt,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预种资格信息(供内部 API + 移动端购买页使用)
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue