功能更新,bug修复
This commit is contained in:
@@ -63,6 +63,12 @@ class Document extends \think\model\Merge{
|
||||
return $status;
|
||||
}
|
||||
|
||||
protected function getTagsAttr($value){
|
||||
if ($value) {
|
||||
return explode(',', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function extend($name){
|
||||
if (is_numeric($name)) {
|
||||
$name = db('model')->where(array('id'=>$name))->value('name');
|
||||
@@ -71,17 +77,6 @@ class Document extends \think\model\Merge{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function scopeList($query, $map, $field = '*', $limit = 10, $order = 'Document.id desc'){
|
||||
if (!empty($map) && is_array($map)) {
|
||||
foreach ($map as $key => $value) {
|
||||
$where[$this->name . '.' . $key] = $value;
|
||||
}
|
||||
}else{
|
||||
$where = $map;
|
||||
}
|
||||
$query->field($field)->where($where)->limit($limit)->order($order);
|
||||
}
|
||||
|
||||
public function change(){
|
||||
/* 获取数据对象 */
|
||||
$data = input('post.');
|
||||
@@ -119,4 +114,22 @@ class Document extends \think\model\Merge{
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function recom($id, $field = '*', $limit = 10, $order = 'id desc'){
|
||||
$tag = $this->where(array('id'=>$id))->value('tags');
|
||||
$map = '';
|
||||
if ($tag) {
|
||||
$tags = explode(',', $tag);
|
||||
foreach ($tags as $item) {
|
||||
$where[] = 'tags LIKE "%' . $item . '%"';
|
||||
}
|
||||
$map = implode(' OR ', $where);
|
||||
}
|
||||
$list = $this->where($map)->field($field)->limit($limit)->order($order)->select();
|
||||
if (empty($list)) {
|
||||
return $list;
|
||||
}else{
|
||||
return $this->field($field)->limit($limit)->order($order)->select();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user