Ejemplo n.º 1
0
 public function actionView($id)
 {
     $user_id = $_GET['user_id'];
     $query = Yii::$app->db->createCommand('select * from {{%user_follow}} where user_id=' . $id . ' and people_id=' . $user_id)->queryOne();
     if (!empty($query)) {
         Yii::$app->db->createCommand("delete from {{%user_follow}} where user_id=" . $id . " and people_id=" . $user_id)->execute();
         Yii::$app->db->createCommand("UPDATE {{%user_data}} SET following_count=following_count-1 WHERE user_id=" . $id)->execute();
         Yii::$app->db->createCommand("UPDATE {{%user_data}} SET follower_count=follower_count-1 WHERE user_id=" . $user_id)->execute();
         Response::show(200, '取消关注');
     } else {
         Yii::$app->db->createCommand("insert into {{%user_follow}} (user_id,people_id) VALUES ({$id},{$user_id})")->execute();
         Yii::$app->db->createCommand("UPDATE {{%user_data}} SET following_count=following_count+1 WHERE user_id=" . $id)->execute();
         Yii::$app->db->createCommand("UPDATE {{%user_data}} SET follower_count=follower_count+1 WHERE user_id=" . $user_id)->execute();
         $cid = Yii::$app->db->createCommand('select cid from {{%user}} where id=' . $user_id)->queryOne();
         if (!empty($cid['cid'])) {
             $title = "有人关注您为好友";
             $msg = "有人关注您为好友";
             $date = time();
             $icon = 'http://13loveme.com:82/images/app_push/u=3453872033,2552982116&fm=21&gp=0.png';
             $extras = json_encode(array('push_title' => urlencode($title), 'push_content' => urlencode($msg), 'push_type' => 'SSCOMM_FANS'));
             Yii::$app->db->createCommand("insert into {{%app_push}} (type,status,cid,title,msg,extras,platform,response,icon,created_at,updated_at) values('SSCOMM_FANS',2,'{$cid['cid']}','{$title}','{$msg}','{$extras}','all','NULL','{$icon}',{$date},{$date})")->execute();
         }
         Response::show(202, '关注成功');
     }
 }
Ejemplo n.º 2
0
 public function actionDelete($id)
 {
     $model = new $this->modelClass();
     $thread_id = $_GET['thread_id'];
     if ($this->findModel($id)->delete()) {
         $model->PostCuntDel($thread_id);
         Response::show('202', '删除成功');
     }
 }
Ejemplo n.º 3
0
 public function actionUpdate($id)
 {
     $model = $this->findModels($id);
     $model->load(Yii::$app->getRequest()->getBodyParams(), '');
     if (!$model->save()) {
         return array_values($model->getFirstErrors())[0];
     }
     Response::show(202, '更新成功');
 }
Ejemplo n.º 4
0
 public function actionCreate()
 {
     $model = new $this->modelClass();
     $model->load(Yii::$app->getRequest()->getBodyParams(), '');
     if (!$model->save()) {
         return array_values($model->getFirstErrors())[0];
     }
     Response::show('202', '保存成功');
 }
Ejemplo n.º 5
0
 public function actionDelete($id)
 {
     if (isset($_GET['cid'])) {
         if ($this->findModel($id, $_GET['cid'])->delete()) {
             Response::show('202', '删除成功');
         }
     } else {
         if ($this->findModelDAll($id)->deleteAll(['cid' => $id])) {
             Response::show('202', '删除成功');
         }
     }
 }
Ejemplo n.º 6
0
 public function actionView($id)
 {
     $user_id = $_GET['user_id'];
     $query = Yii::$app->db->createCommand("select * from {{%user_notes}} WHERE thread_id=" . $id . " and note_by=" . $user_id)->execute();
     if (empty($query)) {
         Yii::$app->db->createCommand("UPDATE {{%forum_thread}} SET note=note+1 WHERE id=" . $id)->execute();
         Yii::$app->db->createCommand("insert into {{%user_notes}} (note_by,note_at,thread_id) values ({$user_id}," . time() . ",{$id})")->execute();
         $query_one = Yii::$app->db->createCommand("select * from {{%forum_thread}} WHERE id=" . $id)->queryOne();
         Response::show(202, '点赞成功', $query_one['note']);
     } else {
         $query_one = Yii::$app->db->createCommand("select * from {{%forum_thread}} WHERE id=" . $id)->queryOne();
         Response::show(402, '已经存在', $query_one['note']);
     }
 }
Ejemplo n.º 7
0
 public function actionDelete($id)
 {
     if ($this->findModel($id)->delete()) {
         Response::show('202', '删除成功');
     }
 }
Ejemplo n.º 8
0
 public function actionDelete($id)
 {
     /*return $this->findModel($id)->delete();*/
     Response::show(401, '不允许的操作');
 }
Ejemplo n.º 9
0
 public function actionDelete($id)
 {
     Response::show(401, '不允许的操作');
 }