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,11 +1,32 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Req, HttpStatus, Query } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Patch,
|
||||
Param,
|
||||
Delete,
|
||||
UseGuards,
|
||||
Req,
|
||||
HttpStatus,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { PetsService } from './pets.service';
|
||||
import { CreatePetDto } from './dto/create-pet.dto';
|
||||
import { UpdatePetDto } from './dto/update-pet.dto';
|
||||
import { CreateReminderDto } from './dto/create-reminder.dto';
|
||||
import { CreateHealthLogDto } from './dto/create-health-log.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse, ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse, ApiNotFoundResponse } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiOkResponse,
|
||||
ApiCreatedResponse,
|
||||
ApiBadRequestResponse,
|
||||
ApiNotFoundResponse,
|
||||
} from '@nestjs/swagger';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
|
||||
@ApiTags('Pets - مدیریت حیوانات خانگی')
|
||||
@@ -20,9 +41,9 @@ import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
success: false,
|
||||
message: 'Unauthorized',
|
||||
code: 'UNAUTHORIZED',
|
||||
details: {}
|
||||
}
|
||||
}
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
export class PetsController {
|
||||
constructor(private readonly petsService: PetsService) {}
|
||||
@@ -42,9 +63,9 @@ export class PetsController {
|
||||
weight: '25.50',
|
||||
activityLevel: 'متوسط',
|
||||
imageUrl: null,
|
||||
createdAt: '2026-05-26T18:10:00.000Z'
|
||||
}
|
||||
}
|
||||
createdAt: '2026-05-26T18:10:00.000Z',
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiBadRequestResponse({
|
||||
description: 'خطا در صحتسنجی فیلدهای ورودی',
|
||||
@@ -53,9 +74,9 @@ export class PetsController {
|
||||
success: false,
|
||||
message: 'نوع حیوان خانگی اجباری است',
|
||||
code: 'BAD_REQUEST',
|
||||
details: {}
|
||||
}
|
||||
}
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
create(@Req() req: any, @Body() createPetDto: CreatePetDto) {
|
||||
return this.petsService.create(req.user.id, createPetDto);
|
||||
@@ -78,17 +99,17 @@ export class PetsController {
|
||||
weight: '25.50',
|
||||
activityLevel: 'متوسط',
|
||||
imageUrl: null,
|
||||
createdAt: '2026-05-26T18:10:00.000Z'
|
||||
}
|
||||
createdAt: '2026-05-26T18:10:00.000Z',
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
total: 1,
|
||||
page: 1,
|
||||
lastPage: 1,
|
||||
limit: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
limit: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
findAll(@Req() req: any, @Query() query: PaginationDto) {
|
||||
return this.petsService.findAllByUser(req.user.id, query);
|
||||
@@ -112,9 +133,9 @@ export class PetsController {
|
||||
medicalConditions: [],
|
||||
reminders: [],
|
||||
healthLogs: [],
|
||||
createdAt: '2026-05-26T18:10:00.000Z'
|
||||
}
|
||||
}
|
||||
createdAt: '2026-05-26T18:10:00.000Z',
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiNotFoundResponse({
|
||||
description: 'حیوان خانگی پیدا نشد یا متعلق به کاربر جاری نیست',
|
||||
@@ -123,9 +144,9 @@ export class PetsController {
|
||||
success: false,
|
||||
message: 'Pet not found or unauthorized',
|
||||
code: 'NOT_FOUND',
|
||||
details: {}
|
||||
}
|
||||
}
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
findOne(@Req() req: any, @Param('id') id: string) {
|
||||
return this.petsService.findOne(id, req.user.id);
|
||||
@@ -143,9 +164,9 @@ export class PetsController {
|
||||
breed: 'ژرمن شپرد',
|
||||
age: 4,
|
||||
weight: '26.00',
|
||||
activityLevel: 'زیاد'
|
||||
}
|
||||
}
|
||||
activityLevel: 'زیاد',
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiNotFoundResponse({
|
||||
description: 'حیوان خانگی یافت نشد',
|
||||
@@ -154,11 +175,15 @@ export class PetsController {
|
||||
success: false,
|
||||
message: 'Pet not found',
|
||||
code: 'NOT_FOUND',
|
||||
details: {}
|
||||
}
|
||||
}
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
update(@Req() req: any, @Param('id') id: string, @Body() updatePetDto: UpdatePetDto) {
|
||||
update(
|
||||
@Req() req: any,
|
||||
@Param('id') id: string,
|
||||
@Body() updatePetDto: UpdatePetDto,
|
||||
) {
|
||||
return this.petsService.update(id, req.user.id, updatePetDto);
|
||||
}
|
||||
|
||||
@@ -169,9 +194,9 @@ export class PetsController {
|
||||
schema: {
|
||||
example: {
|
||||
success: true,
|
||||
message: 'حیوان خانگی با موفقیت حذف شد'
|
||||
}
|
||||
}
|
||||
message: 'حیوان خانگی با موفقیت حذف شد',
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiNotFoundResponse({
|
||||
description: 'حیوان خانگی یافت نشد',
|
||||
@@ -180,9 +205,9 @@ export class PetsController {
|
||||
success: false,
|
||||
message: 'Pet not found',
|
||||
code: 'NOT_FOUND',
|
||||
details: {}
|
||||
}
|
||||
}
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
remove(@Req() req: any, @Param('id') id: string) {
|
||||
return this.petsService.remove(id, req.user.id);
|
||||
@@ -206,7 +231,12 @@ export class PetsController {
|
||||
@Param('reminderId') reminderId: string,
|
||||
@Body('date') date: string,
|
||||
) {
|
||||
return this.petsService.toggleReminder(req.user.id, petId, reminderId, date);
|
||||
return this.petsService.toggleReminder(
|
||||
req.user.id,
|
||||
petId,
|
||||
reminderId,
|
||||
date,
|
||||
);
|
||||
}
|
||||
|
||||
@Post(':petId/health-logs')
|
||||
@@ -216,6 +246,10 @@ export class PetsController {
|
||||
@Param('petId') petId: string,
|
||||
@Body() createHealthLogDto: CreateHealthLogDto,
|
||||
) {
|
||||
return this.petsService.addHealthLog(req.user.id, petId, createHealthLogDto);
|
||||
return this.petsService.addHealthLog(
|
||||
req.user.id,
|
||||
petId,
|
||||
createHealthLogDto,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user