/**
  * 选择应用
  * @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()));
 }