dever 6 vuotta sitten
vanhempi
commit
9565f68bd3
2 muutettua tiedostoa jossa 30 lisäystä ja 2 poistoa
  1. 17 0
      database/info.php
  2. 13 2
      src/Api.php

+ 17 - 0
database/info.php

@@ -243,4 +243,21 @@ return array
 			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 		),
 	),
+
+	'request' => array
+	(
+		# 获取最新一条的用户信息
+		'getOne' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'product_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'one',
+			'order' => array('page_number' => 'desc'),
+			'col' => 'page_number',
+		),
+	)
 );

+ 13 - 2
src/Api.php

@@ -25,12 +25,23 @@ class Api
 			$user['status'] = 2;
 			$user['id'] = Dever::db('survey/user')->insert($user);
 		}
-		$user['question_total'] = Dever::db('survey/info')->total(array('product_id' => $product_id));
 
-		$result['user'] = $user;
 		if ($page_number > 0) {
 			$user['index'] = $page_number;
 		}
+
+		//$user['question_total'] = Dever::db('survey/info')->total(array('product_id' => $product_id));
+		$user['page'] = $user['index'];
+		$page = Dever::db('survey/info')->getOne(array('product_id' => $product_id));
+		if ($page) {
+			$user['page_total'] = $page['page_number'];
+		} else {
+			$user['page_total'] = 0;
+		}
+		
+
+		$result['user'] = $user;
+
 		$result['info'] = Dever::db('survey/info')->state(array('product_id' => $product_id, 'page_number' => $user['index']));
 
 		if ($result['info']) {