Browse Source

角色优化

wuyi 2 years ago
parent
commit
f609fabf5a
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/chat-role/chat-role.service.ts
  2. 1 1
      src/chat-role/dto/chat-role.dto.ts

+ 3 - 1
src/chat-role/chat-role.service.ts

@@ -59,7 +59,9 @@ export class ChatRoleService {
 
     public async create(chatRoleDto: ChatRoleDto) {
         const result = await this.chatRoleRepository.save(chatRoleDto)
-        this.labelService.addRoleLabel(result.id, chatRoleDto.labelList)
+        if (Array.isArray(chatRoleDto.labelList) && chatRoleDto.labelList.length > 0) {
+            this.labelService.addRoleLabel(result.id, chatRoleDto.labelList)
+        }
         return result;
     }
 

+ 1 - 1
src/chat-role/dto/chat-role.dto.ts

@@ -15,6 +15,6 @@ export class ChatRoleDto {
     dynamicNumber?: number = 0
 
     @IsArray()
-    labelList?: Label[]
+    labelList?: Label[] = []
 
 }