作者 liyuhang

gx

1 <?php 1 <?php
2 use Illuminate\Support\Facades\Log; 2 use Illuminate\Support\Facades\Log;
3 3
  4 +define('HTTP_OPENAI_URL','http://openai.waimaoq.com');
4 5
5 if(!function_exists('http_post')){ 6 if(!function_exists('http_post')){
6 /** 7 /**
@@ -117,7 +117,7 @@ class BaseController extends Controller @@ -117,7 +117,7 @@ class BaseController extends Controller
117 $result = [ 117 $result = [
118 'msg' => $msg == ' ' ? $code->description : $msg, 118 'msg' => $msg == ' ' ? $code->description : $msg,
119 'code' => $code->value, 119 'code' => $code->value,
120 - 'data' => $data, 120 + 'data' => $this->_extents($data),
121 ]; 121 ];
122 $this->header['Content-Type'] = $type; 122 $this->header['Content-Type'] = $type;
123 $this->header['token'] = $this->token; 123 $this->header['token'] = $this->token;
@@ -144,5 +144,26 @@ class BaseController extends Controller @@ -144,5 +144,26 @@ class BaseController extends Controller
144 return $new_arr ? $new_arr : false; 144 return $new_arr ? $new_arr : false;
145 } 145 }
146 146
  147 + protected function _extents($data) {
147 148
  149 + if (empty($data) || !is_array($data)) {
  150 + return empty($data) ? is_array($data) ? [] : '' : $data;
  151 + }
  152 + foreach ($data as $k => $v) {
  153 + if (is_array($v)) {
  154 + $data[$k] = $this->_extents($v);
  155 + } else {
  156 + if (is_null($v)) {
  157 + $data[$k] = '';
  158 + continue;
  159 + }
  160 + switch ((string) $k) {
  161 + case 'image':
  162 + $v['image_link'] = file_get_contents($v);
  163 + break;
  164 + }
  165 + }
  166 + }
  167 + return $data;
  168 + }
148 } 169 }
@@ -81,11 +81,11 @@ class UserLogic extends BaseLogic @@ -81,11 +81,11 @@ class UserLogic extends BaseLogic
81 * @method 81 * @method
82 */ 82 */
83 public function user_info(){ 83 public function user_info(){
84 - $rs = $this->model->read($this->param);  
85 - if($rs === false){ 84 + $info = $this->model->read($this->param);
  85 + if($info === false){
86 $this->fail('error',Code::USER_ERROR); 86 $this->fail('error',Code::USER_ERROR);
87 } 87 }
88 - return $this->success(); 88 + return $this->success($info);
89 } 89 }
90 90
91 /** 91 /**