mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 新增应该管理模块,新增API字段规则的相关表模型
This commit is contained in:
parent
1bbf7f4fbb
commit
13943f5f3e
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Api管理中心
|
||||
* APP管理
|
||||
* @since 2016-02-18
|
||||
* @author zhaoxiang <zhaoxiang051405@outlook.com>
|
||||
*/
|
||||
@ -13,9 +13,7 @@ use app\admin\model\App;
|
||||
class AppManager extends Base {
|
||||
|
||||
public function index(){
|
||||
$data = [];
|
||||
// $dataObj = App::all();
|
||||
|
||||
$data = App::all();
|
||||
$table = [
|
||||
'tempType' => 'table',
|
||||
'header' => [
|
||||
@ -24,32 +22,28 @@ class AppManager extends Base {
|
||||
'info' => '应用名称'
|
||||
],
|
||||
[
|
||||
'field' => 'token',
|
||||
'info' => '应用唯一标识'
|
||||
],
|
||||
[
|
||||
'field' => 'baseUrl',
|
||||
'info' => '基础URL'
|
||||
],
|
||||
[
|
||||
'field' => 'keyGroup',
|
||||
'info' => '关联秘钥组'
|
||||
'field' => 'info',
|
||||
'info' => '应用描述'
|
||||
],
|
||||
[
|
||||
'field' => 'type',
|
||||
'info' => '参与角色'
|
||||
'info' => '参与方式'
|
||||
],
|
||||
[
|
||||
'field' => 'status',
|
||||
'info' => '状态'
|
||||
]
|
||||
],
|
||||
'topButton' => [
|
||||
[
|
||||
'href' => 'Menu/add',
|
||||
'href' => 'AppManager/add',
|
||||
'class'=> 'btn-success',
|
||||
'info'=> '新增',
|
||||
'icon' => 'fa fa-plus',
|
||||
'confirm' => 0,
|
||||
],
|
||||
[
|
||||
'href' => 'Menu/del',
|
||||
'href' => 'AppManager/del',
|
||||
'class'=> 'btn-danger ajax-delete',
|
||||
'info'=> '删除',
|
||||
'icon' => 'fa fa-trash',
|
||||
@ -57,10 +51,28 @@ class AppManager extends Base {
|
||||
]
|
||||
],
|
||||
'rightButton' => [
|
||||
[
|
||||
'info' => '启用',
|
||||
'href' => 'AppManager/open',
|
||||
'class'=> 'btn-success ajax-put-url',
|
||||
'param'=> [$this->primaryKey],
|
||||
'icon' => 'fa fa-check',
|
||||
'confirm' => 1,
|
||||
'show' => ['status', 0]
|
||||
],
|
||||
[
|
||||
'info' => '禁用',
|
||||
'href' => 'AppManager/close',
|
||||
'class'=> 'btn-warning ajax-put-url',
|
||||
'param'=> [$this->primaryKey],
|
||||
'icon' => 'fa fa-close',
|
||||
'confirm' => 1,
|
||||
'show' => ['status', 1]
|
||||
],
|
||||
[
|
||||
'info' => '编辑',
|
||||
'href' => 'Menu/edit',
|
||||
'class'=> 'btn-warning',
|
||||
'href' => 'AppManager/edit',
|
||||
'class'=> 'btn-primary',
|
||||
'param'=> [$this->primaryKey],
|
||||
'icon' => 'fa fa-pencil',
|
||||
'confirm' => 0,
|
||||
@ -68,7 +80,7 @@ class AppManager extends Base {
|
||||
],
|
||||
[
|
||||
'info' => '删除',
|
||||
'href' => 'Menu/del',
|
||||
'href' => 'AppManager/del',
|
||||
'class'=> 'btn-danger ajax-delete',
|
||||
'param'=> [$this->primaryKey],
|
||||
'icon' => 'fa fa-trash',
|
||||
@ -77,25 +89,29 @@ class AppManager extends Base {
|
||||
]
|
||||
],
|
||||
'typeRule' => [
|
||||
'name' => [
|
||||
'module' => 'a',
|
||||
'rule' => [
|
||||
'info' => '',
|
||||
'href' => url('Menu/add'),
|
||||
'param'=> [$this->primaryKey],
|
||||
'class' => 'refresh'
|
||||
]
|
||||
],
|
||||
'hide' => [
|
||||
'type' => [
|
||||
'module' => 'label',
|
||||
'rule' => [
|
||||
[
|
||||
'info' => '显示',
|
||||
'class' => 'label label-success'
|
||||
'info' => '监视方式',
|
||||
'class' => 'label label-info'
|
||||
],
|
||||
[
|
||||
'info' => '隐藏',
|
||||
'class' => 'label label-warning'
|
||||
'info' => '网关方式',
|
||||
'class' => 'label label-primary'
|
||||
]
|
||||
]
|
||||
],
|
||||
'status' => [
|
||||
'module' => 'label',
|
||||
'rule' => [
|
||||
[
|
||||
'info' => '禁用',
|
||||
'class' => 'label label-danger'
|
||||
],
|
||||
[
|
||||
'info' => '启用',
|
||||
'class' => 'label label-success'
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -106,4 +122,190 @@ class AppManager extends Base {
|
||||
$this->result($table, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
if( $this->request->isPost() ){
|
||||
$appModel = new App();
|
||||
$result = $appModel->allowField(true)->save($this->request->post());
|
||||
if(false === $result){
|
||||
$this->error($appModel->getError());
|
||||
}else{
|
||||
$this->success('操作成功!', url('AppManager/index'));
|
||||
}
|
||||
}else{
|
||||
$form = [
|
||||
'formTitle' => $this->menuInfo['name'],
|
||||
'tempType' => 'add',
|
||||
'formAttr' => [
|
||||
'target' => url('AppManager/add'),
|
||||
'formId' => 'add-AppManager-form',
|
||||
'backUrl' => url('AppManager/index'),
|
||||
],
|
||||
'formList' => [
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '应用名称:',
|
||||
'attr' => [
|
||||
'name' => 'name',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '基础链接:',
|
||||
'attr' => [
|
||||
'name' => 'baseUrl',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'select',
|
||||
'description' => '',
|
||||
'info' => '参与方式:',
|
||||
'attr' => [
|
||||
'name' => 'type',
|
||||
'value' => '',
|
||||
'options' => [
|
||||
'监视方式',
|
||||
'网关方式'
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'textarea',
|
||||
'description' => '',
|
||||
'info' => '应用描述:',
|
||||
'attr' => [
|
||||
'name' => 'info',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
public function open(){
|
||||
if( $this->request->isPut() ){
|
||||
$id = $this->request->put($this->primaryKey);
|
||||
$appMemberObj = \app\admin\model\AppMember::get([$this->primaryKey => $id]);
|
||||
if( is_null($appMemberObj) ){
|
||||
$this->error('管理员不存在','');
|
||||
}else{
|
||||
$appMemberObj->status = 1;
|
||||
$appMemberObj->save();
|
||||
$this->success('操作成功', url('AppMember/index'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function close(){
|
||||
if( $this->request->isPut() ){
|
||||
$id = $this->request->put($this->primaryKey);
|
||||
$appMemberObj = \app\admin\model\AppMember::get([$this->primaryKey => $id]);
|
||||
if( is_null($appMemberObj) ){
|
||||
$this->error('管理员不存在','');
|
||||
}else{
|
||||
$appMemberObj->status = 0;
|
||||
$appMemberObj->save();
|
||||
$this->success('操作成功', url('AppMember/index'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function del(){
|
||||
if( $this->request->isDelete() ){
|
||||
$key = $this->request->delete($this->primaryKey);
|
||||
$delNum = \app\admin\model\AppMember::destroy($key);
|
||||
if( $delNum ){
|
||||
$this->success('操作成功!', url('AppMember/index'));
|
||||
}
|
||||
}
|
||||
$this->error('操作失败!');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if( $this->request->isPut() ){
|
||||
if( empty($this->request->put('name')) ){
|
||||
$this->error('应用名称不能为空', '');
|
||||
}
|
||||
$data = $this->request->put();
|
||||
$appMemberModel = new App();
|
||||
$appMemberModel->update($data);
|
||||
$this->success('操作成功!', url('AppManager/index'));
|
||||
}else{
|
||||
$detail = App::get($this->request->get($this->primaryKey))->toArray();
|
||||
$form = [
|
||||
'formTitle' => $this->menuInfo['name'],
|
||||
'tempType' => 'edit',
|
||||
'formAttr' => [
|
||||
'target' => url('AppManager/edit'),
|
||||
'formId' => 'edit-AppManager-form',
|
||||
'backUrl' => url('AppManager/index'),
|
||||
],
|
||||
'formList' => [
|
||||
[
|
||||
'module' => 'hidden',
|
||||
'description' => '',
|
||||
'info' => '',
|
||||
'attr' => [
|
||||
'name' => $this->primaryKey,
|
||||
'value' => $detail[$this->primaryKey],
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '应用名称:',
|
||||
'attr' => [
|
||||
'name' => 'name',
|
||||
'value' => $detail['name'],
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '基础链接:',
|
||||
'attr' => [
|
||||
'name' => 'baseUrl',
|
||||
'value' => $detail['baseUrl'],
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'select',
|
||||
'description' => '',
|
||||
'info' => '参与方式:',
|
||||
'attr' => [
|
||||
'name' => 'type',
|
||||
'value' => $detail['type'],
|
||||
'options' => [
|
||||
'监视方式',
|
||||
'网关方式'
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'textarea',
|
||||
'description' => '',
|
||||
'info' => '应用描述:',
|
||||
'attr' => [
|
||||
'name' => 'info',
|
||||
'value' => $detail['info'],
|
||||
'placeholder' => ''
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
12
application/admin/model/ApiBack.php
Normal file
12
application/admin/model/ApiBack.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @since 2016-12-12
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
class ApiBack extends Base {
|
||||
|
||||
}
|
12
application/admin/model/ApiFields.php
Normal file
12
application/admin/model/ApiFields.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @since 2016-12-12
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
class ApiFields extends Base {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user