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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
namespace app\api\behavior;
use app\model\ApiFields;
use app\model\AdminFields;
use app\util\ApiLog;
use app\util\ReturnCode;
use app\util\DataType;
@ -47,7 +47,7 @@ class RequestFilter {
$hash = $request->routeInfo();
if (isset($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);
if ($newRule) {

View File

@ -8,7 +8,7 @@
namespace app\api\controller;
use app\model\ApiApp;
use app\model\AdminApp;
use app\util\ApiLog;
use app\util\ReturnCode;
use app\util\Strs;
@ -28,7 +28,7 @@ class BuildToken extends Base {
if (empty($param['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)) {
return $this->buildFailed(ReturnCode::INVALID, '应用ID非法');
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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