7 changed files with 123 additions and 88 deletions
			
			
		| @ -0,0 +1,56 @@ | |||||
|  | '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, | ||||
|  | 
 | ||||
|  | } | ||||
| @ -0,0 +1,11 @@ | |||||
|  | 'use strict'; | ||||
|  | 
 | ||||
|  | const log = require('../../controllers/metadataAcquisition/log'); | ||||
|  | 
 | ||||
|  | module.exports = function (app, router, opts, AuthCode) { | ||||
|  | 
 | ||||
|  |     //获取采集任务列表
 | ||||
|  |     app.fs.api.logAttr['GET/meta/acq/logs'] = { content: '获取采集任务列表', visible: true }; | ||||
|  |     router.get('/meta/acq/logs', log.getAcquisitionTask(opts)); | ||||
|  | 
 | ||||
|  | }; | ||||
| @ -0,0 +1,16 @@ | |||||
|  | 'use strict'; | ||||
|  | 
 | ||||
|  | import { basicAction } from '@peace/utils' | ||||
|  | import { ApiTable } from '$utils' | ||||
|  | 
 | ||||
|  | export function getLogs(query) { | ||||
|  |     return dispatch => basicAction({ | ||||
|  |         type: 'get', | ||||
|  |         dispatch: dispatch, | ||||
|  |         query: query || {}, | ||||
|  |         actionType: 'GET_ACQ_LOGS', | ||||
|  |         url: `${ApiTable.getLogs}`, | ||||
|  |         msg: { error: '获取采集日志失败' }, | ||||
|  |         reducer: { name: 'acqlogs' } | ||||
|  |     }); | ||||
|  | } | ||||
					Loading…
					
					
				
		Reference in new issue