|
@ -1,17 +1,25 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
const moment = require("moment/moment"); |
|
|
const moment = require("moment"); |
|
|
|
|
|
const { getDataRange } = require('../auth/index') |
|
|
|
|
|
|
|
|
async function get(ctx) { |
|
|
async function get(ctx) { |
|
|
try { |
|
|
try { |
|
|
const { limit, page } = ctx.query; |
|
|
const { limit, page } = ctx.query; |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
let res = await models.DeptTraining.findAndCountAll({ |
|
|
const findObj = { |
|
|
where: {}, |
|
|
where: {}, |
|
|
offset: Number(page) * Number(limit), |
|
|
|
|
|
limit: Number(limit), |
|
|
|
|
|
order: [['id', 'ASC']] |
|
|
order: [['id', 'ASC']] |
|
|
}) |
|
|
}; |
|
|
|
|
|
let dataRange = await getDataRange(ctx); |
|
|
|
|
|
if (dataRange.departmentNames) { |
|
|
|
|
|
findObj.where.departmentName = { $in: dataRange.departmentNames || [] } |
|
|
|
|
|
} |
|
|
|
|
|
if (Number(limit) > 0 && Number(page) >= 0) { |
|
|
|
|
|
findObj.limit = Number(limit); |
|
|
|
|
|
findObj.offset = Number(page) * Number(limit); |
|
|
|
|
|
} |
|
|
|
|
|
let res = await models.DeptTraining.findAndCountAll(findObj) |
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.body = res; |
|
|
ctx.body = res; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|