Commit c53b675c authored by huanle's avatar huanle

0529—

parent 5694ea23
...@@ -52,11 +52,17 @@ class Index extends Controller ...@@ -52,11 +52,17 @@ class Index extends Controller
} else { } else {
$res = $model->addFolder($name, $parentid); $res = $model->addFolder($name, $parentid);
if ($res['code']>=0) { if ($res['code']==0) {
return json(code([], 0, '添加成功')); return json(code([$res['data']], 0, '添加成功'));
} else { }
return json(code([], 10002, '添加失败')); if ($res['code']==-200) {
return json(code([], 0, '文件名重复'));
}
if ($res['code']==-10002) {
return json(code([], 0, '添加失败'));
} }
} }
} }
......
...@@ -75,13 +75,15 @@ class Folder extends Model ...@@ -75,13 +75,15 @@ class Folder extends Model
if ($parentid) { if ($parentid) {
$items = $this->where(['folderid' => $parentid])->setField('items', $childfolder_nums + 1); $items = $this->where(['folderid' => $parentid])->setField('items', $childfolder_nums + 1);
if ($items) { if ($items) {
$return = $rs->folderid; $folderid = $rs->folderid;
$return = ['code' => 0, 'msg' => '添加成功','data' =>$folderid];
} else { } else {
throw new \Exception('添加失败'); throw new \Exception('添加失败');
} }
} else { } else {
$return = $rs->folderid; $folderid = $rs->folderid;
$return = ['code' => 0, 'msg' => '添加成功','data' =>$folderid];
} }
} }
// 提交事务 // 提交事务
...@@ -90,10 +92,12 @@ class Folder extends Model ...@@ -90,10 +92,12 @@ class Folder extends Model
// 回滚事务 // 回滚事务
Db::rollback(); Db::rollback();
$return = ['code' => -200, 'msg' => $e->getMessage()]; $return = ['code' => -200, 'msg' => $e->getMessage()];
} }
} else { } else {
$return = ['code' => -10002, 'msg' => '文件名重复']; $return = ['code' => -10002, 'msg' => '文件名重复'];
} }
return $return; 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