123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace huo\controller\message;
- use huo\controller\common\Base;
- use huo\logic\message\MessageLogic;
- class Message extends Base {
- protected $msg_logic;
- public function __construct(MessageLogic $msg_logic = null) {
- if (null === $msg_logic) {
- $this->msg_logic = new MessageLogic();
- } else {
- $this->msg_logic = $msg_logic;
- }
- }
-
- public function getCnt($param, $mem_id = 0) {
- if (empty($mem_id)) {
- return 0;
- }
-
- return rand(0, 2);
- }
-
- public function getList($param = [], $page, $mem_id = 0) {
- $_map['gameid'] = $this->getVal($param, 'gameid', 0);
- $_map['type'] = $this->getVal($param, 'type', 0);
- $_map['mem_id'] = $mem_id;
- $_data = [
- 'count' => 0,
- 'list' => []
- ];
- $_cnt = $this->msg_logic->getCnt($_map);
- if (empty($_cnt)) {
- return $this->huoSuccess(200, '', $_data);
- }
- $_data['count'] = $_cnt;
- $_order = '-create_time';
- $_data['list'] = $this->msg_logic->getList($_map, $page, $_order);
- return $this->huoSuccess(200, '', $_data);
- }
-
- public function getDetail($msg_id = 0, $mem_id = 0) {
- if (empty($msg_id)) {
- return $this->huoError(400);
- }
- $_data = $this->msg_logic->getDetail($msg_id, $mem_id);
- if (false === $_data) {
- return $this->huoError(1000);
- }
- if (is_numeric($_data)) {
- return $this->huoError($_data);
- }
- return $this->huoSuccess(200, '', $_data);
- }
-
- public function addMessage($_param, $mem_id) {
- $title = $this->getVal($_param, 'title', '');
- $content = $this->getVal($_param, 'content', '');
- $type = $this->getVal($_param, 'type', 2);
- $app_id = $this->getVal($_param, 'app_id', 0);
- $_rs = $this->msg_logic->addMessage($mem_id, $title, $content, $type, $app_id);
- if ($_rs) {
- return $this->huoSuccess(200);
- } else {
- return $this->huoError(1000);
- }
- }
- }
|