ip限制控制器提交

master
zhengyongxing 5 years ago
parent 48239c0f13
commit 5d81a253db

@ -0,0 +1,118 @@
<?php
namespace Admin\Controller;
use Org\Util\Date;
use Sdk\Controller\AgeController;
use User\Api\MemberApi as MemberApi;
use Org\WeixinSDK\Weixin;
class AmericaIpForbitController extends ThinkController
{
public function index($p = 0) {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$map = [];
if ($_REQUEST['user_account']) {
$map['user_account'] = $_REQUEST['user_account'];
}
$data = M('forbit_ip','tab_')
->where($map)
->page($page,$row)
->select();
$this->assgin('data',$data);
$this->display();
}
public function operateIp() {
if (!I('id')) {
$this->ajaxReturn(['code'=>1,'msg'=>'ID未选择']);
} else {
$id = I('id');
}
if (I('status')) {
$status = I('status');
} else {
$status = 0;
}
$map['id'] = ['in',$id];
$is_change = M('forbit_ip','tab_')->where(['id'=>['in',$id]])->save(['status'=>$status]);
if ($is_change) {
$this->ajaxReturn(['code'=>0]);
} else {
$this->ajaxReturn(['code'=>1]);
}
}
public function del() {
if (!I('id')) {
$this->ajaxReturn(['code'=>1,'msg'=>'ID未选择']);
} else {
$id = I('id');
}
$is_del = $is_change = M('forbit_ip','tab_')->where(['id'=>['in',$id]])->delete();
if ($is_del) {
$this->ajaxReturn(['code'=>0]);
} else {
$this->ajaxReturn(['code'=>1]);
}
}
public function addUser() {
$insert = [];
$hav_user = M('user','tab_')->where(['account'=>I('user_account')])->find();
if (!$hav_user) {
$this->ajaxReturn(['msg'=>'用户不存在','code'=>1]);
}
$insert['user_id'] = $hav_user['id'];
$insert['user_account'] = I('user_account');
$insert['area'] = I('area');
$insert['status'] = I('status');
$insert['admin_id'] = I('admin_id');
$insert['admin_account'] = I('admin_account');
$insert['create_time'] = time();
$insert['remarks'] = '';
$is_insert = M('forbit_ip','tab_')->add($insert);
if ($is_insert) {
$this->ajaxReturn(['code'=>0]);
} else {
$this->ajaxReturn(['code'=>1]);
}
}
}
Loading…
Cancel
Save