正在显示
3 个修改的文件
包含
31 行增加
和
2 行删除
@@ -33,16 +33,19 @@ class Base { | @@ -33,16 +33,19 @@ class Base { | ||
33 | * @author:dc | 33 | * @author:dc |
34 | * @time 2022/12/28 9:32 | 34 | * @time 2022/12/28 9:32 |
35 | */ | 35 | */ |
36 | - protected final function getData($url,$data=[]){ | 36 | + protected final function getData($url,$data=[], $is_cache = true){ |
37 | 37 | ||
38 | $url = 'https://oa.shopk.com/api/shopk/'.$url; | 38 | $url = 'https://oa.shopk.com/api/shopk/'.$url; |
39 | // $url = 'http://local.oa.shopk.com/api/shopk/'.$url; | 39 | // $url = 'http://local.oa.shopk.com/api/shopk/'.$url; |
40 | 40 | ||
41 | // 缓存 | 41 | // 缓存 |
42 | $cacheKey = md5($url.':'.json_encode($data)); | 42 | $cacheKey = md5($url.':'.json_encode($data)); |
43 | -// if(Cache::has($cacheKey)){ | 43 | + if($is_cache){ |
44 | + // if(Cache::has($cacheKey)){ | ||
44 | // return Cache::get($cacheKey); | 45 | // return Cache::get($cacheKey); |
45 | // } | 46 | // } |
47 | + } | ||
48 | + | ||
46 | 49 | ||
47 | $ch = curl_init(); | 50 | $ch = curl_init(); |
48 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); | 51 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\V2; | @@ -4,6 +4,7 @@ namespace App\Http\Controllers\V2; | ||
4 | 4 | ||
5 | use App\Fun; | 5 | use App\Fun; |
6 | use Illuminate\Support\Facades\View; | 6 | use Illuminate\Support\Facades\View; |
7 | +use function Swoole\Coroutine\Http\get; | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * 第二版的控制器 | 10 | * 第二版的控制器 |
@@ -117,6 +118,28 @@ class Index extends Base | @@ -117,6 +118,28 @@ class Index extends Base | ||
117 | } | 118 | } |
118 | 119 | ||
119 | 120 | ||
121 | + /** | ||
122 | + * 设置模板,保存 | ||
123 | + * @author:dc | ||
124 | + * @time 2022/12/30 16:44 | ||
125 | + */ | ||
126 | + public function template(){ | ||
127 | + $name = request()->get('name'); | ||
128 | + $data = $this->getData('template',['name'=>$name],false); | ||
129 | + | ||
130 | + if($data){ | ||
131 | + // 保存文件 | ||
132 | + $filename = resource_path('views'.$data['path'].'.blade.php'); | ||
133 | + // 是否存在 | ||
134 | + if(!is_dir(dirname($filename))){ | ||
135 | + mkdir(dirname($filename),0775,true); | ||
136 | + } | ||
137 | + @file_put_contents($filename,$data['html']); | ||
138 | + | ||
139 | + } | ||
140 | + | ||
141 | + | ||
142 | + } | ||
120 | 143 | ||
121 | 144 | ||
122 | 145 |
@@ -17,3 +17,6 @@ use Illuminate\Support\Facades\Route; | @@ -17,3 +17,6 @@ use Illuminate\Support\Facades\Route; | ||
17 | Route::middleware('auth:api')->get('/user', function (Request $request) { | 17 | Route::middleware('auth:api')->get('/user', function (Request $request) { |
18 | return $request->user(); | 18 | return $request->user(); |
19 | }); | 19 | }); |
20 | + | ||
21 | +// 设置模板 | ||
22 | +Route::post('/template',[\App\Http\Controllers\V2\Index::class,'template']); |
-
请 注册 或 登录 后发表评论