You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
'use strict';
|
|
|
|
function getAcquisitionTask(opts) {
|
|
return async function (ctx, next) {
|
|
|
|
const models = ctx.fs.dc.models;
|
|
const { page, limit, taskName } = ctx.query;
|
|
let errMsg = { message: '获取采集任务失败' }
|
|
const Op = ctx.fs.dc.ORM.Op;
|
|
try {
|
|
let searchWhere = {}
|
|
let option = {
|
|
where: searchWhere,
|
|
order: [["id", "desc"]],
|
|
include: [{
|
|
model: models.AcquisitionTask,
|
|
as: 'acquisitionTask',
|
|
include: [{
|
|
model: models.DataSource,
|
|
}]
|
|
}]
|
|
}
|
|
|
|
if (taskName) {
|
|
searchWhere.$or = [
|
|
{ '$acquisitionTask.task_name$': { $iLike: `%${taskName}%` } },
|
|
{ '$acquisitionTask.dataSource.name$': { $iLike: `%${taskName}%` } },
|
|
]
|
|
}
|
|
|
|
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.AcquisitionLog.findAndCount(option);
|
|
ctx.status = 200;
|
|
ctx.body = res;
|
|
} catch (error) {
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
ctx.status = 400;
|
|
ctx.body = errMsg
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
|
|
getAcquisitionTask,
|
|
|
|
}
|
|
|