wuyi il y a 2 ans
Parent
commit
10fd7441fa
2 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. 10 2
      src/moments/moments.controller.ts
  2. 1 1
      src/moments/moments.service.ts

+ 10 - 2
src/moments/moments.controller.ts

@@ -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 { MomentsService } from "./moments.service";
 import { PageRequest } from "../common/dto/page-request";
 import { Moments } from "./entities/moments.entity";
 import { LikesDto } from "src/likes/dto/likes.dto";
+import { HasRoles } from "src/auth/roles.decorator";
+import { Role } from "src/model/role.enum";
 
 @ApiTags('moments')
 @Controller('/moments')
@@ -20,7 +22,7 @@ export class MomentsController {
     @Get('/get/:id')
     public async get(@Param('id') id: string, @Req() req) {
         try {
-            return await this.momentsService.findById(Number(id),req.user.userId)
+            return await this.momentsService.findById(Number(id), req.user.userId)
         } catch (err) {
             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()
+    }
+
 }

+ 1 - 1
src/moments/moments.service.ts

@@ -105,7 +105,7 @@ export class MomentsService {
     }
 
     public async automaticallySendMoments() {
-        const message = "请你以类似于朋友圈的放肆发一条此时此刻的动态"
+        const message = "我需要你以类似于朋友圈的方式发一条此时此刻的动态,尽量符合角色性格."
         const chatRoleList = await this.chatRoleRepository.createQueryBuilder().getMany()
 
         chatRoleList.forEach(async role => {