作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

<?php
namespace App\Http\Controllers\Aside\Drainage;
namespace App\Http\Controllers\Aside\GoogleSeoIps;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Projects\ProjectsLogic;
use App\Models\GoogleSeoIps\Country;
/**
* @remark :谷歌流量系统
... ... @@ -45,6 +46,7 @@ class ProjectsController extends BaseController
'id.required' => 'ID不能为空'
]);
}
//参数验证
$this->verifyParam();
$projectsLogic->projectsSave();
$this->response('success');
... ... @@ -86,6 +88,7 @@ class ProjectsController extends BaseController
'seo_type.required' => '引流方式不能为空',
]);
}
/**
* @remark :删除记录
* @name :del
... ... @@ -102,4 +105,20 @@ class ProjectsController extends BaseController
$projectsLogic->projectsDel();
$this->response('success');
}
/**
* @remark :获取国家
* @name :getCountry
* @author :lyh
* @method :post
* @time :2023/7/18 11:08
*/
public function getCountry(ProjectsLogic $projectsLogic){
if(isset($this->map['cname']) && !empty( $this->map['cname'])){
$this->map['cname'] = ['like','%'.$this->map['cname'].'%'];
}
$lists = $projectsLogic->getCountryList($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
<?php
namespace App\Http\Controllers\Aside\Drainage;
namespace App\Http\Controllers\Aside\GoogleSeoIps;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
... ... @@ -30,4 +30,25 @@ class ProjectsLogController extends BaseController
$lists = $projectsLogLogic->projectsLogLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :日志注释
* @name :setLog
* @author :lyh
* @method :post
* @time :2023/7/18 11:00
*/
public function getLog($param){
$data = [
'domain'=>$param['domain'],//域名
'seo_at'=>date('Y-m-d'),//日期
'ips_num'=>$param['ips_num'],//当天引流的IP数
'ips_ok'=>$param['ips_ok'],//当天已引流的IP数
'is_ok'=>$param['is_ok'],//是否跑完
'created_at'=>date('Y-m-d H:i:s'),
'ok_at'=>$param['ok_at'],//任务完成时间
'updated_at'=>date('Y-m-d H:i:s'),
'is_pushredis'=>$param['is_pushredis'],//是否推送redis
];
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\File\File;
use App\Models\File\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Cache;
class FileController
{
... ... @@ -21,20 +22,42 @@ class FileController
'Content-Description' => 'File Transfer',
],
];
public $path = '';
public $config = '';
public $path = '';//路径
public $uploads = '';
public $config = '';//存储默认配置
public $request = '';
public $request = '';//request
public $param = '';//参数
public $token = '';//token
public $cache = '';//缓存数据
public $image_type = [
1 => 'file_other',
];
public function __construct()
{
$this->request = request();
$this->param = $this->request->all();
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_file');
$this->path = $this->config['root'].$this->uploads['path'].'/';
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
if(!isset($this->token) || empty($this->cache)){
$this->response('请登录后上传',Code::USER_LOGIN_ERROE);
}
//上传路径设置
if(!isset($this->param['image_type'])){
$this->response('类型不能为空',Code::USER_ERROR);
}
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['file_type']].'/'.date('Y-m');
}else{
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['file_type']].'/'.date('Y-m');
}
}
/**
... ... @@ -44,7 +67,7 @@ class FileController
* @method :post
* @time :2023/5/9 9:15
*/
public function index($hash = '', $w = 1)
public function index($hash = '')
{
// 检查是否有修改日期或ETag头部
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
... ... @@ -56,7 +79,7 @@ class FileController
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$path = $this->path.$info['path'];
$path = $this->config['url'].'/'.$info['path'];
if (!is_file($path)) {
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
}
... ... @@ -122,12 +145,12 @@ class FileController
],[
'file.required'=>'必须填写',
]);
$files = $this->request->file('file');
$files = $this->param['file'];
if (empty($files)) {
$this->response('没有上传的文件!', 400);
}
$type = $this->request->post('type', 'single');
$type = $this->param['type'];
if ($type == 'multi') {
return $this->multi($files);
} else {
... ... @@ -151,14 +174,14 @@ class FileController
if($file_hash !== false){
return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
}
$url = $this->path;
$url = $this->config['url'].'/'.$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $files->move($url,$fileName);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $fileName,
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
... ... @@ -193,14 +216,14 @@ class FileController
$data[] = $hash;
continue;
}
$url = $this->path;
$url = $this->config['url'].'/'.$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $file->move($url,$fileName);
if ($res === false) {
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $fileName,
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
... ... @@ -281,7 +304,7 @@ class FileController
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$path = $info['path'];
$path = $this->config['url'].'/'.$info['path'];
if (!is_file($path)) {
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
}
... ...
... ... @@ -3,14 +3,16 @@
namespace App\Http\Controllers\File;
use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use App\Http\Controllers\type;
use App\Models\File\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
class ImageController
class ImageController extends Controller
{
public $upload_img = [
//设置静态缓存参数(304)
... ... @@ -25,20 +27,45 @@ class ImageController
];
const TYPE = 1;
public $path = '';
public $path = '';//路径
public $config = '';
public $config = '';//存储默认配置
public $thr_path = '';
public $request = '';//request
public $request = '';
public $param = '';//参数
public $token = '';//token
public $cache = '';//缓存数据
public $image_type = [
1 => 'image_product',
2 => 'image_news',
3 => 'image_blog',
4 => 'image_other',
];
public function __construct()
{
$this->request = request();
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
if(!isset($this->token) || empty($this->cache)){
$this->response('请登录后上传',Code::USER_LOGIN_ERROE);
}
$this->param = $this->request->all();
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_image');
$this->path = $this->config['root'].$this->uploads['path'].'/';
//上传路径设置
if(!isset($this->param['image_type'])){
$this->response('类型不能为空',Code::USER_ERROR);
}
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['image_type']].'/'.date('Y-m');
}else{
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['image_type']].'/'.date('Y-m');
}
}
/**
... ... @@ -61,7 +88,7 @@ class ImageController
$this->response('指定图片不存在!', Code::USER_ERROR);
}
//查看缩略图是否存在
$filename = $this->path . $info['hash'] . $w . '_' . $h;
$filename = $this->config['url'].'/'.$this->path . '/' . $info['hash'] . $w . '_' . $h;
if(is_file($filename)){
$last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
... ... @@ -69,7 +96,7 @@ class ImageController
$content = file_get_contents($filename);
$header['Content-Length'] = strlen($content);
}else{
$path = $this->path.$info['path'];
$path = $this->config['url'].'/'.$info['path'];
if (!is_file($path)) {
$this->response('指定图片已被系统删除!', Code::USER_ERROR);
}
... ... @@ -106,7 +133,7 @@ class ImageController
if (empty($files)) {
$this->response('没有上传的文件!', 400);
}
$type = $this->request->post('type', 'single');
$type = $this->param['type'];
if ($type == 'multi') {
return $this->multi($files);
} else {
... ... @@ -130,19 +157,19 @@ class ImageController
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
}
$url = $this->path;
$url = $this->config['url'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $files->move($url,$fileName);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $fileName,
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
'refer'=>$this->request->post('refer') ?? '',
'refer'=>$this->param['refer'] ?? '',
];
$rs = $imageModel->add($data);
if ($rs === false) {
... ... @@ -163,7 +190,7 @@ class ImageController
*/
private function cacheImage($info, $w, $h) {
$path = $info['path'];
$filename = $this->path . $info['hash'] . $w . '_' . $h;
$filename = $this->config['url'] . $this->path . $info['hash'] . $w . '_' . $h;
Image::make($path)->resize($w, $h)->save($filename);
return $filename;
}
... ... @@ -191,20 +218,20 @@ class ImageController
$data[] = ['image'=>$hash];
continue;
}
$url = $this->path;
$url = $this->config['url'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
$res = $file->move($url,$fileName);
if ($res === false) {
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $fileName,
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'updated_at'=>date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$file->getClientOriginalExtension(),
'refer'=>$this->request->post('refer') ?? '',
'refer'=>$this->param['refer'] ?? '',
];
$data[] = ['image'=>$hash];
}
... ... @@ -284,4 +311,5 @@ class ImageController
$lists = $imageModel->list([],$order = 'id',['id','hash','type','path','created_at']);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -8,7 +8,7 @@ use App\Models\Inquiry\InquiryInfo;
use App\Models\Inquiry\InquiryIP;
use App\Models\Project\DeployBuild;
use App\Models\Project\Keywords;
use App\Models\Projects\InquiryUser;
use App\Models\GoogleSeoIps\InquiryUser;
use Illuminate\Support\Facades\DB;
/**
... ...
... ... @@ -3,7 +3,7 @@
namespace App\Http\Logic\Aside\Projects;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Projects\ProjectsSeoTask;
use App\Models\GoogleSeoIps\ProjectsSeoTask;
/**
* @remark :谷歌流量日志记录
... ...
... ... @@ -3,7 +3,8 @@
namespace App\Http\Logic\Aside\Projects;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Projects\Projects;
use App\Models\GoogleSeoIps\Country as CountryModel;
use App\Models\GoogleSeoIps\Projects;
/**
* @remark :谷歌流量系统统计表
... ... @@ -87,4 +88,17 @@ class ProjectsLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :获取国家列表
* @name :getCountryList
* @author :lyh
* @method :post
* @time :2023/7/18 11:12
*/
public function getCountryList($map){
$countryModel = new CountryModel();
$lists = $countryModel->list($map);
return $this->success($lists);
}
}
... ...
... ... @@ -54,6 +54,7 @@ class CustomTemplateLogic extends BaseLogic
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}
if($rs === false){
... ...
<?php
namespace App\Models\GoogleSeoIps;
use App\Models\Base;
/**
* @remark :192.30.242.45引流国家设置
* @class :Country.php
* @author :lyh
* @time :2023/7/18 11:09
*/
class Country extends Base
{
//连接数据库
protected $connection = 'projects_mysql';
protected $table = 'country';
}
... ...
<?php
namespace App\Models\Projects;
namespace App\Models\GoogleSeoIps;
use App\Models\Base;
... ...
<?php
namespace App\Models\Projects;
namespace App\Models\GoogleSeoIps;
use App\Models\Base;
... ...
... ... @@ -67,7 +67,20 @@ return [
'visibility' => 'public',
],
//腾讯云对象存储
'cos' => [
'driver' => 'cosv5',
'region' => env('COS_REGION'),
'credentials' => [
'appId' => env('COS_APP_ID'),
'secretId' => env('COS_SECRET_ID'),
'secretKey' => env('COS_SECRET_KEY'),
],
'bucket' => env('COS_BUCKET'),
'cdn' => env('COS_CDN'),
'timeout' => 60,
'connect_timeout' => 60,
],
],
... ...
... ... @@ -19,34 +19,15 @@ return [
'size' => [
'max' => 1024*1024*2, // 2M
],
'path' => '/images'
'path_b' => '/p',
'path_a' => '/m',
],
//默认视频
'default_file' =>[
'size' => [
'max' => 1024*1024*20, // 2M
],
'path' => '/files'
],
//博客图
'blog' =>[
'size' => [
'max' => 1024*1024*2, // 2M
],
'path' => '/blog'
],
//新闻图
'news' =>[
'size' => [
'max' => 1024*1024*2, // 2M
],
'path' => '/news'
],
//项目相关
'project' =>[
'size' => [
'max' => 1024*1024*1024, // 2M
],
'path' => '/project'
'path_b' => '/p',
'path_a' => '/m',
],
];
... ...
... ... @@ -191,12 +191,13 @@ Route::middleware(['aloginauth'])->group(function () {
});
//谷歌流量系统
Route::prefix('projects')->group(function () {
Route::post('/', [Aside\Drainage\ProjectsController::class, 'lists'])->name('projects_lists');
Route::post('/save', [Aside\Drainage\ProjectsController::class, 'save'])->name('projects_save');
Route::post('/del', [Aside\Drainage\ProjectsController::class, 'del'])->name('projects_del');
Route::post('/', [Aside\GoogleSeoIps\ProjectsController::class, 'lists'])->name('projects_lists');
Route::post('/save', [Aside\GoogleSeoIps\ProjectsController::class, 'save'])->name('projects_save');
Route::post('/getCountry', [Aside\GoogleSeoIps\ProjectsController::class, 'getCountry'])->name('projects_getCountry');
Route::post('/del', [Aside\GoogleSeoIps\ProjectsController::class, 'del'])->name('projects_del');
//谷歌流量系统日志
Route::prefix('log')->group(function () {
Route::post('/', [Aside\Drainage\ProjectsLogController::class, 'lists'])->name('projectsLog_lists');
Route::post('/', [Aside\GoogleSeoIps\ProjectsLogController::class, 'lists'])->name('projectsLog_lists');
});
//优化gsc账号记录表
Route::prefix('gsc')->group(function () {
... ...