'use strict'; async function getPersonalTrainRecordList(ctx) { try { const { models } = ctx.fs.dc; const { limit, page } = ctx.query; let personalTrainDetail = await models.PersonalTraining.findAndCountAll({ offset: Number(page) * Number(limit), limit: Number(limit), order: [['id', 'ASC']] }); ctx.status = 200 ctx.body = personalTrainDetail; } catch (error) { ctx.fs.logger.error(`path:${ctx.path},error:${error}`) ctx.status = 400; ctx.body = { name: 'FindError', message: '查询个人培训记录数据失败' } } } async function importPersonalTrainData(ctx) { let errorMsg = { message: '导入个人培训记录信息失败' }; const transaction = await ctx.fs.dc.orm.transaction(); try { const models = ctx.fs.dc.models; const data = ctx.request.body; await models.PersonalTraining.bulkCreate(data, { transaction }); await transaction.commit(); ctx.status = 204; } catch (error) { await transaction.rollback(); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = errorMsg; } } module.exports = { getPersonalTrainRecordList, importPersonalTrainData }