提交树形组件,但是逻辑和结构不合适,重构

This commit is contained in:
augushong
2021-04-07 23:04:08 +08:00
parent f15b3a8b4f
commit 2fb658d085
4 changed files with 265 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ namespace app\model;
use think\facade\App;
use think\facade\Cache;
use think\facade\View;
use think\Model;
use think\model\concern\SoftDelete;
@@ -157,7 +158,7 @@ class Post extends Model
return '';
}
return file_get_contents($file_path);
return View::fetch($file_path);
}
public static function quickSelect($clear = false)
@@ -179,15 +180,15 @@ class Post extends Model
return $list_post;
}
public static function quickFind($id,$clear = false)
public static function quickFind($id, $clear = false)
{
$cache_key = 'post_'.$id;
$cache_key = 'post_' . $id;
$model_post = Cache::get($cache_key);
if(empty($model_post) || $clear){
if (empty($model_post) || $clear) {
$model_post = Post::find($id);
Cache::set($cache_key,$model_post,600);
Cache::set($cache_key, $model_post, 600);
}
return $model_post;