|
|
@@ -4,6 +4,7 @@ import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
|
|
import OcrRecord from 'App/Models/OcrRecord'
|
|
|
import Drive from '@ioc:Adonis/Core/Drive'
|
|
|
import BlockchainWalletService from 'App/Services/BlockchainWalletService'
|
|
|
+import OcrDevice from 'App/Models/OcrDevice'
|
|
|
|
|
|
export default class OcrRecordController {
|
|
|
private paginationService = new PaginationService(OcrRecord)
|
|
|
@@ -33,6 +34,35 @@ export default class OcrRecordController {
|
|
|
return await OcrRecord.create(data)
|
|
|
}
|
|
|
|
|
|
+ public async updateContent({ request, response }: HttpContextContract) {
|
|
|
+ const data = await request.validate({
|
|
|
+ schema: schema.create({
|
|
|
+ id: schema.number(),
|
|
|
+ content: schema.string()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ const record = await OcrRecord.findBy('id', request.input('id'))
|
|
|
+ if (record) {
|
|
|
+ record.content = data.content
|
|
|
+ await record.save()
|
|
|
+ return response.ok(record)
|
|
|
+ } else {
|
|
|
+ return response.notFound({ message: 'Record not found' })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public async updateDetail({ params, response }: HttpContextContract) {
|
|
|
+ const record = await OcrRecord.findBy('id', params.id)
|
|
|
+ if (record) {
|
|
|
+ const walletAddresses = await BlockchainWalletService.getAllAddresses(record.content)
|
|
|
+ record.detail = JSON.stringify(walletAddresses)
|
|
|
+ await record.save()
|
|
|
+ return response.ok(record)
|
|
|
+ } else {
|
|
|
+ return response.notFound({ message: 'Record not found' })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public async getAllAddresses({ request }: HttpContextContract) {
|
|
|
await request.validate({
|
|
|
schema: schema.create({
|