功能更新,bug修复

This commit is contained in:
2016-06-29 15:01:55 +08:00
parent 6f1790bc3b
commit c8e979b159
14 changed files with 277 additions and 128 deletions

View File

@@ -13,6 +13,11 @@ class Fornt extends Base{
public function _initialize(){
parent::_initialize();
//判读是否为关闭网站
if (\think\Config::get('web_site_close')) {
return $this->fetch('common@default/public/close');exit();
}
//设置SEO
$this->setSeo();

View File

@@ -13,12 +13,18 @@ namespace app\common\model;
* 模型基类
*/
class Base extends \think\Model{
public function scopeList($query, $map, $field = '*', $limit = 10, $order = 'id desc'){
$query->field($field)->where($map)->limit($limit)->order($order);
}
public function scopeWhere($query, $map){
$query->where($map);
protected $type = array(
'id' => 'integer',
'cover_id' => 'integer',
);
/**
* 数据修改
* @return [bool] [是否成功]
*/
public function change(){
$data = \think\Request::instance()->post();
return $this->save($data, array('id'=>$data['id']));
}
}

View File

@@ -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();
}
}
}

View File

@@ -1 +1 @@
<input type="text" value="{$value}" id="{$field}" name="{$field}" data-role="tagsinput" />
<input type="text" value="{$value|implode=',',###}" id="{$field}" name="{$field}" data-role="tagsinput" />