12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /**
- * Common.php UTF-8
- *
- *
- * @date : 2021/5/6 09:49
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HUOSDK-IDENTITY 1.0
- */
- namespace huoIdentify\controller;
- use huolib\status\IdentifyStatus;
- class Common {
- /**
- * 返回错误信息
- *
- * @param int $code
- * @param string $msg
- * @param array $data
- *
- * @return array
- */
- public function huoError($code = 400, $msg = '', $data = []) {
- return $this->huoSuccess($code, $msg, $data);
- }
- /**
- * 逻辑处理返回信息
- *
- * @param int $code
- * @param string $msg
- * @param array $data
- *
- * @return array
- */
- public function huoSuccess($code = IdentifyStatus::NO_ERROR, $msg = '', $data = []) {
- $_rdata['code'] = $code;
- $_rdata['msg'] = $msg;
- $_rdata['data'] = $data;
- return $_rdata;
- }
- /**
- * @param array $data
- *
- * @return array
- */
- public function huoReturn($data) {
- return $this->huoSuccess($data['code'], $data['msg'], $data['data']);
- }
- /**
- * @param int $code
- * @param array $data
- *
- * @return array
- */
- protected function retSucMsg($code = IdentifyStatus::NO_ERROR, $data = []) {
- $_msg = IdentifyStatus::getMsg($code);
- return $this->huoSuccess($code, $_msg, $data);
- }
- /**
- * @param $code
- *
- * @return mixed
- */
- protected function retErrMsg($code) {
- $_err_msg = IdentifyStatus::getMsg($code);
- return $this->huoError($code, $_err_msg);
- }
- }
|