Browse Source

(*)部门培训记录数据范围控制

master
zmh 2 years ago
parent
commit
545f121149
  1. 18
      api/app/lib/controllers/departmentTrain/index.js

18
api/app/lib/controllers/departmentTrain/index.js

@ -1,17 +1,25 @@
'use strict';
const moment = require("moment/moment");
const moment = require("moment");
const { getDataRange } = require('../auth/index')
async function get(ctx) {
try {
const { limit, page } = ctx.query;
const models = ctx.fs.dc.models;
let res = await models.DeptTraining.findAndCountAll({
const findObj = {
where: {},
offset: Number(page) * Number(limit),
limit: Number(limit),
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.body = res;
} catch (error) {

Loading…
Cancel
Save