dever 4 years ago
parent
commit
d5b948a7cf

+ 1 - 0
app/collection/database/type.php

@@ -112,6 +112,7 @@ return array
             '40, "直播","content/live",159,1,' . DEVER_TIME,
 
             '50, "活动","content/act",149,1,' . DEVER_TIME,
+            '51, "朋友圈","content/moment",148,1,' . DEVER_TIME,
 
             '60, "对话","content/dialogue",139,1,' . DEVER_TIME,
 

+ 284 - 0
app/community/database/moment.php

@@ -0,0 +1,284 @@
+<?php
+$audit = Dever::config('base')->audit;
+$table = Dever::config('base')->table;
+$table_name = Dever::config('base')->table_name;
+
+return array
+(
+	# 表名
+	'name' => 'moment',
+	# 显示给用户看的名称
+	'lang' => '朋友圈管理',
+	# 是否显示在后台菜单
+	'order' => 79,
+	'set' => array
+	(
+		'table' => $table,
+		'table_name' => $table_name,
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+			//'list'		=> true,
+		),
+		
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+		'to_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '引用的信息id',
+			'default' 	=> '0',
+			'desc' 		=> '引用的信息id',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'text',
+		),
+
+		'to_uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '引用的信息所属uid',
+			'default' 	=> '0',
+			'desc' 		=> '引用的信息所属uid',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'text',
+		),
+
+		'type' 		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '所属数据源',
+			'default' 	=> '',
+			'desc' 		=> '所属数据源',
+			'match' 	=> 'option',
+			'option' 	=> $table,
+			'search'	=> 'select',
+			//'update'	=> 'select',
+			//'list'		=> true,
+		),
+		
+		'type_id' 		=> array
+		(
+			'type' 		=> 'varchar-11',
+			'name' 		=> '数据源id',
+			'default' 	=> '',
+			'desc' 		=> '数据源id',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'type_name' 		=> array
+		(
+			'type' 		=> 'varchar-200',
+			'name' 		=> '数据源标题',
+			'default' 	=> '',
+			'desc' 		=> '数据源标题',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'day'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '日期',
+            'default'   => '-1',
+            'desc'      => '日期',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+        ),
+
+		'num_up'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '点赞数',
+			'default' 	=> '0',
+			'desc' 		=> '点赞数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'num_oppose'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '反对数',
+			'default' 	=> '0',
+			'desc' 		=> '反对数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'num_comment'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '评论数',
+			'default' 	=> '0',
+			'desc' 		=> '评论数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			//'list'		=> true,
+		),
+		
+		'pic'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '图片-图片尺寸不等,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '图片',
+			'match' 	=> 'is_string',
+			'update'	=> 'images',
+			'key' 		=> '1',
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '内容',
+			'update' 	=> 'editor',
+			'key'		=> 1,
+			'default' 	=> '',
+			'desc' 		=> '请输入内容',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'modal'		=> '查看详情',
+			'list'		=> 'Dever::load("community/lib/info.content", "{id}")',
+		),
+
+		'audit'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核',
+            'default'   => '1',
+            'desc'      => '审核',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $audit,
+            //'search'  => 'select',
+            'list'        => true,
+            'edit'        => true,
+        ),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		# 索引名 => 索引id
+		//'id' => 'id,state',
+		1 => array
+		(
+			'search' => 'type,type_id,day',
+		),
+		'version' => 1,
+	),
+
+	'manage' => array
+	(
+		//'insert' => false,
+		//'edit' => false,
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'day' => 'yes',
+				'noid' => array('yes-id', '!='),
+				'audit' => 1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('num_up`-`num_oppose' => 'desc', 'id' => 'desc'),
+			'page' => array(5, 'list'),
+			'col' => '*',
+		),
+
+		'getHot' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'day' => 'yes',
+				'audit' => 1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('num_up`-`num_oppose' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1',
+			'col' => '*',
+		),
+
+		'getTotal' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'day' => 'yes',
+				'audit' => 1,
+				'state' => 1,
+			),
+			'type' => 'count',
+		),
+	)
+);

+ 155 - 0
app/community/lib/Moment.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace Community\Lib;
+
+use Dever;
+
+class Moment
+{
+	private $table = 'community/moment';
+
+    private function table($type)
+    {
+        $table = Dever::db($this->table)->config['set']['table_name'][$type];
+        return $table;
+    }
+
+    public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $total = false, $id = false, $times = false, $day = false, $collection_id = false)
+    {
+        $where['type'] = $type;
+        $where['type_id'] = $type_id;
+        if ($id > 0) {
+            $where['noid'] = $id;
+        }
+        if ($day && $day > 0) {
+            $where['day'] = $day;
+        } else {
+            $where['day'] = -1;
+        }
+        $data['info'] = Dever::db($this->table)->$method($where);
+        if ($total) {
+            if ($method == 'getAll') {
+                $data['total'] = Dever::total();
+            } else {
+                $data['total'] = Dever::db($this->table)->getTotal($where);
+            }
+        }
+        if ($data['info']) {
+            foreach ($data['info'] as $k => $v) {
+                $data['info'][$k] = $this->one($uid, $v, $times, $collection_id);
+            }
+        }
+
+        return $data;
+    }
+
+    public function content($id)
+    {
+        $info = Dever::db($this->table)->one($id);
+        $table = array();
+
+        $pic = '';
+        if ($info['pic']) {
+            $temp = explode(',', $info['pic']);
+            foreach ($temp as $k => $v) {
+                $pic .= '<img src="'.$v.'" width="150" />';
+            }
+        }
+        
+        $table['内容'] = $info['content'];
+        $table['图片'] = $pic;
+
+        return Dever::table($table);
+    }
+
+    # 发表信息
+    public function submit($uid, $id, $type, $pic, $content, $to_id, $to_uid, $day = false, $score_type = false, $score_type_id = false)
+    {
+        $where['uid'] = $uid;
+        $where['type_id'] = $id;
+        $where['type'] = $type;
+        $where['content'] = $content;
+        $table = $this->table;
+        //$info = Dever::db($table)->one($where);
+        $info = false;
+        if ($pic) {
+            $where['pic'] = $pic;
+        }
+        if ($to_id) {
+            $where['to_id'] = $to_id;
+        }
+        if ($to_uid) {
+            $where['to_uid'] = $to_uid;
+        }
+        if ($day) {
+            $where['day'] = $day;
+        }
+        $data_table = $this->table($type);
+        if (!$info) {
+            $data = Dever::db($data_table)->one($id);
+            if (isset($data['name']) && $data['name']) {
+                $where['type_name'] = $data['name'];
+            }
+            
+            Dever::db($table)->insert($where);
+
+            if ($to_uid && $to_uid != $uid) {
+                Dever::score($uid, 'reply_moment', '回复朋友圈', false, false, false, $score_type, $score_type_id);
+
+                Dever::score($to_uid, 'reply_me_moment', '被回复朋友圈', false, false, false, $score_type, $score_type_id);
+            } else {
+                Dever::score($uid, 'submit_moment', '发表朋友圈', false, false, false, $score_type, $score_type_id);
+            }
+        }
+
+        return true;
+    }
+
+    private function one($uid, $info, $times = false, $collection_id = false)
+    {
+        $info['pic'] = explode(',', $info['pic']);
+        $info['user'] = Dever::load('user/lib/info')->get($info['uid'], $collection_id, true);
+        
+        $info['cdate_string'] = Dever::load('collection/lib/times')->getDate($info['day'], $info['cdate'], $times);
+
+        # 点赞数
+        $info['num_up'] = $info['num_up'] + 0;
+
+        # 反对数
+        $info['num_oppose'] = $info['num_oppose'] + 0;
+
+        $info['is_up'] = $info['is_oppose'] = false;
+
+        if ($uid) {
+            # 是否点赞
+            $info['is_up'] = Dever::load('community/lib/up')->get($uid, $info['id'], 20);
+
+            # 是否反对
+            $info['is_oppose'] = Dever::load('community/lib/oppose')->get($uid, $info['id'], 20);
+        }
+
+        # 评论数
+        $info['num_comment'] = $info['num_comment'] + 0;
+
+        # 获取引用的数据
+        $info['to_user'] = array();
+        if ($info['to_uid']) {
+            $info['to_user'] = Dever::load('user/lib/info')->get($info['to_uid'], $collection_id, true);
+        }
+
+        # 获取热门的子信息
+        $info['child'] = array();
+        if ($info['type'] < 20) {
+            $child = $this->getData('getHot', $uid, 20, $info['id'], true, 1);
+            if ($child && $child['info']) {
+                $info['child'] = $child['info'];
+                $info['child_total'] = $child['total'];
+            }
+        }
+
+        # 获取最新的服务器时间
+        $info['server_time'] = time();
+
+        return $info;
+    }
+}

+ 36 - 1
app/community/src/Api.php

@@ -55,6 +55,14 @@ class Api extends Core
         return $data;
     }
 
+    # 获取朋友圈下的帖子
+    public function moment()
+    {
+        $id = Dever::input('info_id');
+        $data = Dever::load('community/lib/moment')->getData('getAll', $this->uid, $this->type, $this->type_id, false, $id, $this->times, $this->day, $this->id);
+        return $data;
+    }
+
     # 获取弹幕、评论
     public function comment()
     {
@@ -131,7 +139,7 @@ class Api extends Core
         return 'yes';
     }
 
-    # 发布信息
+    # 发布社区帖子信息
     public function add()
     {
         $pic = Dever::input('pic');
@@ -161,6 +169,33 @@ class Api extends Core
         return 'yes';
     }
 
+
+    # 发布朋友圈帖子信息
+    public function addMoment()
+    {
+        $pic = Dever::input('pic');
+        $content = Dever::input('content');
+        if (!$content) {
+            Dever::alert('请填写内容');
+        }
+
+        $type_id = Dever::input('type_id');
+        if (!$type_id) {
+            Dever::alert('错误的信息');
+        }
+        $type = Dever::input('type');
+        if (!$type) {
+            Dever::alert('错误的信息');
+        }
+
+        $to_id = Dever::input('to_id');
+        $to_uid = Dever::input('to_uid');
+        
+        Dever::load('community/lib/moment')->submit($this->uid, $type_id, $type, $pic, $content, $to_id, $to_uid, $this->day, 'collection/info', $this->id);
+
+        return 'yes';
+    }
+
     # 点赞
     public function up()
     {

+ 1 - 12
app/content/database/act.php

@@ -94,18 +94,7 @@ return array
 			'update'	=> 'editor',
 			'key'		=> '1',
 		),
-
-		'content'		=> array
-		(
-			'type' 		=> 'text-255',
-			'name' 		=> '内容',
-			'default' 	=> '',
-			'desc' 		=> '请输入内容',
-			'match' 	=> 'is_string',
-			'update'	=> 'editor',
-			'key'		=> '1',
-		),
-
+		
 		'status'		=> array
 		(
 			'type' 		=> 'int-11',

+ 1 - 1
app/content/database/dialogue.php

@@ -164,7 +164,7 @@ return array
                     'match'     => 'option',
                     'update'    => 'upload',
                     'key'       => 2,
-                    'show'      => 'type=3'
+                    'show'      => 'type=3',
                     'upload'    => 'yun',
                     'large'     => true,
                 ),

+ 163 - 0
app/content/database/moment.php

@@ -0,0 +1,163 @@
+<?php
+
+$status = Dever::config('base')->status;
+
+return array
+(
+	# 表名
+	'name' => 'moment',
+	# 显示给用户看的名称
+	'lang' => '朋友圈',
+	'order' => 100,
+	'menu' => false,
+
+	'end' => array
+	(
+		'insert' => 'collection/lib/content.updateTypeId',
+		'update' => 'collection/lib/content.updateTypeId',
+	),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+
+		'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'content_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集内容id',
+            'default'   => '',
+            'desc'      => '合集内容id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_content_id')
+        ),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '朋友圈标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+			'search'	=> 'fulltext',
+			//增加预览
+			'preview'	=> true,
+		),
+
+		'logo'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '朋友圈logo-图片尺寸380*380px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '朋友圈logo',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '380',
+		),
+
+		'pic'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '封面图-图片尺寸375*281px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '375*281',
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '内容介绍',
+			'default' 	=> '',
+			'desc' 		=> '请输入内容',
+			'match' 	=> 'is_string',
+			'update'	=> 'editor',
+			'key'		=> '1',
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布状态',
+			'default' 	=> '1',
+			'desc' 		=> '发布状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		
+	),
+);

+ 1 - 0
config/base.php

@@ -26,6 +26,7 @@ $config['base'] = array
         2 => 'collection/page',
         3 => 'collection/content',
         20 => 'community/info',
+        30 => 'content/moment',
     ),
 
     'audit' => array