1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Http\Controllers;
- use App\Error;
- use Illuminate\Foundation\Bus\DispatchesJobs;
- use Illuminate\Routing\Controller as BaseController;
- use Illuminate\Foundation\Validation\ValidatesRequests;
- use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
- class Controller extends BaseController
- {
- public $suiteId;
- public $appTemplateId;
- public $corpid;
- public $suiteSecret;
- /*
- * 初始化
- * */
- public function __construct()
- {
- $component = config('qyWechat.suite_info');
- $this->suiteId = $component['suite_id'];
- $this->appTemplateId = $component['app_template_id'];
- $this->corpid = $component['corpid'];
- $this->suiteSecret = $component['suite_secret'];
- $this->appTemplateSecret = $component['app_template_secret'];
- }
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
- public static function returnValue($data = [], $errorNo = 0, $errorSuffix = '') {
- return [
- "rst" => $data,
- "errno" => $errorNo . '',
- "err" => empty($errorSuffix) ? Error::getError($errorNo) : $errorSuffix,
- "timestamp" => intval(microtime(true)) . '',
- // 客户端代码版本号,用于客户端自动加载新提交的代码
- 'v' => (string) get_client_code_version(),
- "auno" => '0'
- ];
- }
- /**
- * 统一分页响应格式
- * @param $data
- * @param $total
- * @param $pageSize
- * @param int $page
- * @param null $extra
- * @return array
- */
- public static function returnPageValue($data, $total, $pageSize, $page, $extra = null)
- {
- $pages = $pageSize > 0 ? ceil($total / $pageSize) : 0;
- $result = [
- 'data' => $data,
- 'pageInfo' => [
- 'total' => $total,
- 'pages' => $pages,
- 'size' => $pageSize,
- 'page' => $page
- ]
- ];
- if( $extra !== null){
- $result['extra'] = $extra;
- }
- return self::returnValue($result);
- }
- }
|