37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace app\protects\controller;
|
|
use think\admin\Controller;
|
|
use dever\Log;
|
|
use app\protects\service\ServiceInfoService;
|
|
use app\protects\service\ServiceProductService;
|
|
use think\App;
|
|
|
|
class Site extends Controller
|
|
{
|
|
protected $auth_ip=['*'];//ip白名单
|
|
protected $no_need_auth=['*'];//无需验证ip权限的方法
|
|
protected $code=array(
|
|
1=>'连接成功',
|
|
-1=>'连接失败',
|
|
-2=>'白名单错误'
|
|
);
|
|
public function __construct(App $app)
|
|
{
|
|
parent::__construct($app);
|
|
$ip=$_SERVER['REMOTE_ADDR'];
|
|
$action=$this->request->action();
|
|
if(!empty($this->auth_ip)&&!empty($this->no_need_auth)&&!in_array('*',$this->auth_ip)&&!in_array('*',$this->no_need_auth)&&!in_array($ip,$this->auth_ip)&&!in_array($action,$this->no_need_auth)){
|
|
return json(['code'=>-1,'msg'=>$this->code[-2]]);
|
|
}
|
|
}
|
|
//获取所有业务和产品
|
|
public function getProducts(){
|
|
$return_data=array();
|
|
$return_data['service_info']=ServiceInfoService::instance()->getAll();
|
|
$return_data['service_type']=ServiceInfoService::instance()->infoType();
|
|
$return_data['service_prosuct']=ServiceProductService::instance()->getAll();
|
|
return json(['code'=>1,'msg'=>'查询成功','data'=>$return_data]);
|
|
}
|
|
|
|
} |