@@ -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;
|
||||||
|
}
|
||||||
@@ -101,6 +101,22 @@ export class AdminBaseController extends BaseController {
|
|||||||
return this.response(data);
|
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")
|
@ApiOperation("delete admin")
|
||||||
@ApiResponse("successfully", HttpStatus.Ok)
|
@ApiResponse("successfully", HttpStatus.Ok)
|
||||||
@ApiAuth()
|
@ApiAuth()
|
||||||
|
|||||||
@@ -33,6 +33,26 @@ export class AdminShipmentController extends BaseController {
|
|||||||
return this.response({ data }, HttpStatus.Created);
|
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")
|
@ApiOperation("update a shipment provider")
|
||||||
@ApiResponse("successful", HttpStatus.Ok)
|
@ApiResponse("successful", HttpStatus.Ok)
|
||||||
@ApiParam("id", "shipment provider id", true)
|
@ApiParam("id", "shipment provider id", true)
|
||||||
@@ -63,24 +83,4 @@ export class AdminShipmentController extends BaseController {
|
|||||||
const data = await this.shipmentService.getShipperDetail(+shipperId);
|
const data = await this.shipmentService.getShipperDetail(+shipperId);
|
||||||
return this.response(data);
|
return this.response(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("activate the admin shop shipment method")
|
|
||||||
@ApiModel(UpdateShopShipmentDTO)
|
|
||||||
@ApiAuth()
|
|
||||||
@httpPatch("/shipment/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("/shipment/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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user