BaseController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * BaseController.php UTF-8
  4. * 百度信息流对接
  5. *
  6. * @date : 2018/7/6 11:46
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : ouzhongfu <ozf@huosdk.com>
  10. * @version : HUOSDK 7.2
  11. */
  12. namespace api\promotion\controller\v8;
  13. use Think\Config;
  14. use think\Controller;
  15. use think\Db;
  16. use Think\Log;
  17. use think\exception\HttpResponseException;
  18. use think\Response;
  19. use think\Session;
  20. class BaseController extends Controller {
  21. function _initialize() {
  22. parent::_initialize();
  23. }
  24. public static function hs_api_responce($code = 200, $msg = '', $data = array(), $type = "json") {
  25. if (empty($data)) {
  26. $data = null;
  27. }
  28. $rdata = array(
  29. 'code' => $code,
  30. 'msg' => $msg,
  31. 'data' => $data
  32. );
  33. $response = Response::create($rdata, $type)->code(200);
  34. if ($code >= 300) {
  35. throw new HttpResponseException($response);
  36. } else {
  37. return $response;
  38. }
  39. }
  40. }