|
|
@ -3,12 +3,14 @@ |
|
|
|
async function getPatrolPlan(ctx, next) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { limit, page } = ctx.query; |
|
|
|
const { limit, page, userId } = ctx.query; |
|
|
|
let userWhere = {}; |
|
|
|
let options = { |
|
|
|
include: [{ |
|
|
|
required: true, |
|
|
|
model: models.User, |
|
|
|
attributes: ['id', 'name'], |
|
|
|
where: userWhere, |
|
|
|
include: [{ |
|
|
|
required: true, |
|
|
|
model: models.Department, |
|
|
@ -26,6 +28,9 @@ async function getPatrolPlan(ctx, next) { |
|
|
|
if (page && limit) { |
|
|
|
options.offset = Number(page) * Number(limit); |
|
|
|
} |
|
|
|
if (userId) { |
|
|
|
userWhere.id = userId; |
|
|
|
} |
|
|
|
let res = await models.PatrolPlan.findAndCountAll(options); |
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = res; |
|
|
|