You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpLuGetAllUserSettings.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * AUTO GENERATED BY LUTICATE GENERATOR
  4. * ANY CHANGES WILL BE OVERWRITTEN
  5. */
  6. namespace Luticate\Auth\DataAccess\SP;
  7. use Luticate\Utils\LuSpDbo;
  8. use Luticate\Utils\LuMultipleDbo;
  9. use Luticate\Utils\LuStringUtils;
  10. use Illuminate\Support\Facades\DB;
  11. class SpLuGetAllUserSettings extends LuSpDbo {
  12. /**
  13. * @param $dam
  14. * @return \Luticate\Auth\DataAccess\SP\SpLuGetAllUserSettings|null
  15. */
  16. protected static function damToDbo($dam)
  17. {
  18. if (is_null($dam))
  19. return null;
  20. $dbo = new SpLuGetAllUserSettings();
  21. $dbo->setSettings(LuStringUtils::convertJsonString($dam->_settings));
  22. return $dbo;
  23. }
  24. /**
  25. * @param $_user_id integer
  26. * @return \Luticate\Auth\DataAccess\SP\SpLuGetAllUserSettings[];
  27. */
  28. public static function execute($_user_id)
  29. {
  30. $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));
  31. $dboValues = array();
  32. foreach ($values as $value)
  33. $dboValues[] = self::damToDbo($value);
  34. return $dboValues;
  35. }
  36. /**
  37. * @param $_user_id integer
  38. * @param $page int The page number, 0 based
  39. * @param $perPage int The number of items per page
  40. * @return \Luticate\Utils\LuMultipleDbo;
  41. */
  42. public static function getMultipleJson($_user_id, $page, $perPage)
  43. {
  44. $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',
  45. array(":_user_id" => $_user_id, ":page" => $page, ":perPage" => $perPage));
  46. $value = $values[0];
  47. if (is_null($value->data))
  48. {
  49. $value->data = '[]';
  50. }
  51. $data = LuStringUtils::convertJsonString($value->data);
  52. return new LuMultipleDbo($value->count, $data);
  53. }
  54. public function jsonSerialize()
  55. {
  56. return array(
  57. "Settings" => $this->_Settings
  58. );
  59. }
  60. public static function jsonDeserialize($json)
  61. {
  62. $dbo = new SpLuGetAllUserSettings();
  63. if (isset($json["Settings"])) {
  64. $dbo->setSettings($json["Settings"]);
  65. }
  66. return $dbo;
  67. }
  68. public static function generateSample()
  69. {
  70. $dbo = new SpLuGetAllUserSettings();
  71. $dbo->setSettings("sample string");
  72. return $dbo;
  73. }
  74. /**
  75. * @var json
  76. */
  77. protected $_Settings;
  78. public function getSettings()
  79. {
  80. return $this->_Settings;
  81. }
  82. public function setSettings($value)
  83. {
  84. $this->_Settings = $value;
  85. }
  86. }