style: apply standard ESLint & Prettier formatting across backend
Deploy Canina / deploy (push) Successful in 4m58s
Deploy Canina / deploy (push) Successful in 4m58s
This commit is contained in:
1 parent
ae636c8b03
commit
62bd8811fa
66 files changed
+1398
-607
No files matched your search
@@ -1,7 +1,22 @@
|
||||
import { Controller, Get, UseGuards, Param, Put, Post, Body, Delete, Query } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
UseGuards,
|
||||
Param,
|
||||
Put,
|
||||
Post,
|
||||
Body,
|
||||
Delete,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { AdminService } from './admin.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiQuery } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Admin - پنل مدیریت')
|
||||
@ApiBearerAuth()
|
||||
@@ -16,7 +31,7 @@ export class AdminController {
|
||||
const stats = await this.adminService.getDashboardStats();
|
||||
return {
|
||||
success: true,
|
||||
data: stats
|
||||
data: stats,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,15 +40,28 @@ export class AdminController {
|
||||
@ApiOperation({ summary: 'لیست کاربران' })
|
||||
@ApiQuery({ name: 'page', required: false, description: 'شماره صفحه' })
|
||||
@ApiQuery({ name: 'limit', required: false, description: 'تعداد آیتمها' })
|
||||
@ApiQuery({ name: 'search', required: false, description: 'جستجو در نام یا ایمیل' })
|
||||
@ApiQuery({ name: 'role', required: false, description: 'فیلتر بر اساس نقش کاربر' })
|
||||
@ApiQuery({
|
||||
name: 'search',
|
||||
required: false,
|
||||
description: 'جستجو در نام یا ایمیل',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'role',
|
||||
required: false,
|
||||
description: 'فیلتر بر اساس نقش کاربر',
|
||||
})
|
||||
async getUsers(
|
||||
@Query('page') page?: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query('search') search?: string,
|
||||
@Query('role') role?: string
|
||||
@Query('role') role?: string,
|
||||
) {
|
||||
const data = await this.adminService.getUsers({ page, limit, search, role });
|
||||
const data = await this.adminService.getUsers({
|
||||
page,
|
||||
limit,
|
||||
search,
|
||||
role,
|
||||
});
|
||||
return { success: true, ...data };
|
||||
}
|
||||
|
||||
@@ -44,7 +72,7 @@ export class AdminController {
|
||||
const user = await this.adminService.updateUserRole(id, role);
|
||||
return {
|
||||
success: true,
|
||||
data: user
|
||||
data: user,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,14 +82,23 @@ export class AdminController {
|
||||
@ApiQuery({ name: 'page', required: false, description: 'شماره صفحه' })
|
||||
@ApiQuery({ name: 'limit', required: false, description: 'تعداد آیتمها' })
|
||||
@ApiQuery({ name: 'search', required: false, description: 'جستجو' })
|
||||
@ApiQuery({ name: 'categoryId', required: false, description: 'شناسه دستهبندی' })
|
||||
@ApiQuery({
|
||||
name: 'categoryId',
|
||||
required: false,
|
||||
description: 'شناسه دستهبندی',
|
||||
})
|
||||
async getProducts(
|
||||
@Query('page') page?: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query('search') search?: string,
|
||||
@Query('categoryId') categoryId?: string
|
||||
@Query('categoryId') categoryId?: string,
|
||||
) {
|
||||
const data = await this.adminService.getProducts({ page, limit, search, categoryId });
|
||||
const data = await this.adminService.getProducts({
|
||||
page,
|
||||
limit,
|
||||
search,
|
||||
categoryId,
|
||||
});
|
||||
return { success: true, ...data };
|
||||
}
|
||||
|
||||
@@ -80,7 +117,7 @@ export class AdminController {
|
||||
const product = await this.adminService.updateProduct(id, data);
|
||||
return {
|
||||
success: true,
|
||||
data: product
|
||||
data: product,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,7 +128,7 @@ export class AdminController {
|
||||
await this.adminService.deleteProduct(id);
|
||||
return {
|
||||
success: true,
|
||||
message: 'Product deleted'
|
||||
message: 'Product deleted',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -106,9 +143,14 @@ export class AdminController {
|
||||
@Query('page') page?: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query('search') search?: string,
|
||||
@Query('status') status?: string
|
||||
@Query('status') status?: string,
|
||||
) {
|
||||
const data = await this.adminService.getOrders({ page, limit, search, status });
|
||||
const data = await this.adminService.getOrders({
|
||||
page,
|
||||
limit,
|
||||
search,
|
||||
status,
|
||||
});
|
||||
return { success: true, ...data };
|
||||
}
|
||||
|
||||
@@ -118,12 +160,16 @@ export class AdminController {
|
||||
async updateOrderStatus(
|
||||
@Param('id') id: string,
|
||||
@Body('status') status: string,
|
||||
@Body('trackingNumber') trackingNumber?: string
|
||||
@Body('trackingNumber') trackingNumber?: string,
|
||||
) {
|
||||
const order = await this.adminService.updateOrderStatus(id, status, trackingNumber);
|
||||
const order = await this.adminService.updateOrderStatus(
|
||||
id,
|
||||
status,
|
||||
trackingNumber,
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
data: order
|
||||
data: order,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,7 +204,10 @@ export class AdminController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('coupons/:id/toggle')
|
||||
@ApiOperation({ summary: 'فعال/غیرفعال کردن کد تخفیف' })
|
||||
async toggleCoupon(@Param('id') id: string, @Body('isActive') isActive: boolean) {
|
||||
async toggleCoupon(
|
||||
@Param('id') id: string,
|
||||
@Body('isActive') isActive: boolean,
|
||||
) {
|
||||
const coupon = await this.adminService.toggleCoupon(id, isActive);
|
||||
return { success: true, data: coupon };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user