objMAnnouncement = new MAnnouncement($this->onlineEnterpriseId); } /** * 公告添加 * @throws \Exception */ public function addAnnouncement() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $data = [ 'title' => isset($params['title']) ? $params['title'] : '', 'content' => isset($params['content']) ? $params['content'] : '', 'status' => isset($params['status']) ? $params['status'] : '', 'type' => isset($params['type']) ? $params['type'] : '', 'upStatus' => isset($params['upStatus']) ? $params['upStatus'] : '', ]; foreach($data as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $result = $this->objMAnnouncement ->addAnnouncement($data); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 公告删除 */ public function delAnnouncement() { $params = $this->request->param('request_id'); if(!$params) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMAnnouncement->delAnnouncement($params); if($result->isSuccess()){ $this->sendOutput($result->getData()); }else{ $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 公告弹框 */ public function upAnnouncement() { $params = $this->request->param('request_id'); if(!$params) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $where['id'] = $params; $result = $this->objMAnnouncement->upAnnouncement($where); if($result->isSuccess()){ $this->sendOutput($result->getData()); }else{ $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 公告编辑 */ public function editAnnouncement() { $id = $this->request->param('request_id'); if(empty($id)){ $this->sendOutput('id参数错误', ErrorCode::$paramError); } $params = $this->request->getRawJson(); $data = [ 'title' => isset($params['title']) ? $params['title'] : '', 'content' => isset($params['content']) ? $params['content'] : '', 'status' => isset($params['status']) ? $params['status'] : '', 'type' => isset($params['type']) ? $params['type'] : '', 'upStatus' => isset($params['upStatus']) ? $params['upStatus'] : '', ]; foreach($data as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $result = $this->objMAnnouncement->editAnnouncement($data, $id); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 公告启用/禁用 */ public function onAnnouncement() { $id = $this->request->param('request_id'); if(!$id){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMAnnouncement->onAnnouncement($id); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 公告列表 */ public function getAllAnnouncement() { $params = $this->request->getRawJson(); if( empty($params) ){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $pageParams = pageToOffset($params['page']?:1, $params['pageSize']?:10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['type']) && !empty($params['type'])){ $selectParams['type'] = $params['type']; } $result = $this->objMAnnouncement->getAllAnnouncement($selectParams); if(!$result->isSuccess()){ parent::sendOutput($result->getData(), $result->getErrorCode()); } $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } /** * 公告详情 */ public function getAnnouncementInfo() { $id = $this->request->param('request_id'); if(empty($id)){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $where['id'] = $id; $result = $this->objMAnnouncement->getAnnouncementInfo($where); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 弹窗公告详情 */ public function getupStatusAnnouncementInfo() { $where['type'] = StatusCode::$delete; $where['upStatus'] = StatusCode::$standard; $result = $this->objMAnnouncement->getAnnouncementInfo($where); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } }