request->param(); $where = []; if (!empty($params['title'])) { $where[] = ['title', '=', $params['title']]; } if (!empty($params['type'])) { $where[] = ['type', '=', $params['type']]; } if (!empty($params['state'])) { $where[] = ['state', '=', $params['state']]; } if (!empty($params['id'])) { $where[] = ['id', '=', $params['id']]; } $this->successWithData(apiconvertToCamelCase(Db::name('announcement')->where($where)->select()->toArray())); } public function save() { $params = $this->request->post(); $params = convertKeysCamelToSnakeRecursive($params); $params['create_time'] = getNormalDate(); Db::name('announcement')->insert($params); $this->success(); } public function update() { $params = $this->request->post(); $params = convertKeysCamelToSnakeRecursive($params); Db::name('announcement')->where([ 'id' => $params['id'] ])->update($params); $this->success(); } public function delete() { $id = $this->request->post('id'); Db::name('announcement')->delete([ 'id' => $id ]); $this->success(); } }