fetch(); } /** * 线下课列表获取 * @return * */ public function offline_list() { $where = parent::getMore([ ['page', 1], ['is_show', ''], ['limit', 20], ['title', ''], ]); return JsonService::successlayui(OfflineCourseModel::getList($where)); } /**添加/编辑 * @param int $id * @return mixed|void * @throws \think\exception\DbException */ public function create($id = 0) { if ($id) { $lecturer = OfflineCourseModel::get($id); $lecturer['label'] = json_decode($lecturer['label']); $lecturer['introduction'] = htmlspecialchars_decode($lecturer['introduction']); if (!$lecturer) return JsonService::fail('线下课信息不存在!'); } else { $lecturer = []; } $this->assign(['lecturer' => json_encode($lecturer), 'id' => $id]); return $this->fetch(); } /** * 删除线下课 * @param int $id 修改的主键 * @return json * */ public function delete($id = 0) { if (!$id) return JsonService::fail('缺少参数'); if (OfflineCourseModel::delLecturer($id)) return JsonService::successful('删除成功'); else return JsonService::fail(OfflineCourseModel::getErrorInfo('删除失败')); } }