|
...
|
...
|
@@ -4,9 +4,6 @@ namespace App\Models; |
|
|
|
|
|
|
|
use App\Helper\Common;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class Base extends Model
|
|
|
|
{
|
|
|
|
protected $table = '';
|
|
...
|
...
|
@@ -107,11 +104,22 @@ class Base extends Model |
|
|
|
*/
|
|
|
|
public function read($condition,$files = ['*'])
|
|
|
|
{
|
|
|
|
//读取缓存
|
|
|
|
$cache = config('cache.user_is_cache');
|
|
|
|
if(($cache['is_cache'] == true) && isset($condition['id'])){
|
|
|
|
$info = Common::get_user_cache($this->getTable(),$condition['id']);
|
|
|
|
if(!empty($info)){
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$query = $this->formatQuery($condition);
|
|
|
|
$info = $query->select($files)->first();
|
|
|
|
if (empty($info)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(($cache['is_cache'] == true) && isset($condition['id'])){
|
|
|
|
Common::set_user_cache($info,$this->getTable(),$condition['id']);
|
|
|
|
}
|
|
|
|
$info = $info->toArray();
|
|
|
|
return $info;
|
|
|
|
}
|
|
...
|
...
|
@@ -136,6 +144,11 @@ class Base extends Model |
|
|
|
$query = $this->formatQuery($condition);
|
|
|
|
$data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$rs = $query->update($data);
|
|
|
|
//更新缓存
|
|
|
|
$cache = config('cache.user_is_cache');
|
|
|
|
if(($cache['is_cache'] == true) && isset($condition['id'])) {
|
|
|
|
Common::del_user_cache($this->getTable(), $condition['id']);
|
|
|
|
}
|
|
|
|
return $rs;
|
|
|
|
}
|
|
|
|
/**
|
|
...
|
...
|
@@ -146,8 +159,7 @@ class Base extends Model |
|
|
|
*/
|
|
|
|
public function del($condition){
|
|
|
|
$query = $this->formatQuery($condition);
|
|
|
|
$rs = $query->delete();
|
|
|
|
return $rs;
|
|
|
|
return $query->delete();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @name :参数处理查询
|
...
|
...
|
|