mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-05-24 22:09:41 +08:00
modified 修复App部分信息变更失败的BUG
This commit is contained in:
parent
18de280fc7
commit
f9c6a0613e
@ -94,6 +94,8 @@ class App extends Base {
|
||||
'app_secret' => $postData['app_secret'],
|
||||
'app_name' => $postData['app_name'],
|
||||
'app_info' => $postData['app_info'],
|
||||
'app_group' => $postData['app_group'],
|
||||
'app_addTime' => time(),
|
||||
'app_api' => '',
|
||||
'app_api_show' => '',
|
||||
];
|
||||
@ -141,11 +143,9 @@ class App extends Base {
|
||||
public function edit() {
|
||||
$postData = $this->request->post();
|
||||
$data = [
|
||||
'id' => $postData['id'],
|
||||
'app_id' => $postData['app_id'],
|
||||
'app_secret' => $postData['app_secret'],
|
||||
'app_name' => $postData['app_name'],
|
||||
'app_info' => $postData['app_info'],
|
||||
'app_group' => $postData['app_group'],
|
||||
'app_api' => '',
|
||||
'app_api_show' => '',
|
||||
];
|
||||
@ -157,7 +157,7 @@ class App extends Base {
|
||||
}
|
||||
$data['app_api'] = implode(',', $appApi);
|
||||
}
|
||||
$res = AdminApp::update($data);
|
||||
$res = AdminApp::update($data, ['id' => $postData['id']]);
|
||||
if ($res === false) {
|
||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||
} else {
|
||||
|
@ -8,6 +8,7 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\AdminApp;
|
||||
use app\model\AdminAppGroup;
|
||||
use app\util\ReturnCode;
|
||||
use app\util\Tools;
|
||||
@ -48,8 +49,8 @@ class AppGroup extends Base {
|
||||
$listInfo = Tools::buildArrFromObj($listInfo);
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo,
|
||||
'count' => $count
|
||||
'list' => $listInfo,
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ class AppGroup extends Base {
|
||||
$listInfo = (new AdminAppGroup())->where(['status' => 1])->select();
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo
|
||||
'list' => $listInfo
|
||||
]);
|
||||
}
|
||||
|
||||
@ -128,6 +129,12 @@ class AppGroup extends Base {
|
||||
if (!$hash) {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||
}
|
||||
|
||||
$has = (new AdminApp())->where(['app_group' => $hash])->count();
|
||||
if ($has) {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '当前分组存在' . $has . '个应用,禁止删除');
|
||||
}
|
||||
|
||||
AdminAppGroup::destroy(['hash' => $hash]);
|
||||
|
||||
return $this->buildSuccess([]);
|
||||
|
@ -8,7 +8,9 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\AdminApp;
|
||||
use app\model\AdminGroup;
|
||||
use app\model\AdminList;
|
||||
use app\util\ReturnCode;
|
||||
use app\util\Tools;
|
||||
|
||||
@ -48,8 +50,8 @@ class InterfaceGroup extends Base {
|
||||
$listInfo = Tools::buildArrFromObj($listInfo);
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo,
|
||||
'count' => $count
|
||||
'list' => $listInfo,
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
|
||||
@ -64,7 +66,7 @@ class InterfaceGroup extends Base {
|
||||
$listInfo = (new AdminGroup())->where(['status' => 1])->select();
|
||||
|
||||
return $this->buildSuccess([
|
||||
'list' => $listInfo
|
||||
'list' => $listInfo
|
||||
]);
|
||||
}
|
||||
|
||||
@ -122,14 +124,40 @@ class InterfaceGroup extends Base {
|
||||
|
||||
/**
|
||||
* 接口组删除
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return array
|
||||
* @throws \think\exception\DbException
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
public function del() {
|
||||
$hash = $this->request->get('hash');
|
||||
if (!$hash) {
|
||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||
}
|
||||
if ($hash === 'default') {
|
||||
return $this->buildFailed(ReturnCode::INVALID, '系统预留关键数据,禁止删除!');
|
||||
}
|
||||
|
||||
AdminList::update(['groupHash' => 'default'], ['groupHash' => $hash]);
|
||||
|
||||
$hashRule = AdminApp::all([
|
||||
'app_api_show' => ['like', "%$hash%"]
|
||||
]);
|
||||
if ($hashRule) {
|
||||
foreach ($hashRule as $rule) {
|
||||
$appApiShowArr = json_decode($rule->app_api_show, true);
|
||||
if (!empty($appApiShowArr[$hash])) {
|
||||
if (isset($appApiShowArr['default'])) {
|
||||
$appApiShowArr['default'] = array_merge($appApiShowArr['default'], $appApiShowArr[$hash]);
|
||||
} else {
|
||||
$appApiShowArr['default'] = $appApiShowArr[$hash];
|
||||
}
|
||||
}
|
||||
unset($appApiShowArr[$hash]);
|
||||
$rule->app_api_show = json_encode($appApiShowArr);
|
||||
$rule->save();
|
||||
}
|
||||
}
|
||||
|
||||
AdminGroup::destroy(['hash' => $hash]);
|
||||
|
||||
return $this->buildSuccess([]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user