dever 6 years ago
parent
commit
d4287d752a
4 changed files with 77 additions and 5 deletions
  1. 37 0
      act/database/feedback.php
  2. 7 1
      act/lib/Feedback.php
  3. 15 2
      doc/apidoc.php
  4. 18 2
      main/src/User.php

+ 37 - 0
act/database/feedback.php

@@ -3,6 +3,17 @@
 $page = 10;
 $table = Dever::config('base')->type;
 
+$type = function()
+{
+	$array = array();
+	$info = Dever::db('act/feedback_type')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
 return array
 (
 	# 表名
@@ -56,6 +67,32 @@ return array
 			//'list'		=> true,
 		),
 
+		'type_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '反馈类型',
+			'default' 	=> '1',
+			'desc' 		=> '反馈类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'contact' 		=> array
+		(
+			'type' 		=> 'varchar-200',
+			'name' 		=> '联系方式',
+			'default' 	=> '',
+			'desc' 		=> '联系方式',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'list'		=> 'Dever::load("act/lib/manage.load", "{type}", {data_id})',
+			//'list'		=> true,
+			'list'		=> true,
+		),
+
 		'name' 		=> array
 		(
 			'type' 		=> 'varchar-200',

+ 7 - 1
act/lib/Feedback.php

@@ -7,7 +7,7 @@ use Dever;
 class Feedback
 {
     # 发表反馈
-    public function submit($uid, $username, $name, $content)
+    public function submit($uid, $username, $name, $type_id, $contact, $content)
     {
         $where['uid'] = $uid;
         $where['username'] = $username;
@@ -16,8 +16,14 @@ class Feedback
         $table = 'act/feedback';
         $info = Dever::db($table)->one($where);
         if (!$info) {
+            $where['type_id'] = $type_id;
+            $where['contact'] = $contact;
             $id = Dever::db($table)->insert($where);
         } else {
+            $where['where_id'] = $info['id'];
+            $where['type_id'] = $type_id;
+            $where['contact'] = $contact;
+            Dever::db($table)->update($where);
             $id = $info['id'];
         }
         Dever::score($uid, 'submit_feedback', '发表反馈');

+ 15 - 2
doc/apidoc.php

@@ -800,13 +800,26 @@
  * @apiDescription 提交反馈
  *
  * @apiParam {String} signature signature
+ * @apiParam {String} type_id 反馈类型 必填
+ * @apiParam {String} contact 联系方式 必填
  * @apiParam {String} content 反馈内容 必填
- * @apiParam {String} username 用户名 选填
- * @apiParam {String} name 反馈标题 选填
  *
  * @apiSuccess {Number}  id 当前的数据id
  */
 
+/**
+ * @api {get} wonderful/main/?l=user.get_feedback_type 获取反馈类型
+ * @apiVersion 1.0.0
+ * @apiName user.get_feedback_type
+ * @apiGroup UserAction
+ *
+ * @apiDescription 获取反馈类型
+ *
+ * @apiParam {String} signature signature
+ *
+ * @apiSuccess {Object}  type 类型
+ */
+
 /**
  * @api {get} wonderful/main/?l=journal.home 小刊首页
  * @apiVersion 1.0.0

+ 18 - 2
main/src/User.php

@@ -252,13 +252,29 @@ class User extends Core
         if (!$name) {
             //Dever::alert('错误的标题');
         }
+        $type_id = Dever::input('type_id');
+        if (!$type_id) {
+            Dever::alert('请选择反馈类型');
+        }
+        $contact = Dever::input('contact');
+        if (!$contact) {
+            Dever::alert('请填写联系方式');
+        }
         $content = Dever::input('content');
         if (!$content) {
-            Dever::alert('错误的内容');
+            Dever::alert('请填写内容');
         }
 
-        $id = Dever::load('act/lib/feedback')->submit($this->data['uid'], $username, $name, $content);
+        $id = Dever::load('act/lib/feedback')->submit($this->data['uid'], $username, $name, $type_id, $contact, $content);
 
         return array('id' => $id);
     }
+
+    # 发布反馈
+    public function get_feedback_type()
+    {
+        $this->data['type'] = Dever::db('act/feedback_type')->getAll();
+
+        return $this->data;
+    }
 }