Star.class.php 2.97 KB
<?php

/**
 *  品牌信息
 *
 * @name Service_Star
 * @version 1.0 (2013-6-5)
 * @package Service/Star
 * @author hbomb
 * @since 1.0
 */

class Service_Star extends Lib_Service
{

    const ROUTER = 'star.yohood.star';

    /**
     * 获取明星
     * 
     * @param unknown_type $offset
     * @param unknown_type $limit
     * @param unknown_type $status
     * @return Ambigous <multitype:, Util_Dao_Db_PdoQuery>
     */
    public function getStarByState ($offset, $limit, $state)
    {
        return self::service(self::ROUTER)->cache(false)->
            fetchAssoc('getStarByState', array('offset' => $offset, 'limit' => $limit, 'state'=>$state));
    }
    
    /**
     * 根据状态获取所有明星个数. 用于前端分页
     * 
     * @param $status
     */
    public function getStarTotal ($state)
    {
        return self::service(self::ROUTER)->cache(false)->fetchOne('getStarTotal', array('state'=>$state));
    }
    
    /**
     * 根据id更新明星状态. 用于管理员更新一个明星的操作.
     * @param unknown_type $name
     * @param unknown_type $pics
     * @param unknown_type $description
     * @param unknown_type $state
     * @param unknown_type $brand_id
     * @param unknown_type $seq
     * @param unknown_type $news_ids
     * @param unknown_type $id
     */
    public function updateStar ($name,$pics,$description,$state,$brand_id,$seq,$news_ids,$say,$id)
    {
        $param = array(
                'id'=>$id,
                'name'=> $name,
                'description'=>$description,
                'state'=>$state,
                'pics'=>$pics,
                'brand_id'=>$brand_id,
                'seq'=>$seq,
                'news_ids'=>$news_ids,
                'say'=>$say
                );
        $status =  self::service(self::ROUTER)->cache(false)->update('updateStar', $param)->status();
        return $status;
    }
    
    /**
     * 用户提交明星. 
     * @param unknown_type $name
     * @param unknown_type $logo
     * @param unknown_type $description
     * @param unknown_type $pics
     * @param unknown_type $person
     * @param unknown_type $news_ids
     * @param unknown_type $seq
     * @param unknown_type $state
     * @return number
     */
    public function submitStar ($name,$pics,$description,$state,$brand_id,$seq,$news_ids,$say)
    {
        $param = array(
                'name'=> $name,
                'description'=>$description,
                'state'=>$state,
                'pics'=>$pics,
                'brand_id'=>$brand_id,
                'seq'=>$seq,
                'news_ids'=>$news_ids,
                'say'=>$say
        );
        $status = self::service(self::ROUTER)->cache(false)->insert('insertStar', $param)->lastInsertId();
        return $status;
    }
    
    /**
     * 根据ID获取主理人
     * @param unknown_type $id
     */
    public static function getStarByID($id)
    {
        return self::service(self::ROUTER)->cache(false)->fetchRow('getStarByID', array('id'=>$id));
    }
}