作者 邓超

v2

... ... @@ -33,16 +33,19 @@ class Base {
* @author:dc
* @time 2022/12/28 9:32
*/
protected final function getData($url,$data=[]){
protected final function getData($url,$data=[], $is_cache = true){
$url = 'https://oa.shopk.com/api/shopk/'.$url;
// $url = 'http://local.oa.shopk.com/api/shopk/'.$url;
// 缓存
$cacheKey = md5($url.':'.json_encode($data));
// if(Cache::has($cacheKey)){
if($is_cache){
// if(Cache::has($cacheKey)){
// return Cache::get($cacheKey);
// }
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\V2;
use App\Fun;
use Illuminate\Support\Facades\View;
use function Swoole\Coroutine\Http\get;
/**
* 第二版的控制器
... ... @@ -117,6 +118,28 @@ class Index extends Base
}
/**
* 设置模板,保存
* @author:dc
* @time 2022/12/30 16:44
*/
public function template(){
$name = request()->get('name');
$data = $this->getData('template',['name'=>$name],false);
if($data){
// 保存文件
$filename = resource_path('views'.$data['path'].'.blade.php');
// 是否存在
if(!is_dir(dirname($filename))){
mkdir(dirname($filename),0775,true);
}
@file_put_contents($filename,$data['html']);
}
}
... ...
... ... @@ -17,3 +17,6 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
// 设置模板
Route::post('/template',[\App\Http\Controllers\V2\Index::class,'template']);
... ...