1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * PostLogic.php UTF-8
- * 资讯
- *
- * @date : 2018/1/23 14:59
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : linjiebin <ljb@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace web\pc\logic;
- use huo\model\common\CommonModel;
- use huo\model\posts\PostsModel;
- class PostLogic extends CommonModel {
- public function getList($where = [], $page = '1,10', $order = '') {
- $_rdata = [
- 'count' => 0,
- 'list' => []
- ];
- $_map = [];
- if (!empty($where['gameid'])) {
- $_map['app_id'] = $where['gameid'];
- }
- if (!empty($where['catalog'])) {
- $_map['post_type'] = $where['catalog'];
- }
- $_param['where'] = $_map;
- $_param['page'] = $page;
- $_param['order'] = $order;
- $_posts = new PostsModel();
- $_rdata['count'] = $_posts->where($_map)->count();
- if (empty($_rdata['count'])) {
- return $_rdata;
- }
- $_field= 'id,post_title,app_id,published_time,more,user_id,comment_count,post_like,post_type,post_content';
- $_datas = $_posts->field($_field)->where($_map)->order($order)->page($page)->select();
- // $_param['field'] = 'id,post_title,app_id,published_time,more,user_id,comment_count,post_like,post_type,post_content';
- // $_datas = $_posts->getDatas($_param);
- $_list = [];
- foreach ($_datas as $_data) {
- $_post = [];
- $_post['id'] = $_data['id'];
- $_post['title'] = $_data['post_title'];
- $_post['gameid'] = $_data['app_id'];
- $_post['pubdate'] = $_data['published_time'];
- $_post['img'] = isset($_data['more']['thumbnail']) ? $_data['more']['thumbnail'] : '';
- $_post['author'] = $_data['user_id'];
- $_post['commentcnt'] = $_data['comment_count'];
- $_post['likecnt'] = $_data['post_like'];
- $_post['type'] = $_data['post_type'];
- $_post['post_content'] = strip_tags($_data['post_content']);
- $_list[] = $_post;
- }
- $_rdata['list'] = $_list;
- return $_rdata;
- }
- /**
- * @param int $post_id
- *
- * @return int
- */
- public function getDetail($post_id = 0) {
- if (empty($post_id)) {
- return 2000;
- }
- $_param['field'] = 'id,post_title,post_content,app_id,post_excerpt,published_time,more,user_id,comment_count,post_like,post_type';
- $_param['id'] = $post_id;
- $_posts = new PostsModel();
- $_data = $_posts->getDatas($_param);
- if (empty($_data)) {
- return 2000;
- }
- $_post['id'] = $_data['id'];
- $_post['title'] = $_data['post_title'];
- $_post['gameid'] = $_data['app_id'];
- $_post['pubdate'] = $_data['published_time'];
- $_post['img'] = isset($_data['more']['thumbnail']) ? $_data['more']['thumbnail'] : '';
- $_post['author'] = $_data['user_id'];
- $_post['type'] = $_data['post_type'];
- $_post['excerpt'] = $_data['post_excerpt'];
- $_post['content'] = $_data['post_content'];
- return $_post;
- }
- }
|