Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
6 个修改的文件
包含
86 行增加
和
15 行删除
| @@ -9,7 +9,9 @@ namespace App\Http\Controllers\Api; | @@ -9,7 +9,9 @@ namespace App\Http\Controllers\Api; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Http\Logic\Bside\User\UserLoginLogic; | 11 | use App\Http\Logic\Bside\User\UserLoginLogic; |
| 12 | +use App\Models\Blog\Blog; | ||
| 12 | use App\Models\Domain\DomainInfo; | 13 | use App\Models\Domain\DomainInfo; |
| 14 | +use App\Models\News\News; | ||
| 13 | use App\Models\Product\Category; | 15 | use App\Models\Product\Category; |
| 14 | use App\Models\Product\CategoryRelated; | 16 | use App\Models\Product\CategoryRelated; |
| 15 | use App\Models\Product\Keyword; | 17 | use App\Models\Product\Keyword; |
| @@ -283,4 +285,54 @@ class PrivateController extends BaseController | @@ -283,4 +285,54 @@ class PrivateController extends BaseController | ||
| 283 | } | 285 | } |
| 284 | return $this->success($projects); | 286 | return $this->success($projects); |
| 285 | } | 287 | } |
| 288 | + | ||
| 289 | + /** | ||
| 290 | + * 获取有效时间内 新增有效URL | ||
| 291 | + * 用于自动提交Google收录 | ||
| 292 | + * @param Request $request | ||
| 293 | + * @return false|string | ||
| 294 | + */ | ||
| 295 | + public function projectNewUrl(Request $request) | ||
| 296 | + { | ||
| 297 | + $domain = trim($request->input('domain')); | ||
| 298 | + $domain_parse = parse_url($domain); | ||
| 299 | + $domain = $domain_parse['host'] ?? $domain; | ||
| 300 | + $date = trim($request->input('date')); | ||
| 301 | + | ||
| 302 | + if (empty($domain) || empty($date)) { | ||
| 303 | + return $this->error('非法参数!'); | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + $project = Project::getProjectByDomain($domain); | ||
| 307 | + if (empty($project)) { | ||
| 308 | + return $this->error('未找到当前域名对应的项目!'); | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + ProjectServer::useProject($project->id); | ||
| 312 | + $result = []; | ||
| 313 | + // 查询有效时间后 有效的产品、新闻、博客、聚合页 链接 | ||
| 314 | + $product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route'); | ||
| 315 | + $news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); | ||
| 316 | + $blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); | ||
| 317 | + $keyword = Keyword::where('created_at', '>', $date)->pluck('route'); | ||
| 318 | + | ||
| 319 | + // 组装链接 | ||
| 320 | + foreach ($product as $item) { | ||
| 321 | + $url = 'https://' . $domain . '/' . $item; | ||
| 322 | + array_push($result, $url); | ||
| 323 | + } | ||
| 324 | + foreach ($keyword as $item) { | ||
| 325 | + $url = 'https://' . $domain . '/' . $item; | ||
| 326 | + array_push($result, $url); | ||
| 327 | + } | ||
| 328 | + foreach ($news as $item) { | ||
| 329 | + $url = 'https://' . $domain . '/news/' . $item; | ||
| 330 | + array_push($result, $url); | ||
| 331 | + } | ||
| 332 | + foreach ($blog as $item) { | ||
| 333 | + $url = 'https://' . $domain . '/blogs/' . $item; | ||
| 334 | + array_push($result, $url); | ||
| 335 | + } | ||
| 336 | + return $this->success($result); | ||
| 337 | + } | ||
| 286 | } | 338 | } |
| @@ -80,18 +80,6 @@ class DetailController extends BaseController | @@ -80,18 +80,6 @@ class DetailController extends BaseController | ||
| 80 | 'data.required' => 'data不能为空', | 80 | 'data.required' => 'data不能为空', |
| 81 | ]); | 81 | ]); |
| 82 | 82 | ||
| 83 | - foreach ($this->param['data'] as $k => $data){ | ||
| 84 | - $i = 1; | ||
| 85 | - foreach ($data as $key => $v){ | ||
| 86 | - $data = [ | ||
| 87 | - 'sort'=>$i, | ||
| 88 | - 'column_id'=>$v['column_id'], | ||
| 89 | - 'product_id'=>$this->param['product_id'], | ||
| 90 | - 'title'=>$v['title'], | ||
| 91 | - 'content'=>json_encode($v['content']) | ||
| 92 | - ]; | ||
| 93 | - $i++; | ||
| 94 | - } | ||
| 95 | - } | 83 | + |
| 96 | } | 84 | } |
| 97 | } | 85 | } |
| @@ -160,6 +160,9 @@ class FileController | @@ -160,6 +160,9 @@ class FileController | ||
| 160 | $suffix = array_pop($nameArr) ?? 'jpg'; | 160 | $suffix = array_pop($nameArr) ?? 'jpg'; |
| 161 | $nameStr = implode('-', $nameArr); | 161 | $nameStr = implode('-', $nameArr); |
| 162 | $enName = generateRoute(Translate::tran($nameStr, 'en')); | 162 | $enName = generateRoute(Translate::tran($nameStr, 'en')); |
| 163 | + if(substr($enName, 0, 1) === '-'){ | ||
| 164 | + $enName = md5(uniqid().$project_id.rand(1,1000)); | ||
| 165 | + } | ||
| 163 | $fileName = $enName; | 166 | $fileName = $enName; |
| 164 | $i=1; | 167 | $i=1; |
| 165 | while($this->onlyName($enName.'.'.$suffix,$project_id)){ | 168 | while($this->onlyName($enName.'.'.$suffix,$project_id)){ |
| @@ -229,9 +229,13 @@ class ImageController extends Controller | @@ -229,9 +229,13 @@ class ImageController extends Controller | ||
| 229 | $nameArr = explode('.',$name); | 229 | $nameArr = explode('.',$name); |
| 230 | $suffix = array_pop($nameArr) ?? 'jpg'; | 230 | $suffix = array_pop($nameArr) ?? 'jpg'; |
| 231 | $nameStr = implode('-', $nameArr); | 231 | $nameStr = implode('-', $nameArr); |
| 232 | - $enName = generateRoute(Translate::tran($nameStr, 'en')); | 232 | + $tran_name = Translate::tran($nameStr, 'en'); |
| 233 | + if(is_array($tran_name)){ | ||
| 234 | + $tran_name = $tran_name[0]; | ||
| 235 | + } | ||
| 236 | + $enName = generateRoute($tran_name); | ||
| 233 | if(substr($enName, 0, 1) === '-'){ | 237 | if(substr($enName, 0, 1) === '-'){ |
| 234 | - $enName = $nameStr; | 238 | + $enName = md5(uniqid().$project_id.rand(1,1000));; |
| 235 | } | 239 | } |
| 236 | $fileName = $enName; | 240 | $fileName = $enName; |
| 237 | $i=1; | 241 | $i=1; |
| @@ -42,4 +42,25 @@ class DetailLogic extends BaseLogic | @@ -42,4 +42,25 @@ class DetailLogic extends BaseLogic | ||
| 42 | } | 42 | } |
| 43 | return $this->success(['id'=>$id]); | 43 | return $this->success(['id'=>$id]); |
| 44 | } | 44 | } |
| 45 | + | ||
| 46 | + public function saveDetail(){ | ||
| 47 | + foreach ($this->param['data'] as $k => $data){ | ||
| 48 | + $i = 1; | ||
| 49 | + $save_data = []; | ||
| 50 | + foreach ($data as $key => $v){ | ||
| 51 | + $save_data[] = [ | ||
| 52 | + 'sort'=>$i, | ||
| 53 | + 'column_id'=>$v['column_id'], | ||
| 54 | + 'product_id'=>$this->param['product_id'], | ||
| 55 | + 'title'=>$v['title'] ?? '', | ||
| 56 | + 'content'=>json_encode($v['content'] ?? []), | ||
| 57 | + 'css'=>json_encode($v['css'] ?? []), | ||
| 58 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 59 | + 'updated_at'=>date('Y-m-d H:i:s') | ||
| 60 | + ]; | ||
| 61 | + $i++; | ||
| 62 | + } | ||
| 63 | + $this->model->insert($save_data); | ||
| 64 | + } | ||
| 65 | + } | ||
| 45 | } | 66 | } |
| @@ -39,6 +39,9 @@ Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'v | @@ -39,6 +39,9 @@ Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'v | ||
| 39 | Route::any('getAutoToken', [\App\Http\Controllers\Api\PrivateController::class, 'getAutoToken'])->name('api.getAutoToken'); | 39 | Route::any('getAutoToken', [\App\Http\Controllers\Api\PrivateController::class, 'getAutoToken'])->name('api.getAutoToken'); |
| 40 | // 特殊项目 有效产品路由 | 40 | // 特殊项目 有效产品路由 |
| 41 | Route::any('valid_product_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProductRoute'])->name('api.valid_product_route'); | 41 | Route::any('valid_product_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProductRoute'])->name('api.valid_product_route'); |
| 42 | +// 6.0项目新增有效链接 - 提交Google | ||
| 43 | +Route::any('project_new_url', [\App\Http\Controllers\Api\PrivateController::class, 'projectNewUrl'])->name('api.project_new_url'); | ||
| 44 | + | ||
| 42 | 45 | ||
| 43 | // --------------------- 站群服务 ------------------------------------------ | 46 | // --------------------- 站群服务 ------------------------------------------ |
| 44 | // 获取项目信息 | 47 | // 获取项目信息 |
-
请 注册 或 登录 后发表评论