From 4d65c928edc56d40f99408497b3b36522e5e0120 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sun, 28 Sep 2025 15:01:18 +0330 Subject: [PATCH] add: ship detail --- src/modules/admin/controllers/shipment.controller.ts | 12 +++++++++++- src/modules/shipment/shipment.service.ts | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modules/admin/controllers/shipment.controller.ts b/src/modules/admin/controllers/shipment.controller.ts index 111af96..578f954 100644 --- a/src/modules/admin/controllers/shipment.controller.ts +++ b/src/modules/admin/controllers/shipment.controller.ts @@ -1,5 +1,5 @@ import { inject } from "inversify"; -import { controller, httpDelete, httpPatch, httpPost, requestBody, requestParam } from "inversify-express-utils"; +import { controller, httpDelete, httpGet, httpPatch, httpPost, requestBody, requestParam } from "inversify-express-utils"; import { HttpStatus } from "../../../common"; import { BaseController } from "../../../common/base/controller"; @@ -48,4 +48,14 @@ export class AdminShipmentController extends BaseController { const data = await this.shipmentService.deleteShipper(+shipperId); return this.response(data); } + + @ApiOperation("get shipment detail") + @ApiResponse("successful", HttpStatus.Ok) + @ApiParam("id", "shipment id", true) + @ApiAuth() + @httpGet("/:id", Guard.authAdmin(), Guard.checkAdminPermissions([PermissionEnum.ADMIN])) + public async getShipmentDetail(@requestParam("id") shipperId: string) { + const data = await this.shipmentService.getShipperDetail(+shipperId); + return this.response(data); + } } diff --git a/src/modules/shipment/shipment.service.ts b/src/modules/shipment/shipment.service.ts index ef3e20e..ac0435e 100644 --- a/src/modules/shipment/shipment.service.ts +++ b/src/modules/shipment/shipment.service.ts @@ -74,6 +74,14 @@ class ShipmentService { }; } + async getShipperDetail(shipperId: number) { + const shipper = await this.shipmentRepo.model.findOne({ _id: shipperId, deleted: false }); + if (!shipper) throw new BadRequestError(CommonMessage.NotFoundById); + return { + shipper, + }; + } + //################################################################### //################################################################### async calculateAllShipmentOptions(userId: string) {