ListController.class.php 1013 Bytes
<?php
/**
 * Created by PhpStorm.
 * User: zhonglei
 * Date: 2018/3/26
 * Time: 11:41
 */

namespace Apicp\Controller\Dict;

use Common\Service\DictService;

class ListController extends AbstractController
{
    /**
     * List
     * @author zhonglei
     * @desc 字典列表
     * @param String key 字典Key
     * @return array
     *          array(
     *              'list' => array( // 字典列表
     *                  'dict_id' => 1, // 字典ID
     *                  'key' => 'course_teacher_title', // 字典Key(teacher_title=讲师头衔;teacher_task_type=讲师授课任务类型)
     *                  'value' => '金牌讲师', // 字典值
     *              )
     *          )
     */
    public function Index_post()
    {
        $key = I('post.key');

        if (empty($key)) {
            E('_ERR_DICT_KEY_EMPTY');
        }

        $dictServ = new DictService();
        $list = $dictServ->list_by_conds(['key' => $key]);
        $this->_result['list'] = $list;
    }
}