Brand.class.php
8.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
/**
* 品牌信息
*
* @name Service_Brand
* @version 1.0 (2013-6-5)
* @package Service/Brand/Brand
* @author hbomb
* @since 1.0
*/
class Service_Brand extends Lib_Service
{
const ROUTER = 'brand.yohood.brand';
private static $_tag = 'tag_yohood_brand_';
private static $_key = 'key_yohood_brand_';
private static $_rela_tag = 'key_yohood_brand_news_';
/**
* 获取品牌
*
* @param unknown_type $offset
* @param unknown_type $limit
* @param unknown_type $status
* @return Ambigous <multitype:, Util_Dao_Db_PdoQuery>
*/
public function getBrandByState ($offset, $limit, $state)
{
return self::service(self::ROUTER)->tag(self::$_tag)->
fetchAssoc('getBrandByState', array('offset' => $offset, 'limit' => $limit, 'state'=>$state));
}
/**
* 根据状态获取所有品牌个数. 用于前端分页
*
* @param $status
*/
public function getBrandTotal ($state)
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getBrandTotal', array('state'=>$state));
}
/**
* 根据id更新品牌状态. 用于管理员更新一个品牌的操作.
* @param string $id
* @param string $name
* @param string $logo
* @param string $description
* @param string $state
* @param string $pics
* @param string $person
* @param string $seq
* @param int $boothId
* @params string $link
* @return boolean
*/
public function updateBrand ($id, $name,$logo,$description,$state,$pics,$person,$seq,$news_ids, $boothId, $link)
{
$param = array(
'id'=> $id,
'name'=> $name,
'logo'=> $logo,
'description'=> $description,
'state'=> $state,
'pics'=> $pics,
'person'=> $person,
'seq'=> $seq,
'news_ids'=> $news_ids,
'booth_id'=> $boothId,
'link' => $link
);
$status = self::service(self::ROUTER)->cache(false)->update('updateBrand', $param)->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 用户提交品牌.
* @param string $name
* @param string $logo
* @param string $description
* @param string $pics
* @param string $person
* @param string $news_ids
* @param string $seq
* @param string $state
* @param int $boothId
* @param string $link
* @return int
*/
public function submitBrand ($name, $logo, $description, $pics, $person, $news_ids, $seq, $state, $boothId, $link)
{
$param = array(
'name'=> $name,
'logo'=>$logo,
'description'=>$description,
'state'=>$state,
'pics'=>$pics,
'person'=>$person,
'seq'=>$seq,
'news_ids'=>$news_ids,
'booth_id'=> $boothId,
'link' => $link
);
$status = self::service(self::ROUTER)->cache(false)->insert('insertBrand', $param)->lastInsertId();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 根据ID获取品牌
*
* @param string $id
* @return array
*/
public function getBrandByID($id)
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getBrandByID', array('id'=>$id));
}
/**
* 设置booth
*
* @param string $booth_id
* @param string $position
* @return boolean
*/
public function setBooth($booth_id, $position)
{
$params = array('booth_id' => $booth_id, 'position' => $position);
$status = self::service(self::ROUTER)->cache(false)->insert('setBooth', $params)->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 获取booth
*
* @return array
*/
public function getBoothList()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getBoothList');
}
/**
* 删除booth
*
* @return bolean
*/
public function delBooth($booth_id)
{
$status = self::service(self::ROUTER)->cache(false)->delete('delBooth', array('booth_id'=> $booth_id))->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 获取签到布局列表
*
* @return array
*/
public function getSignLayoutList()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getSignLayoutList');
}
/**
* 获取签到图片
*
* @return array
*/
public function getSignPicList()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getSignPicList');
}
/**
* 获取签到坐标
*
* @return array
*/
public function getSignPosition()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAll('getSignPosition');
}
/**
* 获取有货品牌
*
* @return array
*/
public function getYohobuyBrand()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getYohobuyBrand');
}
/**
* 获取签到品牌
*
* @return array
*/
public function getSignBrand()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAll('getSignBrand');
}
/**
* 获取所有品牌
*
* @return array
*/
public function getBrand()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getBrand');
}
/**
* 设置品牌和资讯对应关系
*
* @param int $news_id
* @param int $brand_id
* @return boolean
*/
public function setBrandNewsRela($news_id, $brand_id)
{
return self::service(self::ROUTER)->tag(self::$_rela_tag)->insert('setBrandNewsRela',
array('news_id' => intval($news_id), 'brand_id'=> intval($brand_id)))->status();
}
/**
* 根据news_id获取品牌和资讯对应关系
*
* @param int|array $news_id
* @return array
*/
public function getBrandNewsRelaByNewsID($news_id)
{
if(is_numeric($news_id))
{
$news_id = array($news_id);
}
return self::service(self::ROUTER)->tag(self::$_rela_tag)->fetchAssoc('getBrandNewsRelaByNewsID', array(), array('news_id' => implode(',', $news_id)));
}
/**
* 根据news_id获取品牌和资讯对应关系
*
* @param int|array $brand_id
* @return array
*/
public function getBrandNewsRelaByBrandID($brand_id)
{
if(empty($brand_id))
{
return array();
}
if(is_numeric($brand_id))
{
$brand_id = array($brand_id);
}
return self::service(self::ROUTER)->tag(self::$_rela_tag)->fetchAssoc('getBrandNewsRelaByBrandID', array(), array('brand_id' => implode(',', $brand_id)));
}
/**
* 根据news_id删除品牌和资讯对应关系
*
* @param int $news_id
* @return array
*/
public function deleteBrandNewsRelaByNewsID($news_id)
{
return self::service(self::ROUTER)->tag(self::$_rela_tag)->delete('deleteBrandNewsRelaByNewsID', array('news_id' => intval($news_id)));
}
/**
* 获取相同的news_ids
*
* @param int $news_id
* @return array
*/
public function getSameNewsByNewsID($news_id)
{
return self::service(self::ROUTER)->tag(self::$_rela_tag)->fetchCol('getSameNewsByNewsID', array('news_id' => intval($news_id)));
}
/**
* 根据名称获取品牌列表
*
* @param string $name
* @param int $state
* @return array
*/
public function getBrandByName($name, $state)
{
$name = strip_tags($name);
$name = '%'.addslashes($name).'%';
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getBrandByName',
array('state'=> $state,'name'=> $name));
}
}