Commit c53b675c authored by huanle's avatar huanle

0529—

parent 5694ea23
......@@ -52,11 +52,17 @@ class Index extends Controller
} else {
$res = $model->addFolder($name, $parentid);
if ($res['code']>=0) {
if ($res['code']==0) {
return json(code([], 0, '添加成功'));
} else {
return json(code([], 10002, '添加失败'));
return json(code([$res['data']], 0, '添加成功'));
}
if ($res['code']==-200) {
return json(code([], 0, '文件名重复'));
}
if ($res['code']==-10002) {
return json(code([], 0, '添加失败'));
}
}
}
......
......@@ -75,13 +75,15 @@ class Folder extends Model
if ($parentid) {
$items = $this->where(['folderid' => $parentid])->setField('items', $childfolder_nums + 1);
if ($items) {
$return = $rs->folderid;
$folderid = $rs->folderid;
$return = ['code' => 0, 'msg' => '添加成功','data' =>$folderid];
} else {
throw new \Exception('添加失败');
}
} else {
$return = $rs->folderid;
$folderid = $rs->folderid;
$return = ['code' => 0, 'msg' => '添加成功','data' =>$folderid];
}
}
// 提交事务
......@@ -90,10 +92,12 @@ class Folder extends Model
// 回滚事务
Db::rollback();
$return = ['code' => -200, 'msg' => $e->getMessage()];
}
} else {
$return = ['code' => -10002, 'msg' => '文件名重复'];
}
return $return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment