diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php index 10e8bef..1311687 100644 --- a/application/admin/controller/App.php +++ b/application/admin/controller/App.php @@ -54,10 +54,10 @@ class App extends Base { /** * 获取AppId,AppSecret,接口列表,应用接口权限细节 - * @author zhaoxiang * @return array * @throws \think\Exception * @throws \think\exception\DbException + * @author zhaoxiang */ public function getAppInfo() { $apiArr = AdminList::all(); @@ -81,8 +81,8 @@ class App extends Base { /** * 刷新APPSecret - * @author zhaoxiang * @return array + * @author zhaoxiang */ public function refreshAppSecret() { $id = $this->request->get('id', 0); @@ -110,7 +110,7 @@ class App extends Base { 'app_name' => $postData['app_name'], 'app_info' => $postData['app_info'], 'app_group' => $postData['app_group'], - 'app_add_time' => time(), + 'app_add_time' => time(), 'app_api' => '', 'app_api_show' => '', ]; @@ -141,13 +141,15 @@ class App extends Base { $res = AdminApp::update([ 'app_status' => $status ], [ - 'id' => $id + 'id' => $id, + 'is_official' => 0 ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { $appInfo = AdminApp::get($id); cache('AccessToken:' . $appInfo['app_secret'], null); + return $this->buildSuccess([]); } } @@ -174,12 +176,13 @@ class App extends Base { } $data['app_api'] = implode(',', $appApi); } - $res = AdminApp::update($data, ['id' => $postData['id']]); + $res = AdminApp::update($data, ['id' => $postData['id'], 'is_official' => 0]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { $appInfo = AdminApp::get($postData['id']); cache('AccessToken:' . $appInfo['app_secret'], null); + return $this->buildSuccess([]); } } @@ -197,7 +200,7 @@ class App extends Base { $appInfo = AdminApp::get($id); cache('AccessToken:' . $appInfo['app_secret'], null); - AdminApp::destroy($id); + AdminApp::destroy(['id' => $id, 'is_official' => 0]); return $this->buildSuccess([]); } diff --git a/application/admin/controller/AppGroup.php b/application/admin/controller/AppGroup.php index 9e154d2..1949caa 100644 --- a/application/admin/controller/AppGroup.php +++ b/application/admin/controller/AppGroup.php @@ -72,11 +72,17 @@ class AppGroup extends Base { public function changeStatus() { $id = $this->request->get('id'); $status = $this->request->get('status'); - $res = AdminAppGroup::update([ - 'status' => $status - ], [ - 'id' => $id - ]); + $res = AdminAppGroup::get($id); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } else { + $res = AdminAppGroup::update([ + 'status' => $status + ], [ + 'id' => $id + ]); + } + if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -106,7 +112,12 @@ class AppGroup extends Base { */ public function edit() { $postData = $this->request->post(); - $res = AdminAppGroup::update($postData); + $res = AdminAppGroup::get($postData['id']); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } else { + AdminAppGroup::update($postData); + } if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -130,7 +141,7 @@ class AppGroup extends Base { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '当前分组存在' . $has . '个应用,禁止删除'); } - AdminAppGroup::destroy(['hash' => $hash]); + AdminAppGroup::destroy(['hash' => $hash, 'is_official' => 0]); return $this->buildSuccess([]); } diff --git a/application/admin/controller/Fields.php b/application/admin/controller/Fields.php index 70c22cb..8f8a777 100644 --- a/application/admin/controller/Fields.php +++ b/application/admin/controller/Fields.php @@ -94,6 +94,10 @@ class Fields extends Base { */ public function add() { $postData = $this->request->post(); + $res = AdminList::get(['hash' => $postData['hash']]); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } $postData['show_name'] = $postData['field_name']; $postData['default'] = $postData['defaults']; unset($postData['defaults']); @@ -120,7 +124,13 @@ class Fields extends Base { $postData['show_name'] = $postData['field_name']; $postData['default'] = $postData['defaults']; unset($postData['defaults']); - $res = AdminFields::update($postData); + + $res = AdminFields::get($postData['id']); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } else { + $res = AdminFields::update($postData); + } cache('RequestFields:NewRule:' . $postData['hash'], null); cache('RequestFields:Rule:' . $postData['hash'], null); @@ -146,6 +156,9 @@ class Fields extends Base { } $fieldsInfo = AdminFields::get($id); + if ($fieldsInfo['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } cache('RequestFields:NewRule:' . $fieldsInfo->hash, null); cache('RequestFields:Rule:' . $fieldsInfo->hash, null); cache('ResponseFieldsRule:' . $fieldsInfo->hash, null); @@ -172,6 +185,12 @@ class Fields extends Base { if ($data === null) { return $this->buildFailed(ReturnCode::EXCEPTION, 'JSON数据格式有误'); } + + $fieldsInfo = AdminList::get(['hash' => $hash]); + if ($fieldsInfo['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } + AdminList::update(['return_str' => json_encode($data)], ['hash' => $hash]); $this->handle($data['data'], $dataArr); $old = (new AdminFields())->where([ diff --git a/application/admin/controller/InterfaceGroup.php b/application/admin/controller/InterfaceGroup.php index bc14a08..717b7ae 100644 --- a/application/admin/controller/InterfaceGroup.php +++ b/application/admin/controller/InterfaceGroup.php @@ -52,10 +52,10 @@ class InterfaceGroup extends Base { /** * 获取全部有效的接口组 - * @author zhaoxiang * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @author zhaoxiang */ public function getAll() { $listInfo = (new AdminGroup())->where(['status' => 1])->select(); @@ -76,7 +76,8 @@ class InterfaceGroup extends Base { $res = AdminGroup::update([ 'status' => $status ], [ - 'id' => $id + 'id' => $id, + 'is_official' => 0 ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); @@ -87,8 +88,8 @@ class InterfaceGroup extends Base { /** * 添加接口组 - * @author zhaoxiang * @return array + * @author zhaoxiang */ public function add() { $postData = $this->request->post(); @@ -102,12 +103,17 @@ class InterfaceGroup extends Base { /** * 接口组编辑 - * @author zhaoxiang * @return array + * @author zhaoxiang */ public function edit() { $postData = $this->request->post(); - $res = AdminGroup::update($postData); + $res = AdminGroup::get($postData['id']); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } else { + $res = AdminGroup::update($postData); + } if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -130,6 +136,11 @@ class InterfaceGroup extends Base { return $this->buildFailed(ReturnCode::INVALID, '系统预留关键数据,禁止删除!'); } + $res = AdminGroup::get(['hash' => $hash]); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } + AdminList::update(['group_hash' => 'default'], ['group_hash' => $hash]); $hashRule = AdminApp::all([ diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 29901ba..82eff2e 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -95,7 +95,8 @@ class InterfaceList extends Base { $res = AdminList::update([ 'status' => $status ], [ - 'hash' => $hash + 'hash' => $hash, + 'is_official' => 0 ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); @@ -117,7 +118,12 @@ class InterfaceList extends Base { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '真实类名只允许填写字母,数字和/'); } - $res = AdminList::update($postData); + $res = AdminList::get($postData['id']); + if ($res['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } else { + AdminList::update($postData); + } if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -139,6 +145,11 @@ class InterfaceList extends Base { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + $api = AdminList::get(['hash' => $hash]); + if ($api['is_official'] == 1) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作'); + } + $hashRule = AdminApp::all([ 'app_api' => ['like', "%$hash%"] ]); diff --git a/application/api/controller/Phone.php b/application/api/controller/Phone.php new file mode 100644 index 0000000..8b210cc --- /dev/null +++ b/application/api/controller/Phone.php @@ -0,0 +1,17 @@ + + */ + +namespace app\api\controller; + + +use think\Controller; + +class Phone extends Controller { + public function area() { + + } +}