fix(orders): getOwned 统一带 relations,修复 include 分支的类型错误
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,10 +29,10 @@ export class OrdersService {
|
||||
};
|
||||
}
|
||||
|
||||
private async getOwned(userId: string, id: string, includeRelations = false) {
|
||||
private async getOwned(userId: string, id: string) {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
where: { id },
|
||||
include: includeRelations ? { items: true, payment: true } : undefined,
|
||||
include: { items: true, payment: true },
|
||||
});
|
||||
if (!order) throw new NotFoundException('订单不存在');
|
||||
if (order.userId !== userId) throw new ForbiddenException('无权操作该订单');
|
||||
@@ -62,7 +62,7 @@ export class OrdersService {
|
||||
|
||||
async findOne(userId: string, id: string) {
|
||||
// 越权 403 / 不存在 404(契约 §6)
|
||||
const order = await this.getOwned(userId, id, true);
|
||||
const order = await this.getOwned(userId, id);
|
||||
return this.toClientOrder(order);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user