Skip to content

Commit

Permalink
新增sdk添加请求头入参
Browse files Browse the repository at this point in the history
  • Loading branch information
zq committed Jun 29, 2020
1 parent f405c36 commit 7967067
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Parsers/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ private function sdkText()
$text .= '// 并创建release版本, 调用方执行composer update完成更新'.$this->crlf;
$text .= '// SDK项目地址 https://github.com/uniondrug/service-sdk'.$this->crlf;
$text .= '$body = [];'.$this->crlf;
$text .= '$response = $this->serviceSdk->'.lcfirst($this->collection->sdkPath).'->'.$this->collection->sdk.'->'.lcfirst($this->annotation->sdkName).'($body);'.$this->crlf;
$text .= '$query = null;//Query数据'.$this->crlf;
$text .= '$extra = null;//请求头信息'.$this->crlf;
$text .= '$response = $this->serviceSdk->'.lcfirst($this->collection->sdkPath).'->'.$this->collection->sdk.'->'.lcfirst($this->annotation->sdkName).'($body, $query, $extra);'.$this->crlf;
$text .= '```';
$text .= $this->eol;
}
Expand All @@ -260,8 +262,10 @@ private function sdkText()
$text .= '// 该用法需要你知道域名前缀及路径路径, 同时不便于后期维护'.$this->crlf;
$text .= '// 一经修改将有大量项目及文件(调用方)同步修改'.$this->crlf;
$text .= '$body = [];'.$this->crlf;
$text .= '$query = null;//Query数据'.$this->crlf;
$text .= '$extra = null;//请求头信息'.$this->crlf;
$text .= '$response = $this->serviceSdk->'.strtolower($this->annotation->method);
$text .= '("'.$host.'", $body);'.$this->crlf;
$text .= '("'.$host.'", $body, $query, $extra);'.$this->crlf;
$text .= '```'.$this->eol;
// 2.3
$text .= '*结果处理*'.$this->eol;
Expand Down
6 changes: 4 additions & 2 deletions src/Parsers/Sdkx.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ private function renderMethod(array $datas)
* {{TITLE}}{{DESCRIPTION}}
* @link {{LINKTO}}
* @param array $body 入参类型
* @param null $query Query数据
* @param null $extra 请求头信息
* @return ResponseInterface
*/
public function {{FUNCTION}}($body)
public function {{FUNCTION}}($body, $query = null, $extra = null)
{
return $this->restful("{{METHOD}}", "{{PATH}}", $body);
return $this->restful("{{METHOD}}", "{{PATH}}", $body, $query, $extra);
}
TEMP;
foreach ($datas as $key => $value) {
Expand Down

0 comments on commit 7967067

Please sign in to comment.