public function LoadPage()
 {
     //删除自动转义增加的\
     $PostStr = stripslashes($_POST['data']);
     $req = json_decode($PostStr);
     $searchFilter = null;
     if ("" != $req->user_name) {
         $keyword = '%' . $req->user_name . '%';
         $searchFilter['user_name'] = array('like', $keyword);
     }
     $condition['company_id'] = CompanyEnum::GROUP_COMPANY;
     $condition['user_type_id'] = UserTypeEnum::SUPER_ADMIN;
     $roleList = MispCommonDataService::GetRoleID($condition);
     $searchFilter['role_id'] = array('in', $roleList);
     $this->LogInfo("LoadPage, searchFilter is " . json_encode($searchFilter));
     $order['user_id'] = 'desc';
     $this->LoadPageTable($this->GetModel(), $searchFilter, $order);
 }
 public function Login()
 {
     $Req = $this->GetReqObj();
     $req = $this->GetCommonData();
     $reqType = $this->GetReqType();
     $this->LogInfo("User login, Client type is " . $reqType);
     $user['user_name'] = $req->user_name;
     $user['password'] = $req->password;
     if ($reqType == ClientTypeEnum::IOS || $reqType == ClientTypeEnum::ANDROID) {
         //APP客户端登陆验证
         $data = null;
         $user['company_id'] = $Req->app_id;
         $this->LogInfo("Login client type is " . $reqType . ",company_id is " . $Req->app_id);
         //验证用户与登录密码
         try {
             $orignalUser = MispCommonUserService::LoginValidate($user);
         } catch (FuegoException $e) {
             $this->errorCode = $e->getCode();
             return $this->ReturnJson();
         }
         //获取用户APP登录权限
         $privilegeResult = MispCommonDataService::GetRolePrivilege($orignalUser, PrivilegeEnum::ACCESS_TYPE_LOGIN, PrivilegeEnum::ACCESS_VALUE_APP_LOGIN);
         if (false == $privilegeResult) {
             //用户不存在APP登录权限
             $this->LogWarn("Get role privilege failed.The user don't have APP login privilege, login failed.");
             $this->errorCode = MispErrorCode::USERNAME_OR_PASSWORD_WRONG;
             return $this->ReturnJson();
         } else {
             //获取登录权限成功
             $this->LogInfo("Get user login privilege success. The user have APP login privilege.");
             //判断是否已经在其他设备登录
             $condition['user_id'] = $orignalUser['user_id'];
             $tokenDao = MispDaoContext::Token();
             $tokenCount = $tokenDao->where($condition)->count();
             $this->LogInfo("Token count is " . $tokenCount);
             if ($tokenCount > 0) {
                 //用户已在其他设备登录,删除已有token
                 $this->LogInfo("The user has login in other device, user name is " . $orignalUser['user_name']);
                 try {
                     $result = MispCommonService::Delete($tokenDao, $condition);
                     $this->LogInfo("Delete orginal token success.");
                 } catch (FuegoException $e) {
                     $this->LogWarn("Delete orginal token failed.");
                     $this->LogWarn("Customer APPLogin failed");
                     $this->errorCode = MispErrorCode::ERROR_LOGIN_FAILED;
                     $this->ReturnJson();
                     return;
                 }
             }
             //APP登录成功
             $data = MispServiceContext::UserManage()->AppLogin($orignalUser);
         }
         $this->ReturnJson($data);
     }
     if ($reqType == ClientTypeEnum::WEB) {
         //WEB端登陆验证
         //验证用户与登录密码
         try {
             $orignalUser = MispCommonUserService::LoginValidate($user);
         } catch (FuegoException $e) {
             $this->errorCode = $e->getCode();
             return $this->ReturnJson();
         }
         $privilegeResult = MispCommonDataService::GetRolePrivilege($orignalUser, PrivilegeEnum::ACCESS_TYPE_LOGIN, PrivilegeEnum::ACCESS_VALUE_WEB_LOGIN);
         if (false == $privilegeResult) {
             //用户不存在WEB登录权限
             $this->LogWarn("Get role privilege failed. The user don't have WEB login privilege, login failed.");
             $this->errorCode = MispErrorCode::USERNAME_OR_PASSWORD_WRONG;
         } else {
             //WEB登录成功
             $this->LogInfo("Get user login privilege success. The user have WEB login privilege.");
             $this->errorCode = MispServiceContext::UserManage()->WebLogin($orignalUser);
         }
     }
     $this->ReturnJson();
 }