colly_wyx
2018-03-29 2fe556a03bce3df5ad8fdcfdc92583d8ea945ac9
新增广告调用接口
3 files added
76 ■■■■■ changed files
Yfs/Api/Ad.php 48 ●●●●● patch | view | raw | blame | history
Yfs/Domain/Ad.php 20 ●●●●● patch | view | raw | blame | history
Yfs/Model/Ad.php 8 ●●●●● patch | view | raw | blame | history
Yfs/Api/Ad.php
New file
@@ -0,0 +1,48 @@
<?php
/**
 * 广告信息类
 */
class Api_Ad extends PhalApi_Api {
    public function getRules() {
        return array(
            'getAd' => array(
            ),
        );
    }
    /**
     * 获取当前广告信息
     * @desc 获取当前广告记录
     * @return bool code 操作码,0表示成功, 1表示失败
     * @return string msg 返回提示
     * @return object info 用户信息对象
     * @return string info._id 用户id
     * @return string info.name 广告名称
     * @return string info.content 广告内容
     * @return string info.logo 广告logo
     * @return string info.create_time 创建时间
     * @return string info.is_open 是否开启中,0表示未开启,1表示开启
     */
    public function getAd(){
        $rs = array('code' => 0, 'msg' => '', 'info' => array());
        $ad_service = new Domain_Ad();
        $ad = $ad_service->getAd();
        if ($ad) {
            $rs['code'] = 0;
            $rs['msg'] = '广告信息获取成功';
            $rs['info'] = $ad;
        }
        else{
            $rs['code'] = 1;
            $rs['msg'] = '当前广告不存在';
        }
        return $rs;
    }
}
Yfs/Domain/Ad.php
New file
@@ -0,0 +1,20 @@
<?php
/**
 * 广告业务类
 */
class Domain_Ad {
    public function __construct(){
        $this->model = new Model_Ad();
    }
    /**
     * 获取当前广告
     * @param  [type] is_open [description]
     * @return [type]        [description]
     */
    public function getAd(){
        return $this->model->get(array('is_open' => 1),array(), array('time_level' => -1), 1);
    }
}
Yfs/Model/Ad.php
New file
@@ -0,0 +1,8 @@
<?php
class Model_Ad extends Model_Base{
    public $table = 'ad';
}