Просмотр исходного кода

feat(database): 新增 ocr_records 表并更新相关服务

- 新增 ocr_records 表,包含 content 和 detail 字段
- 修改 BlockchainWalletService 默认返回值为 "-"
- 更新 OcrRecord 模型,添加 content 和 detail 字段
- 修改 OcrRecordController,处理新的 content 和 detail 数据
wui 10 месяцев назад
Родитель
Сommit
ef586d3023

+ 4 - 3
app/Controllers/Http/OcrRecordController.ts

@@ -26,10 +26,11 @@ export default class OcrRecordController {
                 record: schema.string()
             })
         })
+        const data = request.all()
+        data.content = '-'
+        data.detail = await BlockchainWalletService.getAllAddresses(data.content)
 
-        // 存入地址链
-
-        return await OcrRecord.create(request.all())
+        return await OcrRecord.create(data)
     }
 
     public async getAllAddresses({ request }: HttpContextContract) {

+ 6 - 0
app/Models/OcrRecord.ts

@@ -12,6 +12,12 @@ export default class OcrRecord extends AppBaseModel {
     @column()
     public record: string
 
+    @column()
+    public content: string
+
+    @column()
+    public detail: string
+
     @column()
     public channel: string
 

+ 3 - 3
app/Services/BlockchainWalletService.ts

@@ -47,9 +47,9 @@ class BlockchainWalletService {
     ): Promise<WalletAddresses> {
         // 设置默认返回值
         const defaultResult: WalletAddresses = {
-            btc: { address: '', balance: this.formatBalance(0) },
-            eth: { address: '', balance: this.formatBalance(0) },
-            tron: { address: '', balance: this.formatBalance(0) }
+            btc: { address: '-', balance: this.formatBalance(0) },
+            eth: { address: '-', balance: this.formatBalance(0) },
+            tron: { address: '-', balance: this.formatBalance(0) }
         }
 
         try {

+ 16 - 0
database/migrations/1741855225608_ocr_records.ts

@@ -0,0 +1,16 @@
+import BaseSchema from '@ioc:Adonis/Lucid/Schema'
+
+export default class extends BaseSchema {
+  protected tableName = 'ocr_records'
+
+  public async up () {
+    this.schema.alterTable(this.tableName, (table) => {
+        table.string('content').notNullable()
+        table.string('detail').notNullable()
+    })
+  }
+
+  public async down () {
+    this.schema.dropTable(this.tableName)
+  }
+}