'use strict'; const moment = require('moment') async function inspection (ctx) { try { const models = ctx.fs.dc.models; const { projectAppId, screenshot = [] } = ctx.request.body const now = moment().format() const storageData = screenshot.map(s => { return { projectAppId, screenshot: [s], createTime: now, } }) await models.AppInspection.bulkCreate(storageData) ctx.status = 204; } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined } } } async function noted (ctx) { try { const models = ctx.fs.dc.models; const { inspectionId } = ctx.request.body const { userId } = ctx.fs.api await models.AppInspection.update({ notedPepUserId: userId, notedTime: moment().format() }, { where: { id: inspectionId } }) ctx.status = 204; } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined } } } module.exports = { inspection, noted, };