提交 c3c7e198 编写于 作者: 李光春's avatar 李光春

- 增加请求门面

上级 59987bcf
......@@ -23,6 +23,7 @@ use think\Facade;
* 日期门面
* Class Dates
* @see \DtApp\ThinkLibrary\Date
* @package DtApp\ThinkLibrary\facade
* @package think\facade
* @mixin helper
*/
......
......@@ -23,6 +23,7 @@ use think\Facade;
* 文件门面
* Class Files
* @see \DtApp\ThinkLibrary\helper\Files
* @package DtApp\ThinkLibrary\facade
* @package think\facade
* @mixin helper
*
......
......@@ -23,6 +23,7 @@ use think\Facade;
* 数字门面
* Class Ints
* @see \DtApp\ThinkLibrary\helper\Ints
* @package DtApp\ThinkLibrary\Ints
* @package think\facade
* @mixin helper
*
......
......@@ -23,6 +23,7 @@ use think\facade;
* 验证门面
* Class Pregs
* @see \DtApp\ThinkLibrary\helper\Pregs
* @package DtApp\ThinkLibrary\Pregs
* @package think\facade
* @mixin helper
*
......
......@@ -22,7 +22,8 @@ use think\facade;
/**
* 随机门面
* Class Randoms
* @see \DtApp\ThinkLibrary\Random
* @see \DtApp\ThinkLibrary\Randoms
* @package DtApp\ThinkLibrary\Randoms
* @package think\facade
* @mixin helper
*
......
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\facade;
use DtApp\ThinkLibrary\helper\Requests as helper;
use think\Facade;
/**
* 请求门面
* Class Requests
* @see \DtApp\ThinkLibrary\helper\Requests
* @package DtApp\ThinkLibrary\facade
* @package think\facade
* @mixin helper
*
* @method helper isEmpty(array $data, array $arr) array|bool 判断输入的参数
* @method helper isEmptyRet(array $data, array $arr) array 判断输入的参数为空就返回Json错误
* @method helper isGet() bool 判断是否为GET方式
* @method helper isPost() bool 判断是否为POST方式
* @method helper isPut() bool 判断是否为PUT方式
* @method helper isDelete() bool 判断是否为DELETE方式
* @method helper isAjax() bool 判断是否为Ajax方式
* @method helper getWebsiteAddress() bool 获取域名地址
*/
class Requests extends Facade
{
/**
* 获取当前Facade对应类名(或者已经绑定的容器对象标识)
* @access protected
* @return string
*/
public static function getFacadeClass()
{
return helper::class;
}
}
......@@ -23,6 +23,7 @@ use think\Facade;
* 返回门面
* Class Returns
* @see \DtApp\ThinkLibrary\helper\Returns
* @package DtApp\ThinkLibrary\Returns
* @package think\facade
* @mixin helper
*
......
......@@ -22,7 +22,8 @@ use think\facade;
/**
* 字符串门面
* Class Strings
* @see \DtApp\ThinkLibrary\Str
* @see \DtApp\ThinkLibrary\Strings
* @package DtApp\ThinkLibrary\Strings
* @package think\facade
* @mixin helper
*
......
......@@ -23,6 +23,7 @@ use think\Facade;
* 时间门面
* Class Times
* @see \DtApp\ThinkLibrary\helper\Times
* @package DtApp\ThinkLibrary\Times
* @package think\facade
* @mixin helper
*
......
......@@ -22,7 +22,8 @@ use think\Facade;
/**
* 唯一ID门面
* Class UnIqIds
* @see \DtApp\ThinkLibrary\UnIqId
* @see \DtApp\ThinkLibrary\UnIqIds
* @package DtApp\ThinkLibrary\UnIqIds
* @package think\facade
* @mixin helper
*
......
......@@ -23,6 +23,7 @@ use think\Facade;
* 网址门面
* Class Urls
* @see \DtApp\ThinkLibrary\Urls
* @package DtApp\ThinkLibrary\Urls
* @package think\facade
* @mixin helper
*
......
......@@ -23,6 +23,7 @@ use think\Facade;
* XML门面
* Class Xmls
* @see \DtApp\ThinkLibrary\helper\Xmls
* @package DtApp\ThinkLibrary\Xmls
* @package think\facade
* @mixin helper
*
......
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\helper;
/**
* 请求管理类
* Class Requests
* @package DtApp\ThinkLibrary\helper
*/
class Requests
{
/**
* 判断输入的参数
* @param array $data
* @param array $arr
* @return array|bool
*/
public function isEmpty(array $data, array $arr)
{
foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) return false;
return $data;
}
/**
* 判断输入的参数为空就返回Json错误
* @param array $data
* @param array $arr
* @return array
*/
public function isEmptyRet(array $data, array $arr)
{
foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) \DtApp\ThinkLibrary\facade\Returns::jsonError('请检查参数', 102);
return $data;
}
/**
* 判断是否为GET方式
* @return bool
*/
public function isGet()
{
return request()->isGet();
}
/**
* 判断是否为POST方式
* @return bool
*/
public function isPost()
{
return request()->isPost();
}
/**
* 判断是否为PUT方式
* @return boolean
*/
public function isPut()
{
return request()->isPut();
}
/**
* 判断是否为DELETE方式
* @return boolean
*/
public function isDelete()
{
return request()->isDelete();
}
/**
* 判断是否为Ajax方式
* @return bool
*/
public function isAjax()
{
return request()->isAjax();
}
/**
* 获取域名地址
* @return string
*/
public function getWebsiteAddress()
{
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
return $http_type . $_SERVER['HTTP_HOST'] . "/";
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册