123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /**
- * Comment.php UTF-8
- *
- *
- * @date : 2017/11/24 17:19
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\controller\comment;
- use huo\controller\common\Base;
- use huo\logic\comment\CommentLogic;
- use huolib\status\CommonStatus;
- class Comment extends Base {
- protected $comment_logic;
- public function __construct(CommentLogic $comment_logic = null) {
- if (null === $comment_logic) {
- $this->comment_logic = new CommentLogic();
- } else {
- $this->comment_logic = $comment_logic;
- }
- }
- /**
- * 获取列表
- *
- * @param array $param
- * @param string $page
- *
- * @return array
- */
- public function getList($param = [], $page) {
- $_map['table_name'] = $param['type_name'];
- $_map['object_id'] = $param['object_id'];
- $_cnt = $this->comment_logic->getCnt($_map);
- if (empty($_cnt)) {
- $_data = [];
- } else {
- $_order = '-create_time';
- $_data = $this->comment_logic->getList($_map, $page, $_order);
- }
- $_rdata = [
- 'count' => $_cnt,
- 'list' => $_data,
- ];
- $code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($code, CommonStatus::getMsg($code), $_rdata);
- }
- /**
- * 添加评论
- *
- * @param array $param
- * @param int $mem_id
- *
- * @return array
- */
- public function addComment($param, $mem_id) {
- $param['mem_id'] = $mem_id;
- $_rs = $this->comment_logic->addComment($param);
- $code = CommonStatus::NO_ERROR;
- if (!$_rs) {
- $code = CommonStatus::INNER_ERROR;
- }
- return $this->huoSuccess($code, CommonStatus::getMsg($code));
- }
- /**
- * 获取列表
- *
- * @param int $mem_id 玩家ID
- * @param string $page
- *
- * @return array
- */
- public function getMyGameCommentList($mem_id, $page) {
- $_map['table_name'] = 'game';
- $_map['mem_id'] = $mem_id;
- $_cnt = $this->comment_logic->getCnt($_map);
- if (empty($_cnt)) {
- $_data = [];
- } else {
- $_order = '-create_time';
- $_data = $this->comment_logic->getListAndGame($_map, $page, $_order);
- }
- $_rdata = [
- 'count' => $_cnt,
- 'list' => $_data,
- ];
- $code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($code, CommonStatus::getMsg($code), $_rdata);
- }
- /**
- * 获取评论数量
- *
- * @param int $mem_id 玩家ID
- *
- * @return array
- */
- public function getCnt($mem_id) {
- $_map['table_name'] = 'game';
- $_map['mem_id'] = $mem_id;
- $_cnt = $this->comment_logic->getCnt($_map);
- $_rdata = [
- 'comment_cnt' => $_cnt,
- ];
- $code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($code, CommonStatus::getMsg($code), $_rdata);
- }
- }
|