| 
				
			 | 
			
			
				
				@@ -7,13 +7,17 @@ 
			 | 
		
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				
				 namespace {{ sp_namespace.as_it }}; 
			 | 
		
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				10
			 | 
			
				
			 | 
			
			
				
				-use Luticate\Utils\LuSpModel; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				
				+use Luticate\Utils\LuSpDbo; 
			 | 
		
		
	
		
			
			| 
				11
			 | 
			
				11
			 | 
			
			
				
				 use Luticate\Utils\LuMultipleDbo; 
			 | 
		
		
	
		
			
			| 
				12
			 | 
			
				12
			 | 
			
			
				
				 use Luticate\Utils\LuStringUtils; 
			 | 
		
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				
				 use Illuminate\Support\Facades\DB; 
			 | 
		
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				15
			 | 
			
				
			 | 
			
			
				
				-class {{ sp.sp_name.camel_upper }} extends LuSpModel { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				15
			 | 
			
			
				
				+class {{ sp.sp_name.camel_upper }} extends LuSpDbo { 
			 | 
		
		
	
		
			
			| 
				16
			 | 
			
				16
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				17
			 | 
			
			
				
				+    /** 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				18
			 | 
			
			
				
				+    * @param $dam 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				
				+    * @return \{{ sp_namespace.as_it }}\{{ sp.sp_name.camel_upper }}|null 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				
				+    */ 
			 | 
		
		
	
		
			
			| 
				17
			 | 
			
				21
			 | 
			
			
				
				     protected static function damToDbo($dam) 
			 | 
		
		
	
		
			
			| 
				18
			 | 
			
				22
			 | 
			
			
				
				     { 
			 | 
		
		
	
		
			
			| 
				19
			 | 
			
				23
			 | 
			
			
				
				         if (is_null($dam)) 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -21,7 +25,7 @@ class {{ sp.sp_name.camel_upper }} extends LuSpModel { 
			 | 
		
		
	
		
			
			| 
				21
			 | 
			
				25
			 | 
			
			
				
				         $dbo = new {{ sp.sp_name.camel_upper }}(); 
			 | 
		
		
	
		
			
			| 
				22
			 | 
			
				26
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				23
			 | 
			
				27
			 | 
			
			
				
				 {% for arg in args.out %} 
			 | 
		
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				
				-        $dbo->set{{ arg.name.camel_upper }}($dam->{{ arg.name.as_it }}); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				
				+        $dbo->set{{ arg.name.camel_upper }}(LuStringUtils::convertJsonString($dam->{{ arg.name.as_it }})); 
			 | 
		
		
	
		
			
			| 
				25
			 | 
			
				29
			 | 
			
			
				
				 {% endfor %} 
			 | 
		
		
	
		
			
			| 
				26
			 | 
			
				30
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				27
			 | 
			
				31
			 | 
			
			
				
				         return $dbo; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -30,9 +34,15 @@ class {{ sp.sp_name.camel_upper }} extends LuSpModel { 
			 | 
		
		
	
		
			
			| 
				30
			 | 
			
				34
			 | 
			
			
				
				 {% set spcall %}{{ sp.sp_name.as_it }}({% for arg in args.in %}:{{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %}){% endset %} 
			 | 
		
		
	
		
			
			| 
				31
			 | 
			
				35
			 | 
			
			
				
				 {% set argsarray %}{% for arg in args.in %}":{{ arg.name.as_it }}" => ${{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %}{% endset %} 
			 | 
		
		
	
		
			
			| 
				32
			 | 
			
				36
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				
				+    /** 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				
				+{% for arg in args.in %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				
				+    * @param ${{ arg.name.as_it }} {{ arg.data_type.php.as_it }} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				
				+{% endfor %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				
				+    * @return \{{ sp_namespace.as_it }}\{{ sp.sp_name.camel_upper }}{% if sp.proretset %}[]{% endif %}; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				
				+    */ 
			 | 
		
		
	
		
			
			| 
				33
			 | 
			
				43
			 | 
			
			
				
				     public static function execute({% for arg in args.in %}${{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %}) 
			 | 
		
		
	
		
			
			| 
				34
			 | 
			
				44
			 | 
			
			
				
				     { 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				
				-        $values = DB::select('SELECT * FROM {{ spcall }}', array({{ argsarray }})); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				
				+        $values = DB::select('SELECT {% for arg in args.out %}to_json(data.{{ arg.name.as_it }}) AS {{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %} FROM {{ spcall }} data', array({{ argsarray }})); 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				46
			 | 
			
			
				
				 {% if sp.proretset %} 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				47
			 | 
			
			
				
				         $dboValues = array(); 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				48
			 | 
			
			
				
				         foreach ($values as $value) 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -44,6 +54,14 @@ class {{ sp.sp_name.camel_upper }} extends LuSpModel { 
			 | 
		
		
	
		
			
			| 
				44
			 | 
			
				54
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				45
			 | 
			
				55
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				46
			 | 
			
				56
			 | 
			
			
				
				 {% if sp.proretset %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				
				+    /** 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				
				+{% for arg in args.in %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				
				+    * @param ${{ arg.name.as_it }} {{ arg.data_type.php.as_it }} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				
				+{% endfor %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				
				+    * @param $page int The page number, 0 based 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				
				+    * @param $perPage int The number of items per page 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				
				+    * @return \Luticate\Utils\LuMultipleDbo; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				
				+    */ 
			 | 
		
		
	
		
			
			| 
				47
			 | 
			
				65
			 | 
			
			
				
				     public static function getMultipleJson({% for arg in args.in %}${{ arg.name.as_it }}, {% endfor %}$page, $perPage) 
			 | 
		
		
	
		
			
			| 
				48
			 | 
			
				66
			 | 
			
			
				
				     { 
			 | 
		
		
	
		
			
			| 
				49
			 | 
			
				67
			 | 
			
			
				
				         $values = DB::select('SELECT (SELECT count(*) FROM {{ spcall }}) as count, (SELECT json_agg(q) FROM (SELECT * FROM {{ spcall }} OFFSET (:page::int * :perPage::int) LIMIT :perPage) q) as data', 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -58,6 +76,38 @@ class {{ sp.sp_name.camel_upper }} extends LuSpModel { 
			 | 
		
		
	
		
			
			| 
				58
			 | 
			
				76
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				59
			 | 
			
				77
			 | 
			
			
				
				 {% endif %} 
			 | 
		
		
	
		
			
			| 
				60
			 | 
			
				78
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				
				+    public function jsonSerialize() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				
				+    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				
				+        return array( 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				
				+{% for arg in args.out %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				
				+            "{{ arg.name.camel_upper }}" => $this->_{{ arg.name.camel_lower }}{{ loop.last ? "" : "," }} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				
				+{% endfor %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				
				+        ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				
				+    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				
				+    public static function jsonDeserialize($json) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				
				+    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				
				+        $dbo = new {{ sp.sp_name.camel_upper }}(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				
				+{% for arg in args.out %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				
				+        if (isset($json["{{ arg.name.camel_upper }}"])) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				
				+            $dbo->set{{ arg.name.camel_upper }}($json["{{ arg.name.camel_upper }}"]); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				
				+{% endfor %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				
				+        return $dbo; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				
				+    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				
				+    public static function generateSample() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				
				+    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				
				+        $dbo = new {{ sp.sp_name.camel_upper }}(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				
				+{% for arg in args.out %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				
				+        $dbo->set{{ arg.name.camel_upper }}({% if arg.data_type.php.as_it == "double" %}42.42{% 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				
				+elseif arg.data_type.php.as_it == "integer" %}42{% 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				
				+elseif arg.data_type.php.as_it == "boolean" %}true{% 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				
				+else %}"sample string"{% endif %}); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				
				+{% endfor %} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				
				+        return $dbo; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				
				+    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				61
			 | 
			
				111
			 | 
			
			
				
				 {% for arg in args.out %} 
			 | 
		
		
	
		
			
			| 
				62
			 | 
			
				112
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				63
			 | 
			
				113
			 | 
			
			
				
				     /** 
			 |