/**
* @Desc : 查询数据 获取id列 并返回随机id
* @Date : 2022/9/20 15:07
* @author: 张三
*/
public function getKey()
{
$model = new \app\common\model\MjExpert(); //实例化
$expert_model = $model->where('status', 1)->column('id'); //取一列
$rndKey = array_rand($expert_model); //随机返回id
return json([
'code' => 1,
'msg' => 'Success !',
'data' => $expert_model[$rndKey]
], 200);
}