simplify response of transaction records

This commit is contained in:
zhl 2023-02-08 09:59:41 +08:00
parent 5cb1322d80
commit a972435a8d
3 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ class RecordController extends BaseController {
let defaultParams: any = { account: user.id } let defaultParams: any = { account: user.id }
let { params } = req let { params } = req
Object.assign(params, defaultParams) Object.assign(params, defaultParams)
const records = await TranRecord.pageQuery(params) const records = await TranRecord.pageQuery(params, {json: 1})
return records return records
} }

View File

@ -83,7 +83,7 @@ export abstract class BaseModule extends FindOrCreate {
let records = await this.find(opt).sort(sort).skip(start).limit(limit) let records = await this.find(opt).sort(sort).skip(start).limit(limit)
let total = await this.countDocuments(opt) let total = await this.countDocuments(opt)
if (options?.json) { if (options?.json) {
records.map((o: T) => o.toJson()) records = records.map((o: T) => o.toJson())
} }
return { records, total, start, limit } return { records, total, start, limit }
} }

View File

@ -85,7 +85,7 @@ class TranRecordClass extends BaseModule {
status: this.status, status: this.status,
startTime: this.startTime, startTime: this.startTime,
confirmTime: this.confirmTime, confirmTime: this.confirmTime,
details: this.details.forEach(o => o.toJson()), details: this.details.map(o => o.toJson()),
} }
} }
} }