From c4a60ae81367a323d10044395d8d8dded5c4dcaf Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 27 Oct 2025 10:59:41 +0330 Subject: [PATCH 1/3] add: update admin route added --- src/modules/admin/DTO/upateAdmin.dto.ts | 37 +++++++++++++++++++ .../admin/controllers/admin.controller.ts | 16 ++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/modules/admin/DTO/upateAdmin.dto.ts diff --git a/src/modules/admin/DTO/upateAdmin.dto.ts b/src/modules/admin/DTO/upateAdmin.dto.ts new file mode 100644 index 0000000..b7960da --- /dev/null +++ b/src/modules/admin/DTO/upateAdmin.dto.ts @@ -0,0 +1,37 @@ +import { Expose } from "class-transformer"; +import { IsNotEmpty } from "class-validator"; + +import { ApiProperty } from "../../../common/decorator/swggerDocs"; +import { AdminMessage, RoleMessage } from "../../../common/enums/message.enum"; + +export class UpdateAdminDTO { + @Expose() + @IsNotEmpty({ message: AdminMessage.FullNameNotEmpty }) + @ApiProperty({ type: "string", description: "full name of new admin", example: "admin 1" }) + fullName: string; + + @Expose() + @IsNotEmpty({ message: AdminMessage.UserNameNotEmpty }) + @ApiProperty({ type: "string", description: "username of new admin", example: "admin1" }) + userName: string; + + @Expose() + @IsNotEmpty({ message: AdminMessage.EmailNotEmpty }) + @ApiProperty({ type: "string", description: "email of new admin", example: "admin1@gmail.com" }) + email: string; + + @Expose() + @IsNotEmpty({ message: AdminMessage.PhoneNotEmpty }) + @ApiProperty({ type: "string", description: "phoneNumber of new admin", example: "09918914108" }) + phoneNumber: string; + + @Expose() + @IsNotEmpty({ message: RoleMessage.PermissionsNotEmpty }) + @ApiProperty({ type: "array", description: "permissions of user", example: ["67723b0c8109df157bd9b2c0", "67723b0c8109df157bd9b2ba"] }) + permissions: string[]; + + @Expose() + @IsNotEmpty({ message: AdminMessage.PasswordNotEmpty }) + @ApiProperty({ type: "string", description: "password", example: "123@123!" }) + password: string; +} diff --git a/src/modules/admin/controllers/admin.controller.ts b/src/modules/admin/controllers/admin.controller.ts index 1bbb9b7..96d69f5 100644 --- a/src/modules/admin/controllers/admin.controller.ts +++ b/src/modules/admin/controllers/admin.controller.ts @@ -101,6 +101,22 @@ export class AdminBaseController extends BaseController { return this.response(data); } + @ApiOperation("Update new admin") + @ApiResponse("successfully", HttpStatus.Created) + @ApiModel(CreateAdminDTO) + @ApiAuth() + @httpPost( + "/create", + Guard.authAdmin(), + Guard.checkAdminPermissions([PermissionEnum.ADMIN]), + ValidationMiddleware.validateInput(CreateAdminDTO), + ) + public async updateAdmin(@request() req: Request, @requestBody() createDto: CreateAdminDTO) { + const admin = req.user as IAdmin; + const data = await this.adminService.createAdminS(admin._id.toString(), createDto); + return this.response(data); + } + @ApiOperation("delete admin") @ApiResponse("successfully", HttpStatus.Ok) @ApiAuth() From b8f0365ad69e22a98e1c78128f6b6894b34f5925 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 27 Oct 2025 11:40:56 +0330 Subject: [PATCH 2/3] fix : admin shipment route --- src/modules/admin/controllers/shipment.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/admin/controllers/shipment.controller.ts b/src/modules/admin/controllers/shipment.controller.ts index 3b6c475..2fcf8c3 100644 --- a/src/modules/admin/controllers/shipment.controller.ts +++ b/src/modules/admin/controllers/shipment.controller.ts @@ -67,7 +67,7 @@ export class AdminShipmentController extends BaseController { @ApiOperation("activate the admin shop shipment method") @ApiModel(UpdateShopShipmentDTO) @ApiAuth() - @httpPatch("/shipment/activate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) + @httpPatch("/activate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) public async activateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { const admin = req.user as IAdmin; const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "activate"); @@ -77,7 +77,7 @@ export class AdminShipmentController extends BaseController { @ApiOperation("deactivate the admin shop shipment method") @ApiModel(UpdateShopShipmentDTO) @ApiAuth() - @httpPatch("/shipment/deactivate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) + @httpPatch("/deactivate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) public async deactivateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { const admin = req.user as IAdmin; const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "deactivate"); From be74d7521240ee2ab0899acf76038274568099e2 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 27 Oct 2025 11:44:21 +0330 Subject: [PATCH 3/3] fix : admin shipment route --- .../admin/controllers/shipment.controller.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/modules/admin/controllers/shipment.controller.ts b/src/modules/admin/controllers/shipment.controller.ts index 2fcf8c3..ce4632a 100644 --- a/src/modules/admin/controllers/shipment.controller.ts +++ b/src/modules/admin/controllers/shipment.controller.ts @@ -33,6 +33,26 @@ export class AdminShipmentController extends BaseController { return this.response({ data }, HttpStatus.Created); } + @ApiOperation("activate the admin shop shipment method") + @ApiModel(UpdateShopShipmentDTO) + @ApiAuth() + @httpPatch("/activate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) + public async activateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { + const admin = req.user as IAdmin; + const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "activate"); + return this.response(data); + } + + @ApiOperation("deactivate the admin shop shipment method") + @ApiModel(UpdateShopShipmentDTO) + @ApiAuth() + @httpPatch("/deactivate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) + public async deactivateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { + const admin = req.user as IAdmin; + const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "deactivate"); + return this.response(data); + } + @ApiOperation("update a shipment provider") @ApiResponse("successful", HttpStatus.Ok) @ApiParam("id", "shipment provider id", true) @@ -63,24 +83,4 @@ export class AdminShipmentController extends BaseController { const data = await this.shipmentService.getShipperDetail(+shipperId); return this.response(data); } - - @ApiOperation("activate the admin shop shipment method") - @ApiModel(UpdateShopShipmentDTO) - @ApiAuth() - @httpPatch("/activate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) - public async activateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { - const admin = req.user as IAdmin; - const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "activate"); - return this.response(data); - } - - @ApiOperation("deactivate the admin shop shipment method") - @ApiModel(UpdateShopShipmentDTO) - @ApiAuth() - @httpPatch("/deactivate", Guard.authAdmin(), ValidationMiddleware.validateInput(UpdateShopShipmentDTO)) - public async deactivateShopShipper(@request() req: Request, @requestBody() updateDto: UpdateShopShipmentDTO) { - const admin = req.user as IAdmin; - const data = await this.sellerService.updateShopShipperForAdmin(admin._id.toString(), updateDto, "deactivate"); - return this.response(data); - } }