'use strict' const request = require('superagent') const moment = require('moment') // function getFileCarImages (opts) { // return async function (ctx, next) { // let error = { message: '文件夹名称更新失败' } // const models = ctx.fs.dc.models // const { page, limit, } = ctx.query // try { // let searchWhere = {} // let option = { // where: searchWhere, // order: [["id", "desc"]], // } // option.where = searchWhere // let limit_ = limit || 10 // let page_ = page || 1 // let offset = (page_ - 1) * limit_ // if (limit && page) { // option.limit = limit_ // option.offset = offset // } // const res = await models.CarImages.findAndCount(option) // error = null // } catch (err) { // ctx.status = 500 // ctx.body = { detail: err, ...error } // } // if (error) { // ctx.status = 400 // ctx.body = { ...error } // } else { // ctx.status = 200 // ctx.body = { message: '文件夹名称更新成功' } // } // } // } function getFileCarImages (opts) { return async function (ctx, next) { const models = ctx.fs.dc.models const { page, limit, } = ctx.query const Op = ctx.fs.dc.ORM.Op let errMsg = { message: '获取图片失败' } try { let searchWhere = {} let option = { where: searchWhere, order: [["id", "ASC"]], } option.where = searchWhere let limit_ = limit || 10 let page_ = page || 1 let offset = (page_ - 1) * limit_ if (limit && page) { option.limit = limit_ option.offset = offset } const res = await models.CarImages.findAndCount(option) ctx.status = 200 ctx.body = res } catch (error) { ctx.status = 400 ctx.body = errMsg } } } module.exports = { getFileCarImages }