noticeRepository = $noticeRepository; } public function getLists($where, $page_num = '') { $lists = $this->noticeRepository->getNotices($where, $page_num); if ($lists->toArray()) { foreach ($lists as $k => $v) { $lists[$k]->origin_title = $v->title; $style_font = ''; $style_color =''; if ($v->tit_b == 1) { $style_font = "font-weight:bold;"; } if ($v->tit_color) { $style_color = 'color:'.$v->tit_color.';'; } if ($style_font || $style_color) { $lists[$k]->title = "".$v->title.""; } if ($v->is_url) { $lists[$k]->url = $v->is_url; } else { $lists[$k]->url = route('notice.show', array('id'=>$v->id)); } } } return $lists; } public function getNotice($where) { $notice_info = $this->noticeRepository->getNotice($where); if (!$notice_info) { return null; } $notice_info->prev = 0; $notice_info->next = 0; $map[] = array('is_display','=','1'); //$map[] = array('type_id','=',$notice_info->type_id); $lists = $this->getLists($map); if ($lists->isNotEmpty()) { $info_key = -1; foreach ($lists as $k => $v) { if ($v->id==$notice_info->id) { $info_key = $k; } } $pre_info = array(); $nex_info = array(); if ($info_key>-1 && !empty($lists[$info_key-1])) { $prev = $lists[$info_key-1]; if ($prev) { $notice_info->prev = 1; $notice_info->prev_title = $prev->origin_title; $notice_info->prev_url = route('notice.show', ['id'=>$prev->id]); } } if ($info_key>-1 && !empty($lists[$info_key+1])) { $next = $lists[$info_key+1]; if ($next) { $notice_info->next = 1; $notice_info->next_title = $next->origin_title; $notice_info->next_url = route('notice.show', ['id'=>$next->id]); } } } return $notice_info; } public function incrementData($where, $num, $filed) { return $this->noticeRepository->incrementData($where, $num, $filed); } public function getNotices($params) { $where = array( array('is_display','=',1) ); if (array_has($params, 'type_id')) { $where[] = array('type_id','=',$params['type_id']); } $limit = ''; if (array_has($params, 'size')) { $limit = $params['size']; } $order = array('sort'=>'desc','created_at'=>'desc'); $rst = $this->noticeRepository->getLimitNotices($where, $order, $limit); if ($rst->isNotEmpty() && array_has($params, 'titlelen')) { $dot = '...'; if (array_has($params, 'dot')) { $dot = $params['dot']; } foreach ($rst as $k => $v) { $rst[$k]->dot_title = cut_str($v->title, $params['titlelen'], 0, $dot); } } return $rst; } }