wuyi 2 ani în urmă
părinte
comite
a8f0f2413b

+ 2 - 1
src/condition/condition.service.ts

@@ -41,9 +41,10 @@ export class ConditionService {
 
             const dto = new ConditionDto
             dto.userId = comment.userId
-            dto.favorability = fraction
+            dto.favorability = parseFloat(fraction)
             dto.chatRoleId = moments.userId
 
+
             const commentDto = new CommentDto
             commentDto.content = chat.message
             commentDto.userId = comment.userId

+ 4 - 2
src/condition/dto/condition.dto.ts

@@ -1,11 +1,13 @@
 import { IsNumber, IsString } from "class-validator";
 
 export class ConditionDto {
- 
+
     userId: number
 
     chatRoleId: number
 
-    favorability: string
+    favorability: number
+
+    score?: number
 
 }

+ 5 - 4
src/condition/entities/condition.entity.ts

@@ -1,4 +1,5 @@
 import { Exclude } from "class-transformer";
+import { DecimalTransformer } from "src/transformers/decimal.transformer";
 import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from "typeorm";
 
 @Entity()
@@ -13,10 +14,10 @@ export class Condition {
     @Column()
     chatRoleId: number
 
-    @Column()
-    favorability: string
+    @Column({ type: 'decimal', precision: 5, scale: 2, transformer: new DecimalTransformer() })
+    favorability: number
 
-    @Column()
-    score: string
+    @Column({ type: 'decimal', precision: 5, scale: 2, transformer: new DecimalTransformer() })
+    score: number
 
 }