add clients by excel
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller, Get, UseGuards, Patch, Body, ValidationPipe, Post, Query, Delete, Param } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiBody, ApiOkResponse, ApiHeader } from '@nestjs/swagger';
|
||||
import { Controller, Get, UseGuards, Patch, Body, ValidationPipe, Post, Query, Delete, Param, UploadedFile, UseInterceptors } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiBody, ApiOkResponse, ApiHeader, ApiConsumes } from '@nestjs/swagger';
|
||||
import { FileInterceptor, type File } from '@nest-lab/fastify-multer';
|
||||
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
||||
import { UserService } from '../providers/user.service';
|
||||
import { UpdateUserDto } from '../dto/update-user.dto';
|
||||
@@ -16,6 +17,7 @@ import { Permissions } from 'src/common/decorators/permissions.decorator';
|
||||
import { Permission } from 'src/common/enums/permission.enum';
|
||||
import { WalletService } from '../providers/wallet.service';
|
||||
import { FindUserByPhoneDto } from '../dto/find-user-by-phone.dto';
|
||||
import { ImportUsersFromExcelDto } from '../dto/import-users-from-excel.dto';
|
||||
|
||||
@ApiTags('User')
|
||||
@Controller()
|
||||
@@ -193,4 +195,21 @@ export class UsersController {
|
||||
) {
|
||||
return this.userService.findByPhone(query.phone);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_USERS)
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiOperation({ summary: 'Import users from Excel file into restaurant customers' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
@ApiBody({ type: ImportUsersFromExcelDto })
|
||||
@Post('admin/users/import')
|
||||
async importUsersFromExcel(@RestId() restId: string, @UploadedFile() file: File) {
|
||||
const result = await this.userService.importUsersFromExcel(restId, file);
|
||||
return {
|
||||
message: UserSuccessMessage.USERS_IMPORTED_SUCCESS,
|
||||
...result,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user