Partner.class.php 1.9 KB
<?php
class Service_Partner extends Lib_Service
{
	 const ROUTER = 'partner.yohood.partner';
	 private static $_tag = 'tag_yohood_partner_';
	 private static $_key = 'key_yohood_partner_';
	 
	 /**
	  * 获取所有合作伙伴
	  * 
	  * @return array
	  */
	 public function getPartner()
	 {
	 	 return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getPartner');
	 }
	 
	 /**
	  * 增加合作伙伴
	  * 
	  * @param int $type
	  * @param string $name
	  * @param string $pic
	  * @param string $url
	  * @param string $description
	  * @return int
	  */
	 public function setPartner($type, $name, $pic, $url, $description)
	 {
	 	 $params = array('name' => $name, 'pic' => $pic, 'url' => $url, 'description'=> $description,'type' => $type);
	 	 $status = self::service(self::ROUTER)->cache(false)->insert('setPartner', $params)->lastInsertId();
	 	 if($status)
	 	 {
	 	 	self::service(self::ROUTER)->delTags(self::$_tag);
	 	 }
	 	 return $status;
	 }
	 
	 /**
	  * 修改合作伙伴
	  * 
	  * @param int $id
	  * @param int $type
	  * @param string $name
	  * @param string $pic
	  * @param string $url
	  * @param string $description
	  * @return boolean
	  */
	 public function setPartnerById($id, $type, $name, $pic, $url, $description)
	 {
	 	 $params = array('name' => $name, 'type'=> $type,'pic' => $pic, 'url' => $url, 'description'=> $description, 'id'=> $id);
	 	 $status = self::service(self::ROUTER)->cache(false)->update('setPartnerById', $params)->status();
	 	 if($status)
	 	 {
	 	 	self::service(self::ROUTER)->delTags(self::$_tag);
	 	 }
	 	 return $status;
	 }
	 
	 /**
	  * 删除合作伙伴
	  * 
	  * @param int $id
	  * @return boolean
	  */
	 public function delPartner($id)
	 {
	 	 $status = self::service(self::ROUTER)->cache(false)->delete('delPartner', array('id'=> $id))->status();
	 	 if($status)
	 	 {
	 	 	self::service(self::ROUTER)->delTags(self::$_tag);
	 	 }
	 	 return $status;
	 }
}