瀏覽代碼

动态修改

wuyi 2 年之前
父節點
當前提交
e4ee79cefa
共有 2 個文件被更改,包括 10 次插入6 次删除
  1. 3 0
      src/chat-role/entities/chat-role.entity.ts
  2. 7 6
      src/moments/moments.service.ts

+ 3 - 0
src/chat-role/entities/chat-role.entity.ts

@@ -14,6 +14,9 @@ export class ChatRole {
     @Column()
     @Column()
     describe: string
     describe: string
 
 
+    @Column()
+    condition: string
+
     @Column()
     @Column()
     pic: String
     pic: String
 
 

+ 7 - 6
src/moments/moments.service.ts

@@ -38,7 +38,7 @@ export class MomentsService {
     ) {
     ) {
         setInterval(() => {
         setInterval(() => {
             this.automaticallySendMoments();
             this.automaticallySendMoments();
-        }, 60 * 60 * 1000);
+        }, 24 * 60 * 60 * 1000);
     }
     }
 
 
     async findAll(req: PageRequest<Moments>, userId: number): Promise<Pagination<Moments>> {
     async findAll(req: PageRequest<Moments>, userId: number): Promise<Pagination<Moments>> {
@@ -105,13 +105,14 @@ export class MomentsService {
     }
     }
 
 
     public async automaticallySendMoments() {
     public async automaticallySendMoments() {
-        const message = "请你发一条此时此刻的动态"
-        const maskList = await this.maskRepository.createQueryBuilder().getMany()
-        maskList.forEach(async mask => {
-            const text = await this.chatService.sendMessage(mask.describe, message)
+        const message = "请你以类似于朋友圈的放肆发一条此时此刻的动态"
+        const chatRoleList = await this.chatRoleRepository.createQueryBuilder().getMany()
+
+        chatRoleList.forEach(async role => {
+            const text = await this.chatService.sendMessage(role.condition, message)
             const momentsDto = new MomentsDto
             const momentsDto = new MomentsDto
             momentsDto.content = text
             momentsDto.content = text
-            momentsDto.userId = mask.id
+            momentsDto.userId = role.id
             await this.momentsRepository.save(momentsDto)
             await this.momentsRepository.save(momentsDto)
         })
         })