diff --git a/application/admin/controller/ApiGroup.php b/application/admin/controller/ApiGroup.php new file mode 100644 index 0000000..56e182a --- /dev/null +++ b/application/admin/controller/ApiGroup.php @@ -0,0 +1,13 @@ + + */ + +namespace app\admin\controller; + + +class ApiGroup extends Base { + +} diff --git a/application/admin/controller/ApiList.php b/application/admin/controller/ApiList.php new file mode 100644 index 0000000..33ab056 --- /dev/null +++ b/application/admin/controller/ApiList.php @@ -0,0 +1,13 @@ + + */ + +namespace app\admin\controller; + + +class ApiList extends Base { + +} diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php new file mode 100644 index 0000000..e26cbd4 --- /dev/null +++ b/application/admin/controller/App.php @@ -0,0 +1,123 @@ + + */ + +namespace app\admin\controller; + + +use app\model\ApiApp; +use app\util\ReturnCode; + +class App extends Base { + /** + * 获取应用列表 + * @return array + * @throws \think\exception\DbException + * @author zhaoxiang + */ + public function index() { + + $limit = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT')); + $start = $limit * ($this->request->get('page', 1) - 1); + $keywords = $this->request->get('keywords', ''); + $type = $this->request->get('type', ''); + $status = $this->request->get('status', ''); + + $where = []; + if ($status === '1' || $status === '0') { + $where['status'] = $status; + } + if ($type) { + switch ($type) { + case 1: + $where['app_id'] = $keywords; + break; + case 2: + $where['app_name'] = ['like', "%{$keywords}%"]; + break; + } + } + + $listInfo = (new ApiApp())->where($where)->order('app_addTime', 'DESC')->limit($start, $limit)->select(); + $count = (new ApiApp())->where($where)->count(); + $listInfo = $this->buildArrFromObj($listInfo); + + return $this->buildSuccess([ + 'list' => $listInfo, + 'count' => $count + ]); + } + + /** + * 新增菜单 + * @return array + * @author zhaoxiang + */ + public function add() { + $postData = $this->request->post(); + $res = ApiMenu::create($postData); + if ($res === false) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + } else { + return $this->buildSuccess([]); + } + } + + /** + * 菜单状态编辑 + * @return array + * @author zhaoxiang + */ + public function changeStatus() { + $id = $this->request->get('id'); + $status = $this->request->get('status'); + $res = ApiApp::update([ + 'app_status' => $status + ], [ + 'app_id' => $id + ]); + if ($res === false) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + } else { + return $this->buildSuccess([]); + } + } + + /** + * 编辑菜单 + * @return array + * @author zhaoxiang + */ + public function edit() { + $postData = $this->request->post(); + $res = ApiMenu::update($postData); + if ($res === false) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + } else { + return $this->buildSuccess([]); + } + } + + /** + * 删除菜单 + * @return array + * @author zhaoxiang + */ + public function del() { + $id = $this->request->get('id'); + if (!$id) { + return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); + } + $childNum = ApiMenu::where(['fid' => $id])->count(); + if ($childNum) { + return $this->buildFailed(ReturnCode::INVALID, '当前菜单存在子菜单,不可以被删除!'); + } else { + ApiMenu::destroy($id); + + return $this->buildSuccess([]); + } + } +} diff --git a/application/admin/controller/AppGroup.php b/application/admin/controller/AppGroup.php new file mode 100644 index 0000000..be5e325 --- /dev/null +++ b/application/admin/controller/AppGroup.php @@ -0,0 +1,13 @@ + + */ + +namespace app\admin\controller; + + +class AppGroup extends Base { + +} diff --git a/application/adminRoute.php b/application/adminRoute.php index ad4a9b2..cced722 100644 --- a/application/adminRoute.php +++ b/application/adminRoute.php @@ -87,6 +87,26 @@ return [ 'admin/Auth/getRuleList', ['method' => 'get', 'after_behavior' => $afterBehavior] ], + 'App/index' => [ + 'admin/App/index', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], + 'App/changeStatus' => [ + 'admin/App/changeStatus', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], + 'App/add' => [ + 'admin/App/add', + ['method' => 'post', 'after_behavior' => $afterBehavior] + ], + 'App/edit' => [ + 'admin/App/edit', + ['method' => 'post', 'after_behavior' => $afterBehavior] + ], + 'App/del' => [ + 'admin/App/del', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], '__miss__' => ['admin/Miss/index'], ], ]; diff --git a/application/model/ApiApp.php b/application/model/ApiApp.php index 0614672..21ddafb 100644 --- a/application/model/ApiApp.php +++ b/application/model/ApiApp.php @@ -3,7 +3,6 @@ namespace app\model; -class ApiApp extends Base -{ - // +class ApiApp extends Base { + } diff --git a/application/model/ApiAppGroup.php b/application/model/ApiAppGroup.php new file mode 100644 index 0000000..c47c7f9 --- /dev/null +++ b/application/model/ApiAppGroup.php @@ -0,0 +1,13 @@ + + */ + +namespace app\model; + + +class ApiAppGroup extends Base { + +} diff --git a/application/model/ApiGroup.php b/application/model/ApiGroup.php new file mode 100644 index 0000000..7ef02c7 --- /dev/null +++ b/application/model/ApiGroup.php @@ -0,0 +1,13 @@ + + */ + +namespace app\model; + + +class ApiGroup extends Base { + +}