<?php
namespace app\index\controller;


/**
 * 分组类
 */
class Groups extends Common
{


    /**
     * 分组
     *
     * @access public
     * @return array JsonString
     */
    public function index()
    {
        // 验证token.
        $tokenStatus = $this->verifyApiToken();
        $code        = -2;
        $msg         = '错误';
        if ($tokenStatus === false) {
            $msg = 'token错误';
            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
        }

        try {
            $groupsWhere['status'] = 1;
            // 获取符合条件数据.
            $groups = model('Groups')->select($groupsWhere);

            return json(['code' => 1, 'data' => $groups, 'msg' => '成功']);
        } catch (\Exception $e) {
            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
        }

    }//end index()


}
