This commit is contained in:
pplokijuhyg 2019-12-02 16:36:45 +08:00
parent 2f5bae670d
commit d018bfc9c5

View File

@ -1,6 +1,6 @@
//添加分组 //添加分组
var groupadd = async (ctx, next) => { var groupadd = async (ctx, next) => {
await dbs.add("group", { groupname: ctx.query.groupname, fuid: ctx.query.fuid }) await dbs.add("group", { groupname: ctx.query.groupname, fuid: ctx.query.fuid == null ? '0' : ctx.query.fuid })
ctx.body = "添加成功" ctx.body = "添加成功"
} }
// 删除分组 // 删除分组
@ -10,7 +10,6 @@ var groupdel = async (ctx, next) => {
} }
// 获取分组 // 获取分组
var groupfind = async (ctx, next) => { var groupfind = async (ctx, next) => {
let group = []
await dbs.find("group").then((res) => { await dbs.find("group").then((res) => {
let tree = function (data) { let tree = function (data) {
let map = {}; let map = {};
@ -28,15 +27,16 @@ var groupfind = async (ctx, next) => {
} else { } else {
val.push(it); val.push(it);
} }
console.log(parent)
}) })
return val; return val;
} }
if(res.data.length == 0 ){
ctx.body="{code:0,data:[]}"
}else{
ctx.body = JSON.stringify(tree(res.data))
console.log(tree(res.data)) }
// console.log(JSON.stringify(group))
ctx.body = JSON.stringify(tree(data))
next() next()
}) })
} }