0,'delete_time'=>0])->select(); $count = $notices->count(); $res = []; if($count){ $res = ['code'=>0,'msg'=>'','count'=>$count]; foreach($notices as $msg){ $res['data'][] = ['id'=>$msg['id'],'type'=>$msg['type'],'title'=>$msg['title'],'user_id'=>$msg['user_id'],'content'=>$msg['content'],'ctime'=>$msg['create_time']]; } } else { $res = ['code'=>-1,'msg'=>'还没有发布任何通知']; } return json($res); } return View::fetch(); } //添加消息 public function add() { $sendId = Session::get('admin_id'); var_dump($sendId); $data = Request::only(['type','title','receve_id','content']); if($data['type'] == 1){ $receveId = $data['receve_id']; //个人通知 } else { $receveId = 0; //系统通知 } unset($data['receve_id']); //收信人移除 $data['user_id'] = $sendId; //发信人入信息库 //写入信息库 $result = Message::sendMsg($sendId,$receveId,$data); if($result){ $res = ['code'=>0,'msg'=>'发布成功']; } else { $res = ['code'=>0,'msg'=>'发布失败']; } return json($res); } //编辑VIP积分规则 public function edit() { $id = input('id'); if(Request::isAjax()){ $data = Request::only(['id','title','type','content']); $result = MessageModel::update($data); if($result){ $res = ['code'=>0,'msg'=>'编辑成功']; }else{ $res = ['code'=>-1,'msg'=>'编辑失败']; } return json($res); } $msg = Db::name('message')->find($id); View::assign(['msg'=>$msg]); return View::fetch(); } //删除消息 public function delete($id) { if(Request::isAjax()){ $msg = MessageModel::find($id); $result = $msg->delete(); if($result){ return json(['code'=>0,'msg'=>'删除成功']); }else{ return json(['code'=>-1,'msg'=>'删除失败']); } } } }