mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 增加线上数据保护
This commit is contained in:
parent
e10efbf4a3
commit
b83f6dbe0a
@ -54,10 +54,10 @@ class App extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取AppId,AppSecret,接口列表,应用接口权限细节
|
* 获取AppId,AppSecret,接口列表,应用接口权限细节
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
* @throws \think\exception\DbException
|
* @throws \think\exception\DbException
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function getAppInfo() {
|
public function getAppInfo() {
|
||||||
$apiArr = AdminList::all();
|
$apiArr = AdminList::all();
|
||||||
@ -81,8 +81,8 @@ class App extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新APPSecret
|
* 刷新APPSecret
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
|
||||||
* @return array
|
* @return array
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function refreshAppSecret() {
|
public function refreshAppSecret() {
|
||||||
$id = $this->request->get('id', 0);
|
$id = $this->request->get('id', 0);
|
||||||
@ -110,7 +110,7 @@ class App extends Base {
|
|||||||
'app_name' => $postData['app_name'],
|
'app_name' => $postData['app_name'],
|
||||||
'app_info' => $postData['app_info'],
|
'app_info' => $postData['app_info'],
|
||||||
'app_group' => $postData['app_group'],
|
'app_group' => $postData['app_group'],
|
||||||
'app_add_time' => time(),
|
'app_add_time' => time(),
|
||||||
'app_api' => '',
|
'app_api' => '',
|
||||||
'app_api_show' => '',
|
'app_api_show' => '',
|
||||||
];
|
];
|
||||||
@ -141,13 +141,15 @@ class App extends Base {
|
|||||||
$res = AdminApp::update([
|
$res = AdminApp::update([
|
||||||
'app_status' => $status
|
'app_status' => $status
|
||||||
], [
|
], [
|
||||||
'id' => $id
|
'id' => $id,
|
||||||
|
'is_official' => 0
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
$appInfo = AdminApp::get($id);
|
$appInfo = AdminApp::get($id);
|
||||||
cache('AccessToken:' . $appInfo['app_secret'], null);
|
cache('AccessToken:' . $appInfo['app_secret'], null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,12 +176,13 @@ class App extends Base {
|
|||||||
}
|
}
|
||||||
$data['app_api'] = implode(',', $appApi);
|
$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) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
$appInfo = AdminApp::get($postData['id']);
|
$appInfo = AdminApp::get($postData['id']);
|
||||||
cache('AccessToken:' . $appInfo['app_secret'], null);
|
cache('AccessToken:' . $appInfo['app_secret'], null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +200,7 @@ class App extends Base {
|
|||||||
$appInfo = AdminApp::get($id);
|
$appInfo = AdminApp::get($id);
|
||||||
cache('AccessToken:' . $appInfo['app_secret'], null);
|
cache('AccessToken:' . $appInfo['app_secret'], null);
|
||||||
|
|
||||||
AdminApp::destroy($id);
|
AdminApp::destroy(['id' => $id, 'is_official' => 0]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess([]);
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,17 @@ class AppGroup extends Base {
|
|||||||
public function changeStatus() {
|
public function changeStatus() {
|
||||||
$id = $this->request->get('id');
|
$id = $this->request->get('id');
|
||||||
$status = $this->request->get('status');
|
$status = $this->request->get('status');
|
||||||
$res = AdminAppGroup::update([
|
$res = AdminAppGroup::get($id);
|
||||||
'status' => $status
|
if ($res['is_official'] == 1) {
|
||||||
], [
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作');
|
||||||
'id' => $id
|
} else {
|
||||||
]);
|
$res = AdminAppGroup::update([
|
||||||
|
'status' => $status
|
||||||
|
], [
|
||||||
|
'id' => $id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
@ -106,7 +112,12 @@ class AppGroup extends Base {
|
|||||||
*/
|
*/
|
||||||
public function edit() {
|
public function edit() {
|
||||||
$postData = $this->request->post();
|
$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) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
@ -130,7 +141,7 @@ class AppGroup extends Base {
|
|||||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '当前分组存在' . $has . '个应用,禁止删除');
|
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '当前分组存在' . $has . '个应用,禁止删除');
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminAppGroup::destroy(['hash' => $hash]);
|
AdminAppGroup::destroy(['hash' => $hash, 'is_official' => 0]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess([]);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,10 @@ class Fields extends Base {
|
|||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
$postData = $this->request->post();
|
$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['show_name'] = $postData['field_name'];
|
||||||
$postData['default'] = $postData['defaults'];
|
$postData['default'] = $postData['defaults'];
|
||||||
unset($postData['defaults']);
|
unset($postData['defaults']);
|
||||||
@ -120,7 +124,13 @@ class Fields extends Base {
|
|||||||
$postData['show_name'] = $postData['field_name'];
|
$postData['show_name'] = $postData['field_name'];
|
||||||
$postData['default'] = $postData['defaults'];
|
$postData['default'] = $postData['defaults'];
|
||||||
unset($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:NewRule:' . $postData['hash'], null);
|
||||||
cache('RequestFields:Rule:' . $postData['hash'], null);
|
cache('RequestFields:Rule:' . $postData['hash'], null);
|
||||||
@ -146,6 +156,9 @@ class Fields extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fieldsInfo = AdminFields::get($id);
|
$fieldsInfo = AdminFields::get($id);
|
||||||
|
if ($fieldsInfo['is_official'] == 1) {
|
||||||
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '官方数据,禁止操作');
|
||||||
|
}
|
||||||
cache('RequestFields:NewRule:' . $fieldsInfo->hash, null);
|
cache('RequestFields:NewRule:' . $fieldsInfo->hash, null);
|
||||||
cache('RequestFields:Rule:' . $fieldsInfo->hash, null);
|
cache('RequestFields:Rule:' . $fieldsInfo->hash, null);
|
||||||
cache('ResponseFieldsRule:' . $fieldsInfo->hash, null);
|
cache('ResponseFieldsRule:' . $fieldsInfo->hash, null);
|
||||||
@ -172,6 +185,12 @@ class Fields extends Base {
|
|||||||
if ($data === null) {
|
if ($data === null) {
|
||||||
return $this->buildFailed(ReturnCode::EXCEPTION, 'JSON数据格式有误');
|
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]);
|
AdminList::update(['return_str' => json_encode($data)], ['hash' => $hash]);
|
||||||
$this->handle($data['data'], $dataArr);
|
$this->handle($data['data'], $dataArr);
|
||||||
$old = (new AdminFields())->where([
|
$old = (new AdminFields())->where([
|
||||||
|
@ -52,10 +52,10 @@ class InterfaceGroup extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部有效的接口组
|
* 获取全部有效的接口组
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
* @throws \think\exception\DbException
|
* @throws \think\exception\DbException
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function getAll() {
|
public function getAll() {
|
||||||
$listInfo = (new AdminGroup())->where(['status' => 1])->select();
|
$listInfo = (new AdminGroup())->where(['status' => 1])->select();
|
||||||
@ -76,7 +76,8 @@ class InterfaceGroup extends Base {
|
|||||||
$res = AdminGroup::update([
|
$res = AdminGroup::update([
|
||||||
'status' => $status
|
'status' => $status
|
||||||
], [
|
], [
|
||||||
'id' => $id
|
'id' => $id,
|
||||||
|
'is_official' => 0
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
@ -87,8 +88,8 @@ class InterfaceGroup extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加接口组
|
* 添加接口组
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
|
||||||
* @return array
|
* @return array
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
$postData = $this->request->post();
|
$postData = $this->request->post();
|
||||||
@ -102,12 +103,17 @@ class InterfaceGroup extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口组编辑
|
* 接口组编辑
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
|
||||||
* @return array
|
* @return array
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function edit() {
|
public function edit() {
|
||||||
$postData = $this->request->post();
|
$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) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
@ -130,6 +136,11 @@ class InterfaceGroup extends Base {
|
|||||||
return $this->buildFailed(ReturnCode::INVALID, '系统预留关键数据,禁止删除!');
|
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]);
|
AdminList::update(['group_hash' => 'default'], ['group_hash' => $hash]);
|
||||||
|
|
||||||
$hashRule = AdminApp::all([
|
$hashRule = AdminApp::all([
|
||||||
|
@ -95,7 +95,8 @@ class InterfaceList extends Base {
|
|||||||
$res = AdminList::update([
|
$res = AdminList::update([
|
||||||
'status' => $status
|
'status' => $status
|
||||||
], [
|
], [
|
||||||
'hash' => $hash
|
'hash' => $hash,
|
||||||
|
'is_official' => 0
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
@ -117,7 +118,12 @@ class InterfaceList extends Base {
|
|||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '真实类名只允许填写字母,数字和/');
|
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) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
||||||
} else {
|
} else {
|
||||||
@ -139,6 +145,11 @@ class InterfaceList extends Base {
|
|||||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
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([
|
$hashRule = AdminApp::all([
|
||||||
'app_api' => ['like', "%$hash%"]
|
'app_api' => ['like', "%$hash%"]
|
||||||
]);
|
]);
|
||||||
|
17
application/api/controller/Phone.php
Normal file
17
application/api/controller/Phone.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2019-07-16
|
||||||
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
|
||||||
|
class Phone extends Controller {
|
||||||
|
public function area() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user