|
@@ -1,9 +1,11 @@
|
|
|
-import { BadRequestException, Body, Controller, Get, HttpStatus, Param, Post, Req } from "@nestjs/common";
|
|
|
|
|
|
|
+import { BadRequestException, Body, Controller, Get, HttpStatus, Param, Post, Put, Req } from "@nestjs/common";
|
|
|
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
|
|
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
|
|
|
import { MomentsService } from "./moments.service";
|
|
import { MomentsService } from "./moments.service";
|
|
|
import { PageRequest } from "../common/dto/page-request";
|
|
import { PageRequest } from "../common/dto/page-request";
|
|
|
import { Moments } from "./entities/moments.entity";
|
|
import { Moments } from "./entities/moments.entity";
|
|
|
import { LikesDto } from "src/likes/dto/likes.dto";
|
|
import { LikesDto } from "src/likes/dto/likes.dto";
|
|
|
|
|
+import { HasRoles } from "src/auth/roles.decorator";
|
|
|
|
|
+import { Role } from "src/model/role.enum";
|
|
|
|
|
|
|
|
@ApiTags('moments')
|
|
@ApiTags('moments')
|
|
|
@Controller('/moments')
|
|
@Controller('/moments')
|
|
@@ -20,7 +22,7 @@ export class MomentsController {
|
|
|
@Get('/get/:id')
|
|
@Get('/get/:id')
|
|
|
public async get(@Param('id') id: string, @Req() req) {
|
|
public async get(@Param('id') id: string, @Req() req) {
|
|
|
try {
|
|
try {
|
|
|
- return await this.momentsService.findById(Number(id),req.user.userId)
|
|
|
|
|
|
|
+ return await this.momentsService.findById(Number(id), req.user.userId)
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
throw new BadRequestException(err, 'Error: Moments not existent!')
|
|
throw new BadRequestException(err, 'Error: Moments not existent!')
|
|
|
}
|
|
}
|
|
@@ -39,4 +41,10 @@ export class MomentsController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Put('/creat')
|
|
|
|
|
+ @HasRoles(Role.Admin)
|
|
|
|
|
+ public async manualCreate() {
|
|
|
|
|
+ await this.momentsService.automaticallySendMoments()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|