<?php
// +----------------------------------------------------------------------
// | 底层父类控制器
// +----------------------------------------------------------------------
// | Copyright (c) 2018 https://blog.junphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小黄牛 <1731223728@qq.com>
// +----------------------------------------------------------------------

namespace app\controller\SuperClass;
use x\Controller;

class Reception extends Controller
{

    /**
     * 输出Json到页面
     * @todo 无
     * @author 小黄牛
     * @version v1.1.5 + 2020.07.14
     * @deprecated 暂不启用
     * @global 无
     * @param string $code
     * @param string $msg
     * @param array $data
     * @return void
    */
    public function returnJson($code, $msg='Success', $data=[]) {
        $json = json_encode([
            'code' => "{$code}",
            'msg' => $msg,
            'data' => $data,
        ], JSON_UNESCAPED_UNICODE);
        $this->fetch($json);
        // 返回false，是为了兼容各种where判断中断操作
        return false;
    }

    /**
     * 输出Json到Table
     * @todo 无
     * @author 小黄牛
     * @version v1.1.5 + 2020.07.14
     * @deprecated 暂不启用
     * @global 无
     * @param array $rows
     * @param int $total
     * @return void
    */
    public function returnTable($rows, $total) {
        $json = json_encode([
            'rows' => $rows,
            'total' => $total,
        ], JSON_UNESCAPED_UNICODE);
        return $this->fetch($json);
    }
}