| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | <?php/** * Post.php UTF-8 * 文章处理 * * @date    : 2017/11/23 21:42 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : wuyonghong <wyh@huosdk.com> * @version : HUOSDK 8.0 */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;        }    }    /**     * 获取文章列表     *     * @param array  $param     * @param string $page     *     * @return array     */    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);    }    /**     * @param int $post_id     *     * @param int $type     *     * @return array     */    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);    }}
 |