コード例 #1
0
 /**
  * 检查专题栏目引用
  * @param $appId
  * @param $local
  * @throws DeepInException
  */
 protected function checkAppsListReferred($appId, $local)
 {
     $appListItem = ShopAppsList::whereRaw("appid=:appid", array(":appid" => $appId))->get();
     $data = array();
     foreach ($appListItem as $v) {
         if ($v instanceof ShopAppsList) {
             if (isset($data[$v->listType()])) {
                 $data[$v->listType()] = array();
             }
             $data[$v->listType()][] = $v->itemId();
         }
     }
     $locals = array();
     if (isset($data[1])) {
         //栏目
         $colnumList = ShopColumn::whereRaw("columnid in (:columnid)", array(":columnid" => implode(",", $data[1])))->get();
         foreach ($colnumList as $v) {
             if ($v instanceof ShopColumn) {
                 $locals[] = $v->local();
             }
         }
     }
     if (in_array($local, $locals)) {
         throw new DeepInException("无法取消,在栏目里面引用到该应用了。");
     }
     if (isset($data[2])) {
         //专题
         $topicList = ShopTopic::whereRaw("topicid=:topicid", array(":topicid" => implode(",", $data[2])))->get();
         foreach ($topicList as $v) {
             if ($v instanceof ShopTopic) {
                 $locals[] = $v->local();
             }
         }
     }
     if (in_array($local, $locals)) {
         throw new DeepInException("无法取消,在专题里面引用到该应用了。");
     }
 }
コード例 #2
0
 /**
  * 选择应用
  * @return \Illuminate\Http\JsonResponse
  * @throws DeepInException
  * @throws DeepInHtmlException
  */
 public function select()
 {
     $listType = intval(\Input::get("listtype", 0));
     //类型
     $itemId = intval(\Input::get("itemid", 0));
     //类型下面对应的id
     $appId = intval(\Input::get("appid", 0));
     //选在的appid
     if ($listType < 1 || $itemId < 0) {
         throw new DeepInException("参数错误~!");
     }
     if ($appId < 1) {
         throw new DeepInException("请选择应用~!");
     }
     //判断应用是否存在
     $app = ShopApps::find($appId);
     if (!$app instanceof ShopApps) {
         throw new DeepInException("选择的应用不存在~!");
     }
     $appLocals = $app->localList()->getResults();
     if ($listType == 1) {
         //栏目
         $colunmn = ShopColumn::find($itemId);
         if (!$colunmn instanceof ShopColumn) {
             throw new DeepInException("专题不存在");
         }
         $local = $colunmn->local();
     } else {
         $topic = ShopTopic::find($itemId);
         if (!$topic instanceof ShopTopic) {
             throw new DeepInException("专题不存在~!");
         }
         $local = $topic->local();
     }
     $isFindLocal = false;
     foreach ($appLocals as $item) {
         if ($item instanceof ShopAppsLocal) {
             if (strcmp($local, $item->local()) === 0) {
                 $isFindLocal = true;
             }
         }
     }
     if ($isFindLocal == false) {
         throw new DeepInException("区域不对~!");
     }
     //        print_r($appLocals);
     //        exit;
     //判断listtype和itemid是否正确
     if ($this->checkAppList($listType, $itemId) == false) {
         throw new DeepInException("listType和itemId参数非法~!");
     }
     $parent = $this->getApplistParent($listType, $itemId);
     if ($parent == null) {
         throw new DeepInException("找不到对应的数据~!");
     }
     $canLocal = $parent->local();
     //只查询该地区下面的应用列表
     if ($this->appHasLocal($appId, $canLocal) == false) {
         throw new DeepInException("应用" . $app->appName() . "不属于" . $canLocal . "地区");
     }
     //创建一行数据加入到数据库中
     $appList = new ShopAppsList();
     $appList->listType($listType);
     $appList->itemId($itemId);
     $appList->appId($appId);
     $appList->pos(0);
     if ($appList->save() == false) {
         throw new DeepInException("新增数据错误~!");
     }
     $appList->pos($appList->id());
     $appList->save();
     //保存位置信息,如果知道不报错。
     return $this->successJSON(array("id" => $appList->id()));
 }
コード例 #3
0
 /**
  * 删除栏目
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  * @throws DeepInException
  * @throws \Exception
  */
 public function delete($id)
 {
     try {
         $column = $this->find($id);
     } catch (DeepInException $e) {
         throw new DeepInHtmlException($e->getMessage());
     }
     if ($column->inuse() == 1) {
         throw new DeepInHtmlException("栏目属于上线状态,无法删除~!");
     }
     //删除其选择的应用列表
     ShopAppsList::whereRaw("listtype=1 and itemid=:itemid", array(":itemid" => $column->columnId()))->delete();
     if ($column->delete() == false) {
         throw new DeepInHtmlException("数据删除失败~!");
     }
     return $this->success("删除成功~!");
 }
コード例 #4
0
 /**
  * 按照listType和itemId获取响应的应用列表
  * @param $type
  * @param $itemId
  * @return array
  */
 protected function findByTypeAndItem($type, $itemId)
 {
     $list = ShopAppsList::whereRaw("`listtype`=:listtype and `itemid`=:itemid", array(":listtype" => $type, ":itemid" => $itemId))->orderBy("pos", "asc")->get();
     return $list;
 }
コード例 #5
0
 /**
  * 删除数据
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  * @throws DeepInException
  * @throws \Exception
  */
 public function delete($id)
 {
     try {
         $topic = $this->find($id);
     } catch (DeepInException $e) {
         throw new DeepInHtmlException($e->getMessage());
     }
     if ($topic->inuse() == 1) {
         throw new DeepInHtmlException("专题属于上线状态,无法删除~!");
     }
     //删除其选择的应用列表
     ShopAppsList::whereRaw("listtype=2 and itemid=:itemid", array(":itemid" => $topic->topicId()))->delete();
     //删除对应的背景图片数据
     ShopTopicBanner::whereRaw("topicid=:topicid", array(":topicid" => $topic->topicId()))->delete();
     if ($topic->delete() == false) {
         throw new DeepInHtmlException("删除失败~!");
     }
     return $this->success("删除成功~!");
 }