代码初始化
This commit is contained in:
20
extend/Yzh/Model/Custom/CustomRequest.php
Normal file
20
extend/Yzh/Model/Custom/CustomRequest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Custom;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/*
|
||||
* 自定义请求
|
||||
*/
|
||||
class CustomRequest extends BaseRequest
|
||||
{
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
extend/Yzh/Model/Custom/CustomResponse.php
Normal file
47
extend/Yzh/Model/Custom/CustomResponse.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Custom;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 自定义返回
|
||||
*/
|
||||
class CustomResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var Object $customer_data 响应 data 数据
|
||||
*/
|
||||
protected $customer_data;
|
||||
|
||||
/**
|
||||
* 写入 data 数据
|
||||
* @param $data
|
||||
* @return $this|ResponseInterface
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* data 数据解析
|
||||
* @param $response
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomerData($response) {
|
||||
$class = get_class($response);
|
||||
$this->customer_data = new $class($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应 data 数据
|
||||
* @return Object
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->customer_data;
|
||||
}
|
||||
}
|
||||
13
extend/Yzh/Model/Custom/CustomResponseData.php
Normal file
13
extend/Yzh/Model/Custom/CustomResponseData.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Custom;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 自定义响应 data 数据
|
||||
*/
|
||||
class CustomResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user