1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace huo\controller\posts;
- use huo\controller\common\Base;
- use huo\logic\posts\PostsLogic;
- use huolib\status\CommonStatus;
- use huolib\status\NewsStatus;
- use huolib\utils\NewsUtils;
- class Posts extends Base {
- protected $post_logic;
- public function __construct(PostsLogic $post_logic = null) {
- if (null === $post_logic) {
- $this->post_logic = new PostsLogic();
- } else {
- $this->post_logic = $post_logic;
- }
- }
-
- public function getList($param = [], $page = '1,10') {
- $_order = '-is_top,-published_time';
- $_map['app_id'] = $this->getVal($param, 'game_id', 0);
- $_map['post_type'] = $this->getVal($param, 'type', 0);
- $_rs = NewsUtils::checkNewsType($_map['post_type']);
- if (NewsStatus::NO_ERROR != $_rs) {
- return $this->huoError($_rs, NewsStatus::getMsg($_rs));
- }
- $_data = $this->post_logic->getList($_map, $page, $_order);
- return $this->retSucMsg(CommonStatus::NO_ERROR, $_data);
- }
-
- public function getDetail($post_id, $type = 0) {
- if (!is_numeric($post_id) || $post_id < 0) {
- return $this->retErrMsg(CommonStatus::INVALID_PARAMS);
- }
- $_data = $this->post_logic->getDetail($post_id, $type);
- return $this->retSucMsg(CommonStatus::NO_ERROR, $_data);
- }
- }
|