Ejemplo n.º 1
0
 /**
  * 助力数据
  * GET api/activity/xmas/{xmasId}/vote 
  */
 public function actionRestlist()
 {
     $this->checkRestAuth();
     $xmas = Xmas::model()->findByPk($_GET['xmasId']);
     if ($xmas == null || $xmas->nickname == null) {
         $this->sendResponse(404, 'not found');
     }
     $criteria = new CDbCriteria();
     $take = 100;
     $criteria->compare('xmas_id', $xmas->id);
     $criteria->limit = $take;
     $criteria->offset = 0;
     $criteria->order = 'created_time DESC';
     $result = XmasVote::model()->findAll($criteria);
     $json = new JsonData();
     $json->limit = $take;
     $json->total = (int) XmasVote::model()->count($criteria);
     $json->result = $this->JSONArrayMapper($result);
     echo CJSON::encode($json);
 }
Ejemplo n.º 2
0
 public function actionRestupdate()
 {
     $this->checkRestAuth();
     //判断是否全部填写
     if (!isset($_POST['subOpenId']) || !isset($_POST['headimgurl']) || !isset($_POST['nickname'])) {
         return $this->sendResponse(400, 'missed required properties');
     }
     // 查询是否已经生成
     $xmas = Xmas::model()->findByPk($_GET['xmasId']);
     if ($xmas == null) {
         return $this->sendResponse(404, 'not found');
     }
     $xmas->sub_open_id = $_POST['subOpenId'];
     $xmas->headimgurl = $_POST['headimgurl'];
     $xmas->nickname = $_POST['nickname'];
     if (!$xmas->save()) {
         return $this->sendResponse(500, 'faild to save xmas');
     }
     echo CJSON::encode($this->JSONMapper($xmas));
 }