Skip to content

Commit

Permalink
功能增加-接口排序功能
Browse files Browse the repository at this point in the history
  • Loading branch information
gongwen committed Jul 6, 2015
1 parent a2f9ea0 commit bddf9a4
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MinPHP/core/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//版本信息
'version'=>array(
'no' => 'v1.0', //版本号
'time' => '2015-06-29 18:08', //版本时间
'time' => '2015-07-06 18:24', //版本时间
)

);
4 changes: 2 additions & 2 deletions MinPHP/run/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
$sql = "insert into api (
`aid`,`num`,`name`,`des`,`url`,
`type`,`parameter`,`re`,`lasttime`,
`lastuid`,`isdel`,`memo`
`lastuid`,`isdel`,`memo`,`ord`
)values (
'{$aid}','{$num}','{$name}','{$des}','{$url}',
'{$type}','{$parameter}','{$re}','{$lasttime}',
'{$lastuid}','{$isdel}','{$memo}'
'{$lastuid}','{$isdel}','{$memo}','99999'
)";
$re = insert($sql);
if($re){
Expand Down
5 changes: 3 additions & 2 deletions MinPHP/run/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
<span id="topbutton" style="float:right">
<?php
if(is_lgoin()){
//如果是接口详情页的话,就显示【导出】按钮
if(isset($_GET['tag']) && !isset($_GET['op'])){
//如果是接口详情页的话,就显示【导出】按钮 与 【排序按钮】
if($_GET['act']='api' && isset($_GET['tag']) && !isset($_GET['op'])){
echo '<a href="?act=sort&tag='.$_GET['tag'].'">排序&nbsp;&nbsp;</a>';
echo '<a href="?act=export&tag='.$_GET['tag'].'">导出&nbsp;&nbsp;</a>';
}
echo '<a href="?act=login&type=quit">退出&nbsp;&nbsp;<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span></a>';
Expand Down
2 changes: 1 addition & 1 deletion MinPHP/run/menu.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php defined('API') or exit('http://gwalker.cn');?>
<!--导航-->
<?php if($act != 'api'){
<?php if($act != 'api' && $act != 'sort'){
$list = select('select * from cate where isdel=0 order by addtime desc');
?>
<div class="form-group">
Expand Down
73 changes: 73 additions & 0 deletions MinPHP/run/sort.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php defined('API') or exit();?>
<!--接口排序管理start-->
<?php
//操作类型{type}
$type = $_GET['type'];
if(empty($type)){
//已经分类下的所有接口start
$sql = "select id,num,name from api where aid='{$_GET['tag']}' and isdel=0 order by ord desc,id desc";
$list = select($sql);
}else if($type == 'do'){
$ord = count($_POST['api']);
foreach($_POST['api'] as $v){
$sql = "update api set ord = '{$ord}' where id='{$v}' and aid='{$_GET['tag']}'";
update($sql);
$ord--;
}
$url = U(array('act'=>'api','tag'=>$_GET['tag']));
go($url);
}
?>
<div style="border:1px solid #ddd;margin-bottom:20px;">
<div style="background:#ffffff;padding:20px;">
<h5 class="textshadow" >接口列表</h5>
<form action="<?php echo U(array('act'=>'sort','tag'=>$_GET['tag'],'type'=>'do')) ?>" method="post">
<table class="table">
<thead>
<tr>
<th class="col-md-2">接口编号</th>
<th class="col-md-9">接口名</th>
<th class="col-md-1">操作</th>
</tr>
</thead>
<tbody>
<?php foreach($list as $v){?>
<tr>
<td><input name="api[]" type="hidden" value="<?php echo $v['id'];?>"><?php echo $v['num'];?></td>
<td><?php echo $v['name'];?></td>
<td>
<span onclick="up(this)" style="color:red;cursor: pointer" class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
&nbsp;
<span onclick="down(this)" style="color:green;cursor: pointer" class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<button class="btn btn-success">Submit</button>
</form>
</div>
</div>
<script>
//上移
function up(obj){
var $TR = $(obj).parents('tr');
var prevTR = $TR.prev();
prevTR.insertAfter($TR);
$('tr.info').removeClass('info');
$TR.addClass('info');
$TR.hide();
$TR.show(300);
}
//下移
function down(obj){
var $TR = $(obj).parents('tr');
var nextTR = $TR.next();
nextTR.insertBefore($TR);
$('tr.info').removeClass('info');
$TR.addClass('info');
$TR.hide();
$TR.show(300);
}
</script>
<!--接口排序管理end-->
7 changes: 7 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
$menu = ' - ' . $menu['cname'];
$file ='./MinPHP/run/info.php';
break;
//接口排序页
case 'sort':
$sql = "select cname from cate where aid='{$_GET['tag']}' and isdel=0";
$menu = find($sql);
$menu = ' - ' . "<a href='".U(array('act'=>'api','tag'=>$_GET['tag']))."'>{$menu['cname']}</a>";
$file ='./MinPHP/run/sort.php';
break;
//导出静态文件
case 'export':
die(include('./MinPHP/run/export.php'));
Expand Down

0 comments on commit bddf9a4

Please sign in to comment.