modified 变更目前所有表前缀,为了以后功能做铺垫

This commit is contained in:
zhaoxiang 2018-03-04 23:13:11 +08:00
parent 147067f70b
commit bd75c23c30
29 changed files with 166 additions and 166 deletions

View File

@ -8,8 +8,8 @@
namespace app\admin\behavior; namespace app\admin\behavior;
use app\model\ApiMenu; use app\model\AdminMenu;
use app\model\ApiUserAction; use app\model\AdminUserAction;
use app\util\ReturnCode; use app\util\ReturnCode;
use think\Request; use think\Request;
@ -29,7 +29,7 @@ class AdminLog {
$userToken = $request->header('ApiAuth', ''); $userToken = $request->header('ApiAuth', '');
$userInfo = cache($userToken); $userInfo = cache($userToken);
$userInfo = json_decode($userInfo, true); $userInfo = json_decode($userInfo, true);
$menuInfo = ApiMenu::get(['url' => $route['route']]); $menuInfo = AdminMenu::get(['url' => $route['route']]);
if ($menuInfo) { if ($menuInfo) {
$menuInfo = $menuInfo->toArray(); $menuInfo = $menuInfo->toArray();
@ -39,7 +39,7 @@ class AdminLog {
return json($data, 200, $header); return json($data, 200, $header);
} }
ApiUserAction::create([ AdminUserAction::create([
'actionName' => $menuInfo['name'], 'actionName' => $menuInfo['name'],
'uid' => $userInfo['id'], 'uid' => $userInfo['id'],
'nickname' => $userInfo['nickname'], 'nickname' => $userInfo['nickname'],

View File

@ -8,9 +8,9 @@
namespace app\admin\behavior; namespace app\admin\behavior;
use app\model\ApiAuthGroup; use app\model\AdminAuthGroup;
use app\model\ApiAuthGroupAccess; use app\model\AdminAuthGroupAccess;
use app\model\ApiAuthRule; use app\model\AdminAuthRule;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
use think\Request; use think\Request;
@ -71,15 +71,15 @@ class ApiPermission {
* @author zhaoxiang <zhaoxiang051405@gmail.com> * @author zhaoxiang <zhaoxiang051405@gmail.com>
*/ */
private function getAuth($uid) { private function getAuth($uid) {
$groups = ApiAuthGroupAccess::get(['uid' => $uid]); $groups = AdminAuthGroupAccess::get(['uid' => $uid]);
if (isset($groups) && $groups->groupId) { if (isset($groups) && $groups->groupId) {
$openGroup = (new ApiAuthGroup())->whereIn('id', $groups->groupId)->where(['status' => 1])->select(); $openGroup = (new AdminAuthGroup())->whereIn('id', $groups->groupId)->where(['status' => 1])->select();
if (isset($openGroup)) { if (isset($openGroup)) {
$openGroupArr = []; $openGroupArr = [];
foreach ($openGroup as $group) { foreach ($openGroup as $group) {
$openGroupArr[] = $group->id; $openGroupArr[] = $group->id;
} }
$allRules = (new ApiAuthRule())->whereIn('groupId', $openGroupArr)->select(); $allRules = (new AdminAuthRule())->whereIn('groupId', $openGroupArr)->select();
if (isset($allRules)) { if (isset($allRules)) {
$rules = []; $rules = [];
foreach ($allRules as $rule) { foreach ($allRules as $rule) {

View File

@ -8,9 +8,9 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiApp; use app\model\AdminApp;
use app\model\ApiList; use app\model\AdminList;
use app\model\ApiGroup; use app\model\AdminGroup;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Strs; use app\util\Strs;
use app\util\Tools; use app\util\Tools;
@ -45,8 +45,8 @@ class App extends Base {
} }
} }
$listInfo = (new ApiApp())->where($where)->order('app_addTime', 'DESC')->limit($start, $limit)->select(); $listInfo = (new AdminApp())->where($where)->order('app_addTime', 'DESC')->limit($start, $limit)->select();
$count = (new ApiApp())->where($where)->count(); $count = (new AdminApp())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -63,16 +63,16 @@ class App extends Base {
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAppInfo() { public function getAppInfo() {
$apiArr = ApiList::all(); $apiArr = AdminList::all();
foreach ($apiArr as $api) { foreach ($apiArr as $api) {
$res['apiList'][$api['groupHash']][] = $api; $res['apiList'][$api['groupHash']][] = $api;
} }
$groupArr = ApiGroup::all(); $groupArr = AdminGroup::all();
$groupArr = Tools::buildArrFromObj($groupArr); $groupArr = Tools::buildArrFromObj($groupArr);
$res['groupInfo'] = array_column($groupArr, 'name', 'hash'); $res['groupInfo'] = array_column($groupArr, 'name', 'hash');
$id = $this->request->get('id', 0); $id = $this->request->get('id', 0);
if ($id) { if ($id) {
$appInfo = ApiApp::get($id)->toArray(); $appInfo = AdminApp::get($id)->toArray();
$res['app_detail'] = json_decode($appInfo['app_api_show'], true); $res['app_detail'] = json_decode($appInfo['app_api_show'], true);
} else { } else {
$res['app_id'] = mt_rand(1, 9) . Strs::randString(7, 1); $res['app_id'] = mt_rand(1, 9) . Strs::randString(7, 1);
@ -105,7 +105,7 @@ class App extends Base {
} }
$data['app_api'] = implode(',', $appApi); $data['app_api'] = implode(',', $appApi);
} }
$res = ApiApp::create($data); $res = AdminApp::create($data);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -121,7 +121,7 @@ class App 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 = ApiApp::update([ $res = AdminApp::update([
'app_status' => $status 'app_status' => $status
], [ ], [
'id' => $id 'id' => $id
@ -157,7 +157,7 @@ class App extends Base {
} }
$data['app_api'] = implode(',', $appApi); $data['app_api'] = implode(',', $appApi);
} }
$res = ApiApp::update($data); $res = AdminApp::update($data);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -175,7 +175,7 @@ class App extends Base {
if (!$id) { if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiApp::destroy($id); AdminApp::destroy($id);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }

View File

@ -8,7 +8,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiAppGroup; use app\model\AdminAppGroup;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -43,8 +43,8 @@ class AppGroup extends Base {
} }
} }
$listInfo = (new ApiAppGroup())->where($where)->limit($start, $limit)->select(); $listInfo = (new AdminAppGroup())->where($where)->limit($start, $limit)->select();
$count = (new ApiAppGroup())->where($where)->count(); $count = (new AdminAppGroup())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -61,7 +61,7 @@ class AppGroup extends Base {
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAll() { public function getAll() {
$listInfo = (new ApiAppGroup())->where(['status' => 1])->select(); $listInfo = (new AdminAppGroup())->where(['status' => 1])->select();
return $this->buildSuccess([ return $this->buildSuccess([
'list' => $listInfo 'list' => $listInfo
@ -76,7 +76,7 @@ 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 = ApiAppGroup::update([ $res = AdminAppGroup::update([
'status' => $status 'status' => $status
], [ ], [
'id' => $id 'id' => $id
@ -95,7 +95,7 @@ class AppGroup extends Base {
*/ */
public function add() { public function add() {
$postData = $this->request->post(); $postData = $this->request->post();
$res = ApiAppGroup::create($postData); $res = AdminAppGroup::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -110,7 +110,7 @@ class AppGroup extends Base {
*/ */
public function edit() { public function edit() {
$postData = $this->request->post(); $postData = $this->request->post();
$res = ApiAppGroup::update($postData); $res = 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 {
@ -128,7 +128,7 @@ class AppGroup extends Base {
if (!$hash) { if (!$hash) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiAppGroup::destroy(['hash' => $hash]); AdminAppGroup::destroy(['hash' => $hash]);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }

View File

@ -8,10 +8,10 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiAuthGroup; use app\model\AdminAuthGroup;
use app\model\ApiAuthGroupAccess; use app\model\AdminAuthGroupAccess;
use app\model\ApiAuthRule; use app\model\AdminAuthRule;
use app\model\ApiMenu; use app\model\AdminMenu;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -37,8 +37,8 @@ class Auth extends Base {
$where['status'] = $status; $where['status'] = $status;
} }
$listInfo = (new ApiAuthGroup())->where($where)->order('id', 'DESC')->limit($start, $limit)->select(); $listInfo = (new AdminAuthGroup())->where($where)->order('id', 'DESC')->limit($start, $limit)->select();
$count = (new ApiAuthGroup())->where($where)->count(); $count = (new AdminAuthGroup())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -56,7 +56,7 @@ class Auth extends Base {
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getGroups() { public function getGroups() {
$listInfo = (new ApiAuthGroup())->where(['status' => 1])->order('id', 'DESC')->select(); $listInfo = (new AdminAuthGroup())->where(['status' => 1])->order('id', 'DESC')->select();
$count = count($listInfo); $count = count($listInfo);
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
@ -77,13 +77,13 @@ class Auth extends Base {
public function getRuleList() { public function getRuleList() {
$groupId = $this->request->get('groupId', 0); $groupId = $this->request->get('groupId', 0);
$list = (new ApiMenu)->where([])->order('sort', 'ASC')->select(); $list = (new AdminMenu)->where([])->order('sort', 'ASC')->select();
$list = Tools::buildArrFromObj($list); $list = Tools::buildArrFromObj($list);
$list = listToTree($list); $list = listToTree($list);
$rules = []; $rules = [];
if ($groupId) { if ($groupId) {
$rules = (new ApiAuthRule())->where(['groupId' => $groupId])->select(); $rules = (new AdminAuthRule())->where(['groupId' => $groupId])->select();
$rules = array_column($rules, 'url'); $rules = array_column($rules, 'url');
} }
$newList = $this->buildList($list, $rules); $newList = $this->buildList($list, $rules);
@ -107,7 +107,7 @@ class Auth extends Base {
$rules = array_filter($rules); $rules = array_filter($rules);
} }
unset($postData['rules']); unset($postData['rules']);
$res = ApiAuthGroup::create($postData); $res = AdminAuthGroup::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -121,7 +121,7 @@ class Auth extends Base {
]; ];
} }
} }
(new ApiAuthRule())->saveAll($insertData); (new AdminAuthRule())->saveAll($insertData);
} }
return $this->buildSuccess([]); return $this->buildSuccess([]);
@ -136,7 +136,7 @@ class Auth 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 = ApiAuthGroup::update([ $res = AdminAuthGroup::update([
'id' => $id, 'id' => $id,
'status' => $status 'status' => $status
]); ]);
@ -162,7 +162,7 @@ class Auth extends Base {
$this->editRule(); $this->editRule();
} }
unset($postData['rules']); unset($postData['rules']);
$res = ApiAuthGroup::update($postData); $res = AdminAuthGroup::update($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -184,7 +184,7 @@ class Auth extends Base {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
$listInfo = (new ApiAuthGroupAccess())->where(['groupId' => ['like', "%{$id}%"]])->select(); $listInfo = (new AdminAuthGroupAccess())->where(['groupId' => ['like', "%{$id}%"]])->select();
if ($listInfo) { if ($listInfo) {
foreach ($listInfo as $value) { foreach ($listInfo as $value) {
$valueArr = $value->toArray(); $valueArr = $value->toArray();
@ -197,8 +197,8 @@ class Auth extends Base {
} }
} }
ApiAuthGroup::destroy($id); AdminAuthGroup::destroy($id);
ApiAuthRule::destroy(['groupId' => $id]); AdminAuthRule::destroy(['groupId' => $id]);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }
@ -216,12 +216,12 @@ class Auth extends Base {
if (!$gid || !$uid) { if (!$gid || !$uid) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
$oldInfo = ApiAuthGroupAccess::get(['uid' => $uid])->toArray(); $oldInfo = AdminAuthGroupAccess::get(['uid' => $uid])->toArray();
$oldGroupArr = explode(',', $oldInfo['groupId']); $oldGroupArr = explode(',', $oldInfo['groupId']);
$key = array_search($gid, $oldGroupArr); $key = array_search($gid, $oldGroupArr);
unset($oldGroupArr[$key]); unset($oldGroupArr[$key]);
$newData = implode(',', $oldGroupArr); $newData = implode(',', $oldGroupArr);
$res = ApiAuthGroupAccess::update([ $res = AdminAuthGroupAccess::update([
'groupId' => $newData 'groupId' => $newData
], [ ], [
'uid' => $uid 'uid' => $uid
@ -269,7 +269,7 @@ class Auth extends Base {
private function editRule() { private function editRule() {
$postData = $this->request->post(); $postData = $this->request->post();
$needAdd = []; $needAdd = [];
$has = (new ApiAuthRule())->where(['groupId' => $postData['id']])->select(); $has = (new AdminAuthRule())->where(['groupId' => $postData['id']])->select();
$has = Tools::buildArrFromObj($has); $has = Tools::buildArrFromObj($has);
$hasRule = array_column($has, 'url'); $hasRule = array_column($has, 'url');
$needDel = array_flip($hasRule); $needDel = array_flip($hasRule);
@ -285,11 +285,11 @@ class Auth extends Base {
} }
} }
if (count($needAdd)) { if (count($needAdd)) {
(new ApiAuthRule())->saveAll($needAdd); (new AdminAuthRule())->saveAll($needAdd);
} }
if (count($needDel)) { if (count($needDel)) {
$urlArr = array_keys($needDel); $urlArr = array_keys($needDel);
ApiAuthRule::destroy([ AdminAuthRule::destroy([
'groupId' => $postData['id'], 'groupId' => $postData['id'],
'url' => ['in', $urlArr] 'url' => ['in', $urlArr]
]); ]);

View File

@ -8,8 +8,8 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiFields; use app\model\AdminFields;
use app\model\ApiList; use app\model\AdminList;
use app\util\DataType; use app\util\DataType;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -44,8 +44,8 @@ class Fields extends Base {
$hash = $this->request->get('hash', ''); $hash = $this->request->get('hash', '');
if (!empty($hash)) { if (!empty($hash)) {
$listInfo = (new ApiFields())->where(['hash' => $hash, 'type' => 0])->limit($start, $limit)->select(); $listInfo = (new AdminFields())->where(['hash' => $hash, 'type' => 0])->limit($start, $limit)->select();
$count = (new ApiFields())->where(['hash' => $hash, 'type' => 0])->count(); $count = (new AdminFields())->where(['hash' => $hash, 'type' => 0])->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -72,8 +72,8 @@ class Fields extends Base {
$hash = $this->request->get('hash', ''); $hash = $this->request->get('hash', '');
if (!empty($hash)) { if (!empty($hash)) {
$listInfo = (new ApiFields())->where(['hash' => $hash, 'type' => 1])->limit($start, $limit)->select(); $listInfo = (new AdminFields())->where(['hash' => $hash, 'type' => 1])->limit($start, $limit)->select();
$count = (new ApiFields())->where(['hash' => $hash, 'type' => 1])->count(); $count = (new AdminFields())->where(['hash' => $hash, 'type' => 1])->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -96,7 +96,7 @@ class Fields extends Base {
$postData['showName'] = $postData['fieldName']; $postData['showName'] = $postData['fieldName'];
$postData['default'] = $postData['defaults']; $postData['default'] = $postData['defaults'];
unset($postData['defaults']); unset($postData['defaults']);
$res = ApiFields::create($postData); $res = AdminFields::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -114,7 +114,7 @@ class Fields extends Base {
$postData['showName'] = $postData['fieldName']; $postData['showName'] = $postData['fieldName'];
$postData['default'] = $postData['defaults']; $postData['default'] = $postData['defaults'];
unset($postData['defaults']); unset($postData['defaults']);
$res = ApiFields::update($postData); $res = AdminFields::update($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -132,7 +132,7 @@ class Fields extends Base {
if (!$id) { if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiFields::destroy($id); AdminFields::destroy($id);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }
@ -154,9 +154,9 @@ class Fields extends Base {
if ($data === null) { if ($data === null) {
return $this->buildFailed(ReturnCode::EXCEPTION, 'JSON数据格式有误'); return $this->buildFailed(ReturnCode::EXCEPTION, 'JSON数据格式有误');
} }
ApiList::update(['returnStr' => json_encode($data)], ['hash' => $hash]); AdminList::update(['returnStr' => json_encode($data)], ['hash' => $hash]);
$this->handle($data['data'], $dataArr); $this->handle($data['data'], $dataArr);
$old = (new ApiFields())->where([ $old = (new AdminFields())->where([
'hash' => $hash, 'hash' => $hash,
'type' => $type 'type' => $type
])->select(); ])->select();
@ -166,7 +166,7 @@ class Fields extends Base {
$addArr = array_diff($newArr, $oldArr); $addArr = array_diff($newArr, $oldArr);
$delArr = array_diff($oldArr, $newArr); $delArr = array_diff($oldArr, $newArr);
if ($delArr) { if ($delArr) {
ApiFields::destroy(['showName' => ['in', $delArr]]); AdminFields::destroy(['showName' => ['in', $delArr]]);
} }
if ($addArr) { if ($addArr) {
$addData = []; $addData = [];
@ -175,7 +175,7 @@ class Fields extends Base {
$addData[] = $item; $addData[] = $item;
} }
} }
(new ApiFields())->insertAll($addData); (new AdminFields())->insertAll($addData);
} }
return $this->buildSuccess([]); return $this->buildSuccess([]);

View File

@ -8,7 +8,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiGroup; use app\model\AdminGroup;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -43,8 +43,8 @@ class InterfaceGroup extends Base {
} }
} }
$listInfo = (new ApiGroup())->where($where)->limit($start, $limit)->select(); $listInfo = (new AdminGroup())->where($where)->limit($start, $limit)->select();
$count = (new ApiGroup())->where($where)->count(); $count = (new AdminGroup())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -61,7 +61,7 @@ class InterfaceGroup extends Base {
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAll() { public function getAll() {
$listInfo = (new ApiGroup())->where(['status' => 1])->select(); $listInfo = (new AdminGroup())->where(['status' => 1])->select();
return $this->buildSuccess([ return $this->buildSuccess([
'list' => $listInfo 'list' => $listInfo
@ -76,7 +76,7 @@ class InterfaceGroup 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 = ApiGroup::update([ $res = AdminGroup::update([
'status' => $status 'status' => $status
], [ ], [
'id' => $id 'id' => $id
@ -96,7 +96,7 @@ class InterfaceGroup extends Base {
public function add() { public function add() {
$postData = $this->request->post(); $postData = $this->request->post();
$postData['addTime'] = $postData['updateTime'] = time(); $postData['addTime'] = $postData['updateTime'] = time();
$res = ApiGroup::create($postData); $res = AdminGroup::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -112,7 +112,7 @@ class InterfaceGroup extends Base {
public function edit() { public function edit() {
$postData = $this->request->post(); $postData = $this->request->post();
$postData['updateTime'] = time(); $postData['updateTime'] = time();
$res = ApiGroup::update($postData); $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,7 +130,7 @@ class InterfaceGroup extends Base {
if (!$hash) { if (!$hash) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiGroup::destroy(['hash' => $hash]); AdminGroup::destroy(['hash' => $hash]);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }

View File

@ -8,8 +8,8 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiFields; use app\model\AdminFields;
use app\model\ApiList; use app\model\AdminList;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -48,8 +48,8 @@ class InterfaceList extends Base {
} }
} }
$listInfo = (new ApiList())->where($where)->order('id', 'DESC')->limit($start, $limit)->select(); $listInfo = (new AdminList())->where($where)->order('id', 'DESC')->limit($start, $limit)->select();
$count = (new ApiList())->where($where)->count(); $count = (new AdminList())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -76,7 +76,7 @@ class InterfaceList extends Base {
*/ */
public function add() { public function add() {
$postData = $this->request->post(); $postData = $this->request->post();
$res = ApiList::create($postData); $res = AdminList::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -92,7 +92,7 @@ class InterfaceList 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 = ApiList::update([ $res = AdminList::update([
'status' => $status 'status' => $status
], [ ], [
'id' => $id 'id' => $id
@ -111,7 +111,7 @@ class InterfaceList extends Base {
*/ */
public function edit() { public function edit() {
$postData = $this->request->post(); $postData = $this->request->post();
$res = ApiList::update($postData); $res = 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 {
@ -129,8 +129,8 @@ class InterfaceList extends Base {
if (!$hash) { if (!$hash) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiList::destroy(['hash' => $hash]); AdminList::destroy(['hash' => $hash]);
ApiFields::destroy(['hash' => $hash]); AdminFields::destroy(['hash' => $hash]);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }
@ -147,7 +147,7 @@ class InterfaceList extends Base {
$methodArr = ['*','POST','GET']; $methodArr = ['*','POST','GET'];
$tplStr = file_get_contents($tplPath); $tplStr = file_get_contents($tplPath);
$listInfo = ApiList::all(['status' => 1]); $listInfo = AdminList::all(['status' => 1]);
foreach ($listInfo as $value) { foreach ($listInfo as $value) {
$tplStr .= 'Route::rule(\'api/'.$value->hash.'\',\'api/'.$value->apiClass.'\', \''.$methodArr[$value->method].'\', [\'after_behavior\' => $afterBehavior]);'; $tplStr .= 'Route::rule(\'api/'.$value->hash.'\',\'api/'.$value->apiClass.'\', \''.$methodArr[$value->method].'\', [\'after_behavior\' => $afterBehavior]);';
} }

View File

@ -8,10 +8,10 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiAuthGroupAccess; use app\model\AdminAuthGroupAccess;
use app\model\ApiUser; use app\model\AdminUser;
use app\model\ApiUserAction; use app\model\AdminUserAction;
use app\model\ApiUserData; use app\model\AdminUserData;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -47,8 +47,8 @@ class Log extends Base {
} }
} }
$listInfo = (new ApiUserAction())->where($where)->order('addTime', 'DESC')->limit($start, $limit)->select(); $listInfo = (new AdminUserAction())->where($where)->order('addTime', 'DESC')->limit($start, $limit)->select();
$count = (new ApiUserAction())->where($where)->count(); $count = (new AdminUserAction())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
return $this->buildSuccess([ return $this->buildSuccess([
@ -67,7 +67,7 @@ class Log extends Base {
if (!$id) { if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiUserAction::destroy($id); AdminUserAction::destroy($id);
return $this->buildSuccess([]); return $this->buildSuccess([]);

View File

@ -8,11 +8,11 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiAuthGroupAccess; use app\model\AdminAuthGroupAccess;
use app\model\ApiAuthRule; use app\model\AdminAuthRule;
use app\model\ApiMenu; use app\model\AdminMenu;
use app\model\ApiUser; use app\model\AdminUser;
use app\model\ApiUserData; use app\model\AdminUserData;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -36,11 +36,11 @@ class Login extends Base {
} else { } else {
$password = Tools::userMd5($password); $password = Tools::userMd5($password);
} }
$userInfo = ApiUser::get(['username' => $username, 'password' => $password]); $userInfo = AdminUser::get(['username' => $username, 'password' => $password]);
if (!empty($userInfo)) { if (!empty($userInfo)) {
if ($userInfo['status']) { if ($userInfo['status']) {
//更新用户数据 //更新用户数据
$userData = ApiUserData::get(['uid' => $userInfo['id']]); $userData = AdminUserData::get(['uid' => $userInfo['id']]);
$data = []; $data = [];
if ($userData) { if ($userData) {
$userData->loginTimes ++; $userData->loginTimes ++;
@ -55,7 +55,7 @@ class Login extends Base {
$data['lastLoginTime'] = time(); $data['lastLoginTime'] = time();
$data['headImg'] = ''; $data['headImg'] = '';
$return['headImg'] = ''; $return['headImg'] = '';
ApiUserData::create($data); AdminUserData::create($data);
} }
} else { } else {
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户已被封禁,请联系管理员'); return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户已被封禁,请联系管理员');
@ -70,13 +70,13 @@ class Login extends Base {
$return['access'] = 1000000; $return['access'] = 1000000;
$isSupper = Tools::isAdministrator($userInfo['id']); $isSupper = Tools::isAdministrator($userInfo['id']);
if ($isSupper) { if ($isSupper) {
$access = ApiMenu::all(['hide' => 0]); $access = AdminMenu::all(['hide' => 0]);
$access = Tools::buildArrFromObj($access); $access = Tools::buildArrFromObj($access);
$return['access'] = array_values(array_filter(array_column($access, 'url'))); $return['access'] = array_values(array_filter(array_column($access, 'url')));
} else { } else {
$groups = ApiAuthGroupAccess::get(['uid' => $userInfo['id']]); $groups = AdminAuthGroupAccess::get(['uid' => $userInfo['id']]);
if (isset($groups) || $groups->groupId) { if (isset($groups) || $groups->groupId) {
$access = (new ApiAuthRule())->whereIn('groupId', $groups->groupId)->select(); $access = (new AdminAuthRule())->whereIn('groupId', $groups->groupId)->select();
$access = Tools::buildArrFromObj($access); $access = Tools::buildArrFromObj($access);
$return['access'] = array_values(array_unique(array_column($access, 'url'))); $return['access'] = array_values(array_unique(array_column($access, 'url')));
} }

View File

@ -8,7 +8,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiMenu; use app\model\AdminMenu;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -21,7 +21,7 @@ class Menu extends Base {
* @author zhaoxiang <zhaoxiang051405@gmail.com> * @author zhaoxiang <zhaoxiang051405@gmail.com>
*/ */
public function index() { public function index() {
$list = (new ApiMenu)->where([])->order('sort', 'ASC')->select(); $list = (new AdminMenu)->where([])->order('sort', 'ASC')->select();
$list = Tools::buildArrFromObj($list); $list = Tools::buildArrFromObj($list);
$list = formatTree(listToTree($list)); $list = formatTree(listToTree($list));
@ -40,7 +40,7 @@ class Menu extends Base {
if ($postData['url']) { if ($postData['url']) {
$postData['url'] = 'admin/' . $postData['url']; $postData['url'] = 'admin/' . $postData['url'];
} }
$res = ApiMenu::create($postData); $res = AdminMenu::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -56,7 +56,7 @@ class Menu 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 = ApiMenu::update([ $res = AdminMenu::update([
'id' => $id, 'id' => $id,
'hide' => $status 'hide' => $status
]); ]);
@ -77,7 +77,7 @@ class Menu extends Base {
if ($postData['url']) { if ($postData['url']) {
$postData['url'] = 'admin/' . $postData['url']; $postData['url'] = 'admin/' . $postData['url'];
} }
$res = ApiMenu::update($postData); $res = AdminMenu::update($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
@ -95,11 +95,11 @@ class Menu extends Base {
if (!$id) { if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
$childNum = ApiMenu::where(['fid' => $id])->count(); $childNum = AdminMenu::where(['fid' => $id])->count();
if ($childNum) { if ($childNum) {
return $this->buildFailed(ReturnCode::INVALID, '当前菜单存在子菜单,不可以被删除!'); return $this->buildFailed(ReturnCode::INVALID, '当前菜单存在子菜单,不可以被删除!');
} else { } else {
ApiMenu::destroy($id); AdminMenu::destroy($id);
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }

View File

@ -8,9 +8,9 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\model\ApiAuthGroupAccess; use app\model\AdminAuthGroupAccess;
use app\model\ApiUser; use app\model\AdminUser;
use app\model\ApiUserData; use app\model\AdminUserData;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -47,18 +47,18 @@ class User extends Base {
} }
} }
$listInfo = (new ApiUser())->where($where)->order('regTime', 'DESC')->limit($start, $limit)->select(); $listInfo = (new AdminUser())->where($where)->order('regTime', 'DESC')->limit($start, $limit)->select();
$count = (new ApiUser())->where($where)->count(); $count = (new AdminUser())->where($where)->count();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
$idArr = array_column($listInfo, 'id'); $idArr = array_column($listInfo, 'id');
$userData = ApiUserData::all(function($query) use ($idArr) { $userData = AdminUserData::all(function($query) use ($idArr) {
$query->whereIn('uid', $idArr); $query->whereIn('uid', $idArr);
}); });
$userData = Tools::buildArrFromObj($userData); $userData = Tools::buildArrFromObj($userData);
$userData = Tools::buildArrByNewKey($userData, 'uid'); $userData = Tools::buildArrByNewKey($userData, 'uid');
$userGroup = ApiAuthGroupAccess::all(function($query) use ($idArr) { $userGroup = AdminAuthGroupAccess::all(function($query) use ($idArr) {
$query->whereIn('uid', $idArr); $query->whereIn('uid', $idArr);
}); });
$userGroup = Tools::buildArrFromObj($userGroup); $userGroup = Tools::buildArrFromObj($userGroup);
@ -99,11 +99,11 @@ class User extends Base {
$groups = trim(implode(',', $postData['groupId']), ','); $groups = trim(implode(',', $postData['groupId']), ',');
} }
unset($postData['groupId']); unset($postData['groupId']);
$res = ApiUser::create($postData); $res = AdminUser::create($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
ApiAuthGroupAccess::create([ AdminAuthGroupAccess::create([
'uid' => $res->id, 'uid' => $res->id,
'groupId' => $groups 'groupId' => $groups
]); ]);
@ -128,15 +128,15 @@ class User extends Base {
return $this->buildFailed(ReturnCode::PARAM_INVALID, '非法操作'); return $this->buildFailed(ReturnCode::PARAM_INVALID, '非法操作');
} }
$listInfo = (new ApiAuthGroupAccess())->where(['groupId' => ['like', "%{$gid}%"]])->select(); $listInfo = (new AdminAuthGroupAccess())->where(['groupId' => ['like', "%{$gid}%"]])->select();
$listInfo = Tools::buildArrFromObj($listInfo); $listInfo = Tools::buildArrFromObj($listInfo);
$uidArr = array_column($listInfo, 'uid'); $uidArr = array_column($listInfo, 'uid');
$userInfo = (new ApiUser())->whereIn('id', $uidArr)->order('regTime', 'DESC')->limit($start, $limit)->select(); $userInfo = (new AdminUser())->whereIn('id', $uidArr)->order('regTime', 'DESC')->limit($start, $limit)->select();
$count = (new ApiUser())->whereIn('id', $uidArr)->count(); $count = (new AdminUser())->whereIn('id', $uidArr)->count();
$userInfo = Tools::buildArrFromObj($userInfo); $userInfo = Tools::buildArrFromObj($userInfo);
$userData = ApiUserData::all(function($query) use ($uidArr) { $userData = AdminUserData::all(function($query) use ($uidArr) {
$query->whereIn('uid', $uidArr); $query->whereIn('uid', $uidArr);
}); });
$userData = Tools::buildArrFromObj($userData); $userData = Tools::buildArrFromObj($userData);
@ -165,7 +165,7 @@ class User 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 = ApiUser::update([ $res = AdminUser::update([
'id' => $id, 'id' => $id,
'status' => $status, 'status' => $status,
'updateTime' => time() 'updateTime' => time()
@ -196,19 +196,19 @@ class User extends Base {
} }
$postData['updateTime'] = time(); $postData['updateTime'] = time();
unset($postData['groupId']); unset($postData['groupId']);
$res = ApiUser::update($postData); $res = AdminUser::update($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
$has = ApiAuthGroupAccess::get(['uid' => $postData['id']]); $has = AdminAuthGroupAccess::get(['uid' => $postData['id']]);
if ($has) { if ($has) {
ApiAuthGroupAccess::update([ AdminAuthGroupAccess::update([
'groupId' => $groups 'groupId' => $groups
], [ ], [
'uid' => $postData['id'], 'uid' => $postData['id'],
]); ]);
} else { } else {
ApiAuthGroupAccess::create([ AdminAuthGroupAccess::create([
'uid' => $postData['id'], 'uid' => $postData['id'],
'groupId' => $groups 'groupId' => $groups
]); ]);
@ -242,11 +242,11 @@ class User extends Base {
$postData['id'] = $this->userInfo['id']; $postData['id'] = $this->userInfo['id'];
$postData['updateTime'] = time(); $postData['updateTime'] = time();
unset($postData['headImg']); unset($postData['headImg']);
$res = ApiUser::update($postData); $res = AdminUser::update($postData);
if ($res === false) { if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else { } else {
$userData = ApiUserData::get(['uid' => $postData['id']]); $userData = AdminUserData::get(['uid' => $postData['id']]);
$userData->headImg = $headImg; $userData->headImg = $headImg;
$userData->save(); $userData->save();
@ -264,8 +264,8 @@ class User extends Base {
if (!$id) { if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
} }
ApiUser::destroy($id); AdminUser::destroy($id);
ApiAuthGroupAccess::destroy(['uid' => $id]); AdminAuthGroupAccess::destroy(['uid' => $id]);
return $this->buildSuccess([]); return $this->buildSuccess([]);

View File

@ -8,7 +8,7 @@
namespace app\api\behavior; namespace app\api\behavior;
use app\model\ApiList; use app\model\AdminList;
use app\util\ApiLog; use app\util\ApiLog;
use app\util\ReturnCode; use app\util\ReturnCode;
use think\Request; use think\Request;
@ -33,7 +33,7 @@ class ApiAuth {
$hash = $this->request->routeInfo(); $hash = $this->request->routeInfo();
if (isset($hash['rule'][1])) { if (isset($hash['rule'][1])) {
$hash = $hash['rule'][1]; $hash = $hash['rule'][1];
$this->apiInfo = ApiList::get(['hash' => $hash]); $this->apiInfo = AdminList::get(['hash' => $hash]);
if ($this->apiInfo) { if ($this->apiInfo) {
$this->apiInfo = $this->apiInfo->toArray(); $this->apiInfo = $this->apiInfo->toArray();
} else { } else {

View File

@ -8,7 +8,7 @@
namespace app\api\behavior; namespace app\api\behavior;
use app\model\ApiFields; use app\model\AdminFields;
use app\util\ApiLog; use app\util\ApiLog;
use app\util\DataType; use app\util\DataType;
use think\Request; use think\Request;
@ -27,7 +27,7 @@ class BuildResponse {
$hash = $request->routeInfo(); $hash = $request->routeInfo();
if (isset($hash['rule'][1])) { if (isset($hash['rule'][1])) {
$hash = $hash['rule'][1]; $hash = $hash['rule'][1];
$rule = ApiFields::all(['hash' => $hash, 'type' => 1]); $rule = AdminFields::all(['hash' => $hash, 'type' => 1]);
if ($rule) { if ($rule) {
$rule = json_decode(json_encode($rule), true); $rule = json_decode(json_encode($rule), true);
$newRule = array_column($rule, 'dataType', 'showName'); $newRule = array_column($rule, 'dataType', 'showName');
@ -85,4 +85,4 @@ class BuildResponse {
} }
} }
} }

View File

@ -9,7 +9,7 @@
namespace app\api\behavior; namespace app\api\behavior;
use app\model\ApiFields; use app\model\AdminFields;
use app\util\ApiLog; use app\util\ApiLog;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\DataType; use app\util\DataType;
@ -47,7 +47,7 @@ class RequestFilter {
$hash = $request->routeInfo(); $hash = $request->routeInfo();
if (isset($hash['rule'][1])) { if (isset($hash['rule'][1])) {
$hash = $hash['rule'][1]; $hash = $hash['rule'][1];
$rule = ApiFields::all(['hash' => $hash, 'type' => 0]); $rule = AdminFields::all(['hash' => $hash, 'type' => 0]);
$newRule = $this->buildValidateRule($rule); $newRule = $this->buildValidateRule($rule);
if ($newRule) { if ($newRule) {

View File

@ -8,7 +8,7 @@
namespace app\api\controller; namespace app\api\controller;
use app\model\ApiApp; use app\model\AdminApp;
use app\util\ApiLog; use app\util\ApiLog;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Strs; use app\util\Strs;
@ -28,7 +28,7 @@ class BuildToken extends Base {
if (empty($param['app_id'])) { if (empty($param['app_id'])) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少app_id'); return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少app_id');
} }
$appInfo = (new ApiApp())->where(['app_id' => $param['app_id'], 'app_status' => 1])->find(); $appInfo = (new AdminApp())->where(['app_id' => $param['app_id'], 'app_status' => 1])->find();
if (empty($appInfo)) { if (empty($appInfo)) {
return $this->buildFailed(ReturnCode::INVALID, '应用ID非法'); return $this->buildFailed(ReturnCode::INVALID, '应用ID非法');
} }

View File

@ -3,6 +3,6 @@
namespace app\model; namespace app\model;
class ApiApp extends Base { class AdminApp extends Base {
} }

View File

@ -8,6 +8,6 @@
namespace app\model; namespace app\model;
class ApiAppGroup extends Base { class AdminAppGroup extends Base {
} }

View File

@ -8,10 +8,10 @@
namespace app\model; namespace app\model;
class ApiAuthGroup extends Base { class AdminAuthGroup extends Base {
public function rules() { public function rules() {
return $this->hasMany('ApiAuthRule', 'groupId', 'id'); return $this->hasMany('AdminAuthRule', 'groupId', 'id');
} }
} }

View File

@ -8,6 +8,6 @@
namespace app\model; namespace app\model;
class ApiAuthGroupAccess extends Base { class AdminAuthGroupAccess extends Base {
} }

View File

@ -8,6 +8,6 @@
namespace app\model; namespace app\model;
class ApiAuthRule extends Base { class AdminAuthRule extends Base {
} }

View File

@ -7,6 +7,6 @@
namespace app\model; namespace app\model;
class ApiFields extends Base { class AdminFields extends Base {
} }

View File

@ -8,6 +8,6 @@
namespace app\model; namespace app\model;
class ApiGroup extends Base { class AdminGroup extends Base {
} }

View File

@ -6,6 +6,6 @@
namespace app\model; namespace app\model;
class ApiList extends Base { class AdminList extends Base {
} }

View File

@ -3,6 +3,6 @@
namespace app\model; namespace app\model;
class ApiMenu extends Base { class AdminMenu extends Base {
// //
} }

View File

@ -7,6 +7,6 @@
namespace app\model; namespace app\model;
class ApiUser extends Base { class AdminUser extends Base {
} }

View File

@ -8,6 +8,6 @@
namespace app\model; namespace app\model;
class ApiUserAction extends Base { class AdminUserAction extends Base {
} }

View File

@ -7,6 +7,6 @@
namespace app\model; namespace app\model;
class ApiUserData extends Base { class AdminUserData extends Base {
} }

View File

@ -8,10 +8,10 @@
namespace app\wiki\controller; namespace app\wiki\controller;
use app\model\ApiApp; use app\model\AdminApp;
use app\model\ApiFields; use app\model\AdminFields;
use app\model\ApiGroup; use app\model\AdminGroup;
use app\model\ApiList; use app\model\AdminList;
use app\util\DataType; use app\util\DataType;
use app\util\ReturnCode; use app\util\ReturnCode;
use app\util\Tools; use app\util\Tools;
@ -27,11 +27,11 @@ class Index extends Base {
public function index() { public function index() {
$this->checkLogin(); $this->checkLogin();
$groupInfo = ApiGroup::all(); $groupInfo = AdminGroup::all();
$groupInfo = Tools::buildArrFromObj($groupInfo); $groupInfo = Tools::buildArrFromObj($groupInfo);
$groupInfo = Tools::buildArrByNewKey($groupInfo, 'hash'); $groupInfo = Tools::buildArrByNewKey($groupInfo, 'hash');
$this->appInfo = ApiApp::get(['app_id' => $this->appInfo['app_id']]); $this->appInfo = AdminApp::get(['app_id' => $this->appInfo['app_id']]);
$this->appInfo['app_api_show'] = json_decode($this->appInfo['app_api_show'], true); $this->appInfo['app_api_show'] = json_decode($this->appInfo['app_api_show'], true);
return view('', [ return view('', [
@ -58,7 +58,7 @@ class Index extends Base {
} }
} }
$apiList = (new ApiList())->whereIn('hash', $this->appInfo['app_api_show'][$groupHash])->where(['groupHash' => $groupHash])->select(); $apiList = (new AdminList())->whereIn('hash', $this->appInfo['app_api_show'][$groupHash])->where(['groupHash' => $groupHash])->select();
$apiList = Tools::buildArrFromObj($apiList); $apiList = Tools::buildArrFromObj($apiList);
$apiList = Tools::buildArrByNewKey($apiList, 'hash'); $apiList = Tools::buildArrByNewKey($apiList, 'hash');
@ -67,8 +67,8 @@ class Index extends Base {
} }
$detail = $apiList[$hash]; $detail = $apiList[$hash];
$request = ApiFields::all(['hash' => $hash, 'type' => 0]); $request = AdminFields::all(['hash' => $hash, 'type' => 0]);
$response = ApiFields::all(['hash' => $hash, 'type' => 1]); $response = AdminFields::all(['hash' => $hash, 'type' => 1]);
$dataType = array( $dataType = array(
DataType::TYPE_INTEGER => 'Integer', DataType::TYPE_INTEGER => 'Integer',
DataType::TYPE_STRING => 'String', DataType::TYPE_STRING => 'String',
@ -81,7 +81,7 @@ class Index extends Base {
DataType::TYPE_MOBILE => 'Mobile' DataType::TYPE_MOBILE => 'Mobile'
); );
$groupInfo = ApiGroup::get(['hash' => $groupHash]); $groupInfo = AdminGroup::get(['hash' => $groupHash]);
$groupInfo->hot = $groupInfo->hot + 1; $groupInfo->hot = $groupInfo->hot + 1;
$groupInfo->save(); $groupInfo->save();
@ -156,7 +156,7 @@ class Index extends Base {
$appId = $this->request->post('appId'); $appId = $this->request->post('appId');
$appSecret = $this->request->post('appSecret'); $appSecret = $this->request->post('appSecret');
$appInfo = ApiApp::get(['app_id' => $appId, 'app_secret' => $appSecret]); $appInfo = AdminApp::get(['app_id' => $appId, 'app_secret' => $appSecret]);
if (!empty($appInfo)) { if (!empty($appInfo)) {
if ($appInfo->app_status) { if ($appInfo->app_status) {
//保存用户信息和登录凭证 //保存用户信息和登录凭证