CommonRecommenderModel.class.php
4.53 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
<?php
/**
* CommonRecommenderModel.class.php
* 推荐系统 Model
* @author Deepseath
* @version $Id$
*/
namespace Common\Model;
class CommonRecommenderModel extends AbstractModel
{
/**
* 推荐类型:首页条幅
* PS: 课程 默认数据初始化那里 直接用到了这个 修改的时候注意一起修改下
* 路径: Course/Rpc/Controller/Common/Install
* 2017-11-09 18:28:07 不用 失效后删除
*/
const TYPE_BANNER = 1;
/**
* 推荐类型:栏目 ICON
*/
const TYPE_ICON = 2;
/**
* 推荐类型:首页文章推荐
*/
const TYPE_ARTICLE = 3;
/**
* 单次获取数据允许的最大条数
*/
const LIMIT_MAX = 500;
/**
* 单次获取数据允许的最小条数
*/
const LIMIT_MIN = 1;
/**
* 是否隐藏:不隐藏,显示
* PS: 课程 默认数据初始化那里 直接用到了这个 修改的时候注意一起修改下
* 路径: Course/Rpc/Controller/Common/Install
*
* @var unknown
*/
const HIDE_NO = 1;
/**
* 是否隐藏:隐藏,不显示
* @var integer
*/
const HIDE_YES = 2;
/**
* 是否系统内置:是
*/
const SYSTEM_YES = 1;
/**
* 是否系统内置:否
* PS: 课程 默认数据初始化那里 直接用到了这个 修改的时候注意一起修改下
* 路径: Course/Rpc/Controller/Common/Install
*/
const SYSTEM_NO = 2;
/**
* 显示顺序最小值
* PS: 课程 默认数据初始化那里 直接用到了这个 修改的时候注意一起修改下
* 路径: Course/Rpc/Controller/Common/Install
*/
const VALUE_DISPLAYORDER_MIN = 1;
/**
* 显示顺序最大值
*/
const VALUE_DISPLAYORDER_MAX = 9999;
/**
* 推荐系统 Model 构造方法
*/
public function __construct()
{
parent::__construct();
}
/**
* 计数 指定类型、应用、数据Id、分类Id 相关的推荐数据
* @param number $type
* @param string $appDir
* @param string $dataId
* @param string $dataCategoryId
* @param number $ignoreRecommenderId 需要排除的数据 Id
* @return array
*/
public function countByTypeAppdirDataidCategoryid($type, $appDir = null, $dataId = null, $dataCategoryId = null, $ignoreRecommenderId = 0)
{
return $this->count_by_conds($this->__whereDuplicate($type, $appDir, $dataId, $dataCategoryId, $ignoreRecommenderId));
}
/**
* 获取 指定类型、应用、数据Id、分类Id 相关的推荐数据
*
* @param number $type
* @param string $appDir
* @param string $dataId
* @param string $dataCategoryId
* @param number $ignoreRecommenderId 需要排除的数据 Id
* @return array
*/
public function getByTypeAppdirDataidCategoryid($type, $appDir = null, $dataId = null, $dataCategoryId = null, $ignoreRecommenderId = 0)
{
return $this->get_by_conds($this->__whereDuplicate($type, $appDir, $dataId, $dataCategoryId, $ignoreRecommenderId));
}
/**
* 构造查询 指定类型、应用、数据 Id、分类 Id 相关的推荐数据
* @param number $type
* @param string $appDir
* @param string $dataId
* @param string $dataCategoryId
* @param number $ignoreRecommenderId 需要排除的数据 Id
*/
private function __whereDuplicate($type, $appDir, $dataId, $dataCategoryId, $ignoreRecommenderId)
{
$conds = [];
$conds['type'] = $type;
if ($appDir !== null) {
$conds['app_dir'] = $appDir;
}
if ($dataId !== null) {
$conds['data_id'] = $dataId;
}
if ($dataCategoryId !== null) {
$conds['data_category_id'] = $dataCategoryId;
}
if ($ignoreRecommenderId) {
// 需要忽略的数据 Id
$conds['recommender_id != ?'] = $ignoreRecommenderId;
}
return $conds;
}
/**
* 列表 指定类型、应用、数据Id、分类Id 相关的推荐数据
*
* @param number $type
* @param string $appDir
* @param string $dataId
* @param string $dataCategoryId
* @param number $ignoreRecommenderId 需要排除的数据 Id
* @return array
*/
public function listByTypeAppdirDataidCategoryid($type, $appDir = null, $dataId = null, $dataCategoryId = null, $ignoreRecommenderId = 0)
{
return $this->list_by_conds($this->__whereDuplicate($type, $appDir, $dataId, $dataCategoryId, $ignoreRecommenderId));
}
}