|
@@ -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;
|
|
|
|