feat: add admin tests read and update endpoints
This commit is contained in:
@@ -19,5 +19,5 @@ export class AdminLoginDTO extends PhoneDTO {
|
||||
field: '$t(auth.fields.password)',
|
||||
}),
|
||||
})
|
||||
password: string;
|
||||
password!: string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ POST http://localhost:3000/admin/auth/login
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"phone": "0933302636",
|
||||
"phone": "09333026363",
|
||||
"password": "Password1@"
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
import { Role } from '@/common/enums/roles.enum';
|
||||
import { Roles } from '@/modules/auth/decorators/roles.decorator';
|
||||
import { CreateTestDTO } from '@/modules/tests/dtos/create-test.dto';
|
||||
import { UpdateTestDTO } from '@/modules/tests/dtos/update-test.dto';
|
||||
import { TestsService } from '@/modules/tests/providers/tests.service';
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
|
||||
@Controller('admin/tests')
|
||||
@Roles(Role.SUPERUSER, Role.ADMIN)
|
||||
export class AdminTestsController {
|
||||
constructor(
|
||||
/**
|
||||
@@ -14,8 +24,25 @@ export class AdminTestsController {
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
@Roles(Role.SUPERUSER, Role.ADMIN)
|
||||
public async createTest(@Body() createTestDto: CreateTestDTO) {
|
||||
return await this.testsService.createOne(createTestDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
public async getAllTests() {
|
||||
return await this.testsService.adminGetAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
public async getTestById(@Param('id', ParseIntPipe) id: number) {
|
||||
return await this.testsService.adminGetOne(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
public async updateTestById(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() updateTestDto: UpdateTestDTO,
|
||||
) {
|
||||
return await this.testsService.updateOne(id, updateTestDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
GET http://localhost:3000/admin/tests
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwMzk4MzI0LCJleHAiOjE3ODA0MDE5MjQsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.s3NAErSAjMTz2s27obas3TEi5Og2HPeLgWCoIyzmzII
|
||||
|
||||
GET http://localhost:3000/admin/tests/4
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwMzk4MzI0LCJleHAiOjE3ODA0MDE5MjQsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.s3NAErSAjMTz2s27obas3TEi5Og2HPeLgWCoIyzmzII
|
||||
@@ -0,0 +1,8 @@
|
||||
PATCH http://localhost:3000/admin/tests/4
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwNDk0NDQ1LCJleHAiOjE3ODA0OTgwNDUsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.Sy-Er8DXzEUCD6Z-GZav0XKmpIqf0sXeBkUzjIf4Ypw
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"accessType": "login",
|
||||
"isActive": false
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
POST http://localhost:3000/admin/tests/
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwNDk0NDQ1LCJleHAiOjE3ODA0OTgwNDUsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.Sy-Er8DXzEUCD6Z-GZav0XKmpIqf0sXeBkUzjIf4Ypw
|
||||
|
||||
{
|
||||
"title": "Test Five",
|
||||
"description": "Description Five",
|
||||
"accessType": "login",
|
||||
"price": "1234000",
|
||||
"isActive": true
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
POST http://localhost:3000/admin/tests/
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwMjIzNDExLCJleHAiOjE3ODAyMjcwMTEsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.FNTIrk6FKO8P88yKnRCybZ6E5N3KlJaCHqZt5DMVgds
|
||||
|
||||
{
|
||||
"title": "Test Three",
|
||||
"description": "Description Three",
|
||||
"accessType": "free",
|
||||
"price": "1234000",
|
||||
"isActive": true
|
||||
}
|
||||
Reference in New Issue
Block a user