Exemplo n.º 1
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         $recommendQueue = RecommendQueue::find()->andWhere(['type' => 'diary'])->andWhere(['sid' => $this->id])->one();
         if (empty($recommendQueue)) {
             $recommendQueue = new RecommendQueue();
         }
         $recommendQueue->type = 'diary';
         $recommendQueue->sid = $this->id;
         $recommendQueue->save();
     }
 }
Exemplo n.º 2
0
 /**
  * Deletes an existing Album model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     try {
         $this->findModel($id)->delete();
         Photo::deleteAll('album_id = :album_id', [':album_id' => $id]);
         RecommendQueue::deleteAlbumById($id);
     } catch (\Exception $exp) {
         echo Json::encode(['statusCode' => '300', 'message' => $exp->getMessage(), 'navTabId' => 'photo_album_index_id', 'forwardUrl' => '', 'callbackType' => '']);
         exit;
     }
     echo Json::encode(['statusCode' => '200', 'message' => '操作成功', 'navTabId' => 'photo_album_index_id', 'forwardUrl' => '', 'callbackType' => '']);
     exit;
 }
Exemplo n.º 3
0
 public static function deleteAlbumById($albumId)
 {
     $recommendQueue = RecommendQueue::find()->andWhere(['type' => 'photo'])->andWhere(['sid' => $albumId])->one();
     $recommendQueue->delete();
 }
Exemplo n.º 4
0
 /**
  * Deletes an existing Diary model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     DiaryContent::deleteAll('diary_id = :diary_id', [':diary_id' => $id]);
     DiaryComment::deleteAll('diary_id = :diary_id', [':diary_id' => $id]);
     // 推荐队列
     RecommendQueue::deleteDiaryById($id);
     $result = ['statusCode' => '200', 'message' => '操作成功', 'navTabId' => 'diary_diary_index_id', 'forwardUrl' => '', 'callbackType' => ''];
     echo Json::encode($result);
 }