with('dictDatas')->find()->dictDatas; $rGroupList = [['id' => 0, 'title' => '全部', 'type' => 'all', 'count' => 2312, 'state' => 0, 'groupId' => -1]]; $total = 0; foreach ($groupList as $key => $item) { $total += $item->count; $rGroupList[($key + 1)] = ['id' => $item->dict_code, 'title' => $item->dict_label, 'type' => $item->type, 'count' => $item->count, 'state' => $item->status, 'groupId' => $item->dict_value]; } $rGroupList[0]['count'] = $total; $this->success("查询成功", null, $rGroupList); } public function delete() { $id = intval($this->request->get('id')); !($id > 0) && $this->error('参数错误'); DictDataModel::destroy($id); $this->success('删除成功'); } }