'use strict'; const Controller = require('egg').Controller; class HomeController extends Controller { async index() { const { ctx } = this; ctx.body = 'hi, homeEgg'; } // 获取地区(下一级地区) async findDept() { const { ctx } = this; const body = ctx.request.body; delete body.deptId; delete body.dept1; delete body.dept2; delete body.dept3; delete body.dept4; delete body.dept5; if (body.name) { body.name = { $regex: body.name }; } const result = await this.ctx.model.SysDeptModel.aggregate([ { $match: ctx.alterDeptId(body) }, { $project: { _id: 0, label: '$name', value: '$_id', }, }, ]); ctx.body = result; } } module.exports = HomeController;