getData('banner_list', 'json'); if (empty($list)) { $list = Banner::where('show', '1')->select(['id', 'image', 'title'])->orderBy('sort', 'desc')->get(); foreach ($list as $value){ $value->{'image'}='http://'.env('APP_HOST_API').$value->{'image'}; } RedisDataServer::creatServer()->setData('banner_list', $list->toArray(), 'json'); } return $this->apiResponseSuccess('获取成功', $list); } /** * 获取公告列表 * @return \Illuminate\Http\JsonResponse */ function notice() { $list = RedisDataServer::creatServer()->getData('notice_list', 'json'); if (empty($list)) { $list = Notice::where('show', '1')->select(['id', 'title', 'new', 'created_at','content'])->orderBy('sort', 'desc')->get(); $m_id = request()->member['id']; foreach ($list as $value) { $value->{'created_date'} = Carbon::parse($value->{'created_at'}, config('app.timezone'))->format('Y-m-d H:i'); $value['is_read'] = $value->getIsRead($m_id); } RedisDataServer::creatServer()->setData('notice_list', $list->toArray(), 'json'); } return $this->apiResponseSuccess('获取成功', $list); } /** * 获取公告详情 * @return \Illuminate\Http\JsonResponse */ function noticeDetails() { $id = request()->get('id', '1'); if (empty($id)) { return $this->apiResponseError('缺少必要参数'); } $info = Notice::where('show', '1')->where('id', $id)->select(['id', 'title', 'new', 'created_at', 'content'])->first(); if (empty($info)) { return $this->apiResponseError('信息不存在'); } $m_id = request()->member['id']; $info->setRead($m_id); $info->{'created_date'} = Carbon::parse($info->{'created_at'}, config('app.timezone'))->format('Y-m-d H:i'); return $this->apiResponseSuccess('获取信息成功', $info); } /** * 获取关于我们 */ function getAboutUs(){ $info=CommonServer::creatServer()->getConfigValue('about_us'); return $this->apiResponseSuccess('获取数据成功',['info'=>$info]); } /** * 添加留言 * @return \Illuminate\Http\JsonResponse */ function addMsg(){ $content=CommonServer::creatServer()->filtrationStr('content',''); if(empty($content)){ return $this->apiResponseError('请输入留言内容'); } $m_id = request()->member['id']; $nickname = Member::where('id',$m_id)->value('nickname'); $msg=Message::create([ 'm_id' => $m_id, 'username' => $nickname, 'content' => $content, 'reply' => '', 'show' => '1', ]); if(empty($msg)){ return $this->apiResponseError('留言失败'); }else{ return $this->apiResponseSuccess('留言成功',$msg); } } /** * 获取留言列表 * @return \Illuminate\Http\JsonResponse */ function getMsgList(){ $m_id = request()->member['id']; $list=Message::where('m_id',$m_id)->where('show',1)->paginate(20); return $this->apiResponseSuccess('',['total'=>$list->total(),'items'=>$list->items()]); } }