insert([ "text"=>$post['content'], "imgs"=>$post['imgs'], "userid"=>$userid, "createtime"=>time(), "click"=>0 ]); Db::name("student")->inc("article_count",1)->where("id",$userid)->update(); return show("发布成功!",SUCCESS_CODE,[]); } public function delete(){ $userid = $GLOBALS['data']['userid']; if(empty($userid)){ return show("请登录后操作!",NEED_LOGIN); } $article_id = $GLOBALS['data']['data']["article_id"]; if(empty($article_id)){ return show("请上输入动态ID"); } $info = Db::name("app_article")->where("id",$article_id)->find(); if(empty($info) || $info['userid']!=$userid){ return show("找不到该动态信息!"); } Db::name("app_article")->where("id",$article_id)->delete(); return show("删除成功!",SUCCESS_CODE,[]); } public function lists(){ $userid = $GLOBALS['data']['userid']; if(empty($userid)){ return show("请登录后操作!",NEED_LOGIN); } $lastIndex = empty($GLOBALS['data']['data']["lastindex"])?0:$GLOBALS['data']['data']["lastindex"]; if($lastIndex == 0){ $where = "userid={$userid} and id>0"; }else{ $where = "userid={$userid} and id<".$lastIndex; } $result["lastIndex"] = 0; $list = Db::name("app_article")->where($where)->order("id desc")->order('id desc')->limit(env("page_count"))->select()->toArray(); foreach($list as $vo){ $result['lastIndex'] = $vo['id']; $result["list"][] = $vo; } if(count($list)where("id",$article_id)->find(); if(empty($info)) return show("找不到该动态信息!"); return show(SUCCESS_MESSAGE,SUCCESS_CODE,$info); } public function getlists(){ $userid = $GLOBALS['data']['userid']; if(empty($userid)){ return show("请登录后操作!"); } if(empty($GLOBALS['data']['data']['student_userid'])){ return show("请输入用户ID!"); } $student_userid = $GLOBALS['data']['data']['student_userid']; $student = Db::name("student")->field("id")->where("id",$student_userid)->find(); if(empty($student)) return show("找不到用户信息!"); $lastIndex = empty($GLOBALS['data']['data']["lastindex"])?0:$GLOBALS['data']['data']["lastindex"]; if($lastIndex == 0){ $where = "userid={$student_userid} and id>0"; }else{ $where = "userid={$student_userid} and id<".$lastIndex; } $result["lastIndex"] = 0; $list = Db::name("app_article")->where($where)->order("id desc")->order('id desc')->limit(env("page_count"))->select()->toArray(); foreach($list as $vo){ $result['lastIndex'] = $vo['id']; $result["list"][] = $vo; } if(count($list)