mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 代码备份
This commit is contained in:
parent
6619202a6d
commit
0f7efab6cf
13
application/admin/controller/ApiGroup.php
Normal file
13
application/admin/controller/ApiGroup.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
class ApiGroup extends Base {
|
||||
|
||||
}
|
13
application/admin/controller/ApiList.php
Normal file
13
application/admin/controller/ApiList.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
class ApiList extends Base {
|
||||
|
||||
}
|
123
application/admin/controller/App.php
Normal file
123
application/admin/controller/App.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\ApiApp;
|
||||
use app\util\ReturnCode;
|
||||
|
||||
class App extends Base {
|
||||
/**
|
||||
* 获取应用列表
|
||||
* @return array
|
||||
* @throws \think\exception\DbException
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
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 <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
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 <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
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 <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
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 <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
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([]);
|
||||
}
|
||||
}
|
||||
}
|
13
application/admin/controller/AppGroup.php
Normal file
13
application/admin/controller/AppGroup.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
class AppGroup extends Base {
|
||||
|
||||
}
|
@ -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'],
|
||||
],
|
||||
];
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace app\model;
|
||||
|
||||
|
||||
class ApiApp extends Base
|
||||
{
|
||||
//
|
||||
class ApiApp extends Base {
|
||||
|
||||
}
|
||||
|
13
application/model/ApiAppGroup.php
Normal file
13
application/model/ApiAppGroup.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\model;
|
||||
|
||||
|
||||
class ApiAppGroup extends Base {
|
||||
|
||||
}
|
13
application/model/ApiGroup.php
Normal file
13
application/model/ApiGroup.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @since 2018-02-11
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\model;
|
||||
|
||||
|
||||
class ApiGroup extends Base {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user