dever %!s(int64=4) %!d(string=hai) anos
pai
achega
9391b264fe
Modificáronse 2 ficheiros con 77 adicións e 1 borrados
  1. 33 1
      app/community/database/info.php
  2. 44 0
      app/community/src/Api.php

+ 33 - 1
app/community/database/info.php

@@ -6,6 +6,8 @@ $table = array
 	1 => '合集',
 	2 => '合集章节',
 	3 => '合集内容',
+	20 => '主信息',
+	21 => '子信息',
 );
 
 $table_name = array
@@ -13,6 +15,8 @@ $table_name = array
 	1 => 'collection/info',
 	2 => 'collection/page',
 	3 => 'collection/content',
+	20 => 'community/info',
+	21 => 'community/info',
 );
 
 $cate = function()
@@ -131,6 +135,17 @@ return array
 			'list'		=> true,
 		),
 
+		'num_oppose'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '反对数',
+			'default' 	=> '0',
+			'desc' 		=> '反对数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			'list'		=> true,
+		),
+
 		'num_comment'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -211,9 +226,26 @@ return array
 				'state' => 1,
 			),
 			'type' => 'all',
-			'order' => array('cdate' => 'desc'),
+			'order' => array('id' => 'desc'),
 			'page' => array($page, 'list'),
 			'col' => '*',
 		),
+
+		'getHot' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'cate_id' => 'yes',
+				'type' => array('yes', 'in'),
+				'type_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('num_comment' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1',
+			'col' => '*',
+		),
 	)
 );

+ 44 - 0
app/community/src/Api.php

@@ -35,6 +35,44 @@ class Api
         return $data;
     }
 
+    # 获取社区下的热门帖子
+    public function hot()
+    {
+    	# 获取分类下的帖子
+    	$where['cate_id'] = Dever::input('cate_id');
+        $where['type'] = Dever::input('type', 3);
+        $where['type_id'] = Dever::input('type_id', 1);
+        $data['info'] = Dever::db('community/info')->getHot($where);
+    	if ($data['info']) {
+    		foreach ($data['info'] as $k => $v) {
+    			$data['info'][$k] = $this->one($v);
+    		}
+    	}
+
+        return $data;
+    }
+
+    # 发布信息
+    public function add()
+    {
+    	$data['uid'] = 1;
+    	$data['content'] = Dever::input('content');
+    	if (!$data['content']) {
+    		Dever::alert('请填写内容');
+    	}
+    	$data['pic'] = Dever::input('pic');
+    	$data['cate_id'] = Dever::input('cate_id');
+    	$data['type'] = Dever::input('type');
+    	$data['type_id'] = Dever::input('type_id');
+    	if (!$data['cate_id'] || !$data['type'] || !$data['type_id']) {
+    		Dever::alert('错误的信息');
+    	}
+
+    	Dever::db('community/info')->insert($data);
+
+    	return 'yes';
+    }
+
     private function one($info)
     {
     	$info['pic'] = explode(',', $info['pic']);
@@ -44,9 +82,15 @@ class Api
     	# 点赞数
     	$info['num_up'] = $info['num_up'] + 0;
 
+    	# 反对数
+    	$info['num_oppose'] = $info['num_oppose'] + 0;
+
     	# 是否点赞
     	$info['is_up'] = false;
 
+    	# 是否反对
+    	$info['is_oppose'] = false;
+
     	# 评论数
     	$info['num_comment'] = $info['num_comment'] + 0;