123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
-
- /**
- * AUTO GENERATED BY LUTICATE GENERATOR
- * ANY CHANGES WILL BE OVERWRITTEN
- */
-
- namespace Luticate\Auth\DataAccess\SP;
-
- use Luticate\Utils\LuSpDbo;
- use Luticate\Utils\LuMultipleDbo;
- use Luticate\Utils\LuStringUtils;
- use Illuminate\Support\Facades\DB;
-
- class SpLuGetAllUserSettings extends LuSpDbo {
-
- /**
- * @param $dam
- * @return \Luticate\Auth\DataAccess\SP\SpLuGetAllUserSettings|null
- */
- protected static function damToDbo($dam)
- {
- if (is_null($dam))
- return null;
- $dbo = new SpLuGetAllUserSettings();
-
- $dbo->setSettings(LuStringUtils::convertJsonString($dam->_settings));
-
- return $dbo;
- }
-
-
- /**
- * @param $_user_id integer
- * @return \Luticate\Auth\DataAccess\SP\SpLuGetAllUserSettings[];
- */
- public static function execute($_user_id)
- {
- $values = DB::select('SELECT to_json(data._settings) AS _settings FROM sp_lu_get_all_user_settings(:_user_id) data', array(":_user_id" => $_user_id));
- $dboValues = array();
- foreach ($values as $value)
- $dboValues[] = self::damToDbo($value);
- return $dboValues;
- }
-
- /**
- * @param $_user_id integer
- * @param $page int The page number, 0 based
- * @param $perPage int The number of items per page
- * @return \Luticate\Utils\LuMultipleDbo;
- */
- public static function getMultipleJson($_user_id, $page, $perPage)
- {
- $values = DB::select('SELECT (SELECT count(*) FROM sp_lu_get_all_user_settings(:_user_id)) as count, (SELECT json_agg(q) FROM (SELECT * FROM sp_lu_get_all_user_settings(:_user_id) OFFSET (:page::int * :perPage::int) LIMIT :perPage) q) as data',
- array(":_user_id" => $_user_id, ":page" => $page, ":perPage" => $perPage));
- $value = $values[0];
- if (is_null($value->data))
- {
- $value->data = '[]';
- }
- $data = LuStringUtils::convertJsonString($value->data);
- return new LuMultipleDbo($value->count, $data);
- }
-
- public function jsonSerialize()
- {
- return array(
- "Settings" => $this->_Settings
- );
- }
-
- public static function jsonDeserialize($json)
- {
- $dbo = new SpLuGetAllUserSettings();
- if (isset($json["Settings"])) {
- $dbo->setSettings($json["Settings"]);
- }
- return $dbo;
- }
-
- public static function generateSample()
- {
- $dbo = new SpLuGetAllUserSettings();
- $dbo->setSettings("sample string");
- return $dbo;
- }
-
-
- /**
- * @var json
- */
- protected $_Settings;
- public function getSettings()
- {
- return $this->_Settings;
- }
- public function setSettings($value)
- {
- $this->_Settings = $value;
- }
- }
|