Merge pull request #4 from Danakcorp/mrtz

add: ship detail
This commit is contained in:
morteza-mortezai
2025-09-28 15:02:27 +03:30
committed by GitHub
2 changed files with 19 additions and 1 deletions
@@ -1,5 +1,5 @@
import { inject } from "inversify"; 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 { HttpStatus } from "../../../common";
import { BaseController } from "../../../common/base/controller"; import { BaseController } from "../../../common/base/controller";
@@ -48,4 +48,14 @@ export class AdminShipmentController extends BaseController {
const data = await this.shipmentService.deleteShipper(+shipperId); const data = await this.shipmentService.deleteShipper(+shipperId);
return this.response(data); 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);
}
} }
+8
View File
@@ -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) { async calculateAllShipmentOptions(userId: string) {