Edit D:\xinhaisoft\crisis_new\api\controllers\department.js
// ?????? const util = require('../utils') const db = require('../data') let [sql, rs] = ['', null] /** * ??????????????????????? * get: /department/allchildren */ exports.AllChildren = async ctx => { const id = ctx.query.id const client = ctx.query.c if (!util.isInteger(id)) { ctx.body = { code: -2 } } else { const parent = await db.select('select top 1 path,name from member_type where id=' + id) if (parent === null) { ctx.body = { code: 1, message: '?????' + id + '??????' } } else { if (client === 'ztree') { sql = `select id,parid as pId,name from member_type as a where path like '${parent.path},%' order by sort,id` rs = await db.select(sql) rs.forEach(item => rs.some(el => el.pId === item.id) && (item.isParent = 1)) rs.unshift({ id: Number(id), pId: 0, name: parent.name, isParent: 1, open: 1 }) } else { sql = `select id,parid,name from member_type where path like '${parent.path},%' order by sort,id` rs = await db.select(sql) rs.unshift({ id: Number(id), parid: 0, name: parent.name }) } ctx.body = { code: 0, data: rs } } } }
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de