public function actionAddBook() { $customer_id = $this->getParam('customer_id'); $title = $this->getParam('title'); $content = $this->getParam('content'); $book = new HiBook(); $book['title'] = $title; $book['content'] = $content; $book['customer_id'] = $customer_id; $book['insert_time'] = date('Y-m-d H:i:s', time()); $book->insert(); EchoUtility::echoMsgTF(true, '添加段子', $book); }
public function actionAddNewAnswer() { $newAnswer = $this->getParam("new_answer"); $customer_id = $this->getParam("customer_id"); $question_id = $this->getParam("question_id"); $answer = new HiQuestionAnswer(); $answer['content'] = $newAnswer; $answer['customer_id'] = $customer_id; $answer['question_id'] = $question_id; $answer['insert_date'] = date('Y-m-d'); $result = $answer->insert(); EchoUtility::echoMsgTF($result, '回答问题', $answer); }
public function actionGetHomeData() { $result = array(); $story_c = new CDbCriteria(); $story_c->addCondition('follow_count != 0'); $story_c->order = 'follow_count DESC'; $stories = Converter::convertModelToArray(HiStory::model()->with('customer')->findAll($story_c)); $result['story'] = $stories[0]; $article = Converter::convertModelToArray(HiPushArticle::model()->findByPk(Yii::app()->time_service->getIndex())); $result['article'] = $article; $question = Converter::convertModelToArray(HiQuestion::model()->findByPk(2)); $question['cover_image'] = 'http://77fkpo.com5.z0.glb.clouddn.com/603b2cffffeb7c5c950a4c9517e8ee9e.jpg'; $result['question'] = $question; $book = Converter::convertModelToArray(HiBook::model()->with('customer')->findByPk(1)); $result['book'] = $book; EchoUtility::echoMsgTF(true, '获取首页数据', $result); }
public function actionAddComment() { $section_id = $this->getParam('section_id'); $story_id = $this->getParam('story_id'); $customer_id = $this->getParam('customer_id'); $content = $this->getParam('content'); $orig_customer_id = $this->getParam('orig_customer_id'); $newComment = new HiStoryComment(); $newComment['customer_id'] = $customer_id; if (isset($section_id)) { $newComment['section_id'] = $section_id; } if (isset($story_id)) { $newComment['story_id'] = $story_id; } $newComment['orig_customer_id'] = $orig_customer_id; $newComment['content'] = $content; $newComment['insert_time'] = date('Y-m-d H:i:s', time()); $newComment->insert(); $comment = Converter::convertModelToArray(HiStoryComment::model()->with('customer')->findByPk($newComment->getPrimaryKey())); EchoUtility::echoMsgTF(1, '插入评论', $comment); }
public function actionGetMyComment() { $orig_customer_id = $this->getParam("customer_id"); $c = new CDbCriteria(); $c->addCondition('sc.orig_customer_id = ' . $orig_customer_id); $c->group = 'sc.story_id'; $comments = Converter::convertModelToArray(HiStoryComment::model()->with('story', 'customer')->findAll($c)); EchoUtility::echoMsgTF(true, '获取评论', $comments); }
public function actionGetArticleList() { $start = $this->getParam('start'); $num = $this->getParam('num'); $sql = 'select * from `hi_push_article`' . ' where article_id <=' . Yii::app()->time_service->getIndex() . ' order by article_id DESC limit ' . $start . ',' . $num; $connection = Yii::app()->db; $command = $connection->createCommand($sql); $articles = $command->queryAll(); $result = array(); if (count($articles) < $num) { $result['has_more'] = false; } else { $result['has_more'] = true; } $result['article_list'] = $articles; $result['success'] = true; EchoUtility::echoMsgTF(1, '获取文章列表', $result); }
public function actionGetStoryList() { $start = $this->getParam('start'); $num = $this->getParam('num'); $c = new CDbCriteria(); $c->offset = $start; $c->limit = $num; $stories = Converter::convertModelToArray(HiStory::model()->with('customer')->findAll($c)); $result = array(); if (count($stories) < $num) { $result['has_more'] = false; } else { $result['has_more'] = true; } $result['story_list'] = $stories; $result['success'] = true; EchoUtility::echoMsgTF(1, '获取段子列表', $result); }