作者 邓超

Merge branch 'develop' into dc

正在显示 75 个修改的文件 包含 2120 行增加731 行删除
... ... @@ -47,7 +47,7 @@ class ShareUser extends Command
foreach ($ayr_share_list as $k => $v){
//查询当前用户是否有未推送的博文
$ayr_release = new AyrReleaseModel();
$release_info = $ayr_release->read(['idempotency_key'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
$release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
//有推文时,直接跳出循环
if($release_info !== false){
continue;
... ...
... ... @@ -45,7 +45,6 @@ class RankData extends BaseCommands
if(!$site_res){
return false;
}
foreach ($list as $item){
$model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '')->first();
if (!$model || $model->updated_date != date('Y-m-d')) {
... ... @@ -61,7 +60,8 @@ class RankData extends BaseCommands
}
//有小语种的
if($item['minor_languages']){
$lang_list = $api->getLangList();
if(!empty($lang_list[$item['api_no']])){
$model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '<>', '')->first();
if (!$model || $model->updated_date != date('Y-m-d')) {
$res = $api->getGoogleRank($item['api_no'], 1);
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 网站引流
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class WebTraffic extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'web_traffic {type}';
/**
* The console command description.
*
* @var string
*/
protected $description = '网站引流';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* google域名后缀
* @var string[]
*/
protected $suffix = [
'co.jp' => '日本',
'com.tr' => '土耳其',
'nl' => '荷兰',
'ru' => '俄罗斯',
'fr' => '法国',
'co.kr' => '韩国',
'fi' => '芬兰',
'be' => '比利时',
'lt' => '立陶宛',
'es' => '西班牙',
'it' => '意大利',
'com.au' => '澳大利亚',
'no' => '挪威',
'al' => '阿尔巴尼亚',
'pt' => '葡萄牙',
'lv' => '拉脱维亚',
'hu' => '匈牙利',
'cz' => '捷克',
'de' => '德国',
'ca' => '加拿大',
'co.in' => '印度',
'co.uk' => '英国',
'com.vn' => '越南',
'com.br' => '巴西',
'co.il' => '以色列',
'pl' => '波兰',
'com.eg' => '埃及',
'co.th' => '泰国',
'sk' => '斯洛伐克',
'ro' => '罗马尼亚',
'com.mx' => '墨西哥',
'com.my' => '马来西亚',
'com.pk' => '巴基斯坦',
'co.nz' => '新西兰',
'co.za' => '南非',
'com.ar' => '阿根廷',
'com.kw' => '科威特',
'com.sg' => '新加坡',
'com.co' => '哥伦比亚',
'co.id' => '印度尼西亚',
'gr' => '希腊',
'bg' => '保加利亚',
'mn' => '蒙古',
'dk' => '丹麦',
'com.sa' => '沙特阿拉伯',
'com.pe' => '秘鲁',
'com.ph' => '菲律宾',
'com.ua' => '乌克兰',
'ge' => '格鲁吉亚',
'ae' => '阿拉伯联合酋长国',
'tn' => '突尼斯',
];
/**
* 概率值
* @var int[]
*/
protected $sjjg = [720, 280];//访问间隔占比 访问|不访问
//访问页面类型占比 产品详情页、单页|产品分类页
protected $ymzb = [
'urls_cats' => 700,
'urls_details' => 300
];
protected $sdzb = [600, 200, 150, 50]; //访问页面深度占比 1页|2页|3-6页|7-11页
protected $yddzb = [1 => 700, 2 => 300]; //移动端占比 pc|mobile
//模拟访问来源占比 (美国)
protected $lyzb = [
'https://www.google.com/' => 630,
'http://www.google.com/' => 30,
'http://www.bing.com/' => 20,
'https://www.bing.com/' => 5,
'https://www.youtube.com/' => 5,
'https://search.yahoo.com/' => 5,
'https://www.facebook.com/' => 5,
];
protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀
protected $pc_ua = [
0 => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
1 => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
2 => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
];
protected $mobile_ua = [
0 => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19',
];
/**
* @return bool
*/
public function handle()
{
$type = $this->argument('type');
$this->sleep($type);
$project_list = $this->getProjectList($type);
$project_chunk = array_chunk($project_list,500,true);
foreach ($project_chunk as $chunk) {
$need_project = [];
foreach ($chunk as $project) {
//随机引流间隔
$res_sjjg = $this->get_rand($this->sjjg);
if ($res_sjjg == 1) {
continue;
}
$project_urls = $this->getProductUrls($project['project_id']);
$project_urls['home'] = $project['domain'];
//随机访问页面
$project['visit_urls'] = $this->getVisitUrls($project_urls);
//随机客户端
$project['device_port'] = $this->get_rand($this->yddzb);
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
//最多10层深度
$client = new Client(['verify' => false]);
for ($j = 0; $j < 10; $j++) {
for ($j = 0; $j < 10; $j++) {
//并发请求
$promises = [];
foreach ($need_project as $project_key => $project) {
if (empty($project['visit_urls'][$j])) {
continue;
}
$data = [
'ip' => $ips[$project_key]['ip'],
'referer' => $this->getReferer($ips[$project_key]['ip_area']),
'url' => $project['visit_urls'][$j],
'device_port' => $this->get_rand($this->yddzb)
];
$promises[] = $client->postAsync($project['domain'] . 'api/customerVisit', ['form_params' => $data]);
}
Utils::settle($promises)->wait();
//每个深度随机等待
sleep(rand(2, 10));
}
}
}
}
/**
* 不同项目 休眠
*/
protected function sleep($type){
if($type == 1){ //1-3个月的项目
sleep(rand(5,480));
}elseif($type == 2){ //4-8个月的项目
sleep(rand(5,240));
}elseif($type == 3){ // 大于9个月的项目
sleep(rand(5,120));
}
}
/**
* 引流的项目
*/
protected function getProjectList($type){
//todo 根据type获取需要引流的项目
return [
[
'project_id' => 1,
'domain' => 'https://demomark.globalso.com/',
]
];
}
/**
* 获取产品分类、单页和详情链接
*/
protected function getProductUrls($project_id){
//产品分类页面
$product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray();
$data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray();
//单页面
//todo 发布状态的单页面id
$data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray();
//产品详情页
$product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray();
$data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray();
$data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
if(empty($data['urls_cats'])){
$data['urls_cats'] = $data['urls_details'];
}
return $data;
}
/**
* 获取地区IP
*/
protected function getIpAreas($num)
{
//本地时间为7-23点的地区
$h = date('H');
$areas = [];
$list = DB::table('gl_area_timezone')->get();
foreach ($list as $v) {
$v = (array)$v;
$country_hour = $h + $v['diff'];
if ($country_hour < 0) {
$country_hour = 24 + $country_hour;
}
if ($country_hour >= 7 && $country_hour < 23) {
$areas[] = $v['name'];
}
}
//根据地区随机取该地区的IP
$data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get();
return Arr::s2a(Arr::a2s($data));
}
/**
* 概率算法
*/
protected function get_rand($proArr) {
$result = '';
$proSum = array_sum($proArr);
foreach ($proArr as $key => $proCur) {
$randNum = mt_rand(1, $proSum);
if ($randNum <= $proCur) {
$result = $key;
break;
} else {
$proSum -= $proCur;
}
}
unset ($proArr);
return $result;
}
/**
* 根据随机访问深度 随机获取访问页面
*/
protected function getVisitUrls($project_urls){
//没有分类页 就只访问首页
if(!$project_urls['urls_cats']){
$url[] = $project_urls['home'];
return $url;
}
//随机访问深度
$res_sdzb = $this->get_rand($this->sdzb);
//随机访问页面类型
$res_ymzb = $this->get_rand($this->ymzb);
$all_url = array_merge($project_urls['urls_cats'],$project_urls['urls_details']);
if(!$all_url){
$url[] = $project_urls['home'];
return $url;
}
$url = [];
if($res_sdzb == 0){//深度一页
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
}elseif($res_sdzb == 1){//深度两页
$url[] = $project_urls['home'];
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
}elseif($res_sdzb == 2){//深度3-6页
$yms = rand(2,5); //随机页面数
$url = Arr::pluck(Arr::random($all_url, $yms), 'route');
$url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去
}elseif($res_sdzb == 3){//深度7-11页
$yms = rand(6,10); //随机页面数
$url = Arr::pluck(Arr::random($all_url, $yms), 'route');
$url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去
}
foreach ($url as &$v){
if(!Str::contains($v, $project_urls['home'])){
$v = $project_urls['home'] . $v;
}
}
return array_unique(array_filter($url));
}
/**
* 获取访问来路
*/
protected function getReferer($ip_area){
if($ip_area == '美国'){
$referer = $this->get_rand($this->lyzb);
}else{
$referer = 'https://www.google.com/';
$suffix = array_search($ip_area, $this->suffix);
if($suffix){
$res_qtzb = $this->get_rand($this->otherzb);
if($res_qtzb == 1){
$referer = 'https://www.google.'.$suffix.'/';
}
}
}
return $referer;
}
}
... ...
... ... @@ -23,6 +23,9 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
$schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
}
/**
... ...
... ... @@ -18,5 +18,4 @@ final class Common extends Enum
//端
const A='a';
const B='b';
const C='c';
}
... ...
<?php
namespace App\Exceptions;
use App\Enums\Common\Code;
use Exception;
use Throwable;
/**
* @notes: C端接口统一错误格式
* Class CsideGlobalException
* @package App\Exceptions
*/
class CsideGlobalException extends Exception
{
public function __construct($code = 0, $message = "", Throwable $previous = null)
{
$this->code = $code;
$this->message = $message;
if (empty($this->message)) {
$this->message = Code::fromValue($code)->description;
}
}
}
... ... @@ -72,10 +72,6 @@ class Handler extends ExceptionHandler
elseif($exception instanceof BsideGlobalException) {
LogUtils::error("BsideGlobalException", [], $exceptionMessage);
}
//C端错误
elseif($exception instanceof CsideGlobalException) {
LogUtils::error("CsideGlobalException", [], $exceptionMessage);
}
//验证错误(非手动抛出)
elseif ($exception instanceof ValidationException) {
LogUtils::error("参数验证失败", [], $exceptionMessage);
... ... @@ -114,9 +110,7 @@ class Handler extends ExceptionHandler
$code = $exception->getCode();
}elseif ($exception instanceof BsideGlobalException) {
$code = $exception->getCode();
}elseif ($exception instanceof CsideGlobalException) {
$code = $exception->getCode();
} elseif ($exception instanceof ValidationException) {
}elseif ($exception instanceof ValidationException) {
$code = Code::USER_PARAMS_ERROE();
$message = $code->description = Arr::first(Arr::first($exception->errors()));
} elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) {
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Helper;
use Illuminate\Support\Collection;
/**
* 数组类函数
* Class Arrays
... ... @@ -185,4 +187,29 @@ class Arr extends \Illuminate\Support\Arr
}
return $str ?: [];
}
/**
* 将数组设置成某个键的值
* @param $arr
* @param $key
* @return array
* @author zbj
* @date 2023/5/16
*/
public static function setValueToKey($arr, $key)
{
$data = [];
if (!$arr) {
return $data;
}
foreach ($arr as $v) {
$data[$v[$key]] = $v;
}
if ($arr instanceof Collection) {
$data = new Collection($data);
}
return $data;
}
}
... ...
... ... @@ -67,7 +67,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
*/
public function deleted_profiles($data){
$param = [
'title'=>$data['title'],
// 'title'=>$data['title'],
'profileKey'=>$data['profileKey'],
];
$url = $this->path.'/api/profiles/profile';
... ... @@ -103,6 +103,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
return $this->http_click('get',$url,[],$this->headers);
}
/**
* @name :(发帖)post_send_msg
* @author :lyh
... ... @@ -113,12 +114,31 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
*/
public function post_send_msg($param,$api_key){
//平台参数处理
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$param['idempotencyKey'] = uniqid().time();
$url = $this->path.'/api/post';
return $this->http_click('posts',$url,$param,$this->headers);
return $this->http_post_ayr($url,$param,$api_key);
}
public function http_post_ayr($url,$param,$api_key){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query($param),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$api_key,
'Accept-Encoding: gzip'
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
/**
* @name :(上传图片或视频到ayr_share)post_media_upload
* @author :lyh
... ...
<?php
namespace App\Helper;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
/**
* Class FormGlobalsoApi
* @package App\Helper
* @author zbj
* @date 2023/5/17
*/
class FormGlobalsoApi
{
//接口地址
protected $url = 'https://form.globalso.com';
/**
* 设置询盘通知
* @author zbj
* @date 2023/5/17
*/
public function setInquiry($domain, $emails, $phones)
{
$api_url = $this->url . '/api/external-project/save/dc77a54480b184c4';
$params = [
'token' => md5($domain.$emails.$phones.date("Y-m-d")),
'domain' => $domain,
'email' => $emails,
'phone' => $phones,
];
try {
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('设置询盘通知', $params, $e);
return false;
}
return $res;
}
/**
* 询盘列表
* @author zbj
* @date 2023/5/17
*/
public function getInquiryList($domain, $search = '', $page = 1, $page_size = 20)
{
$api_url = $this->url . '/api/external-interface/6a1bd159b1fd60af';
$params = [
'token' => md5($domain.$search.date("Y-m-d")),
'domain' => $domain,
'limit' => $page_size,
'page' => $page,
'source' => '1,3' //来源类型 新项目用1,3
];
if($search){
$params['name'] = $search;
}
try {
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('询盘列表', $params, $e);
return false;
}
return $res;
}
/**
* 设置询盘信息已读
* @author zbj
* @date 2023/5/17
*/
public function saveInquiryRead($domain, $id)
{
$api_url = $this->url . '/api/external-interface/save/d1483a8e57cb485a';
$params = [
'token' => md5($domain.$id.date("Y-m-d")),
'domain' => $domain,
'id' => $id,
];
try {
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('设置询盘信息已读', $params, $e);
return false;
}
return $res;
}
/**
* 删除询盘信息
* @author zbj
* @date 2023/5/17
*/
public function delInquiry($domain, $ids)
{
$api_url = $this->url . '/api/external-interface/del/c4b11cf6f1508489';
$ids = Arr::arrToSet($ids);
$params = [
'token' => md5($domain.$ids.date("Y-m-d")),
'domain' => $domain,
'id' => $ids,
];
try {
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('删除询盘信息', $params, $e);
return false;
}
return $res;
}
}
... ...
... ... @@ -202,5 +202,34 @@ class QuanqiusouApi
return $res;
}
/**
* 获取项目小语种信息
* @return array|false|int|mixed|null
* @author zbj
* @date 2023/5/15
*/
public function getLangRankData($api_no)
{
$key = "quanqiusou_get_language_rank_data_{$api_no}_" . date('Y-m-d');
$res = Cache::get($key);
if (!$res) {
$api_url = $this->url . '/api/index/get_language_rank_data';
$param = [
'apino' => $api_no,
];
try {
$res = HttpUtils::get($api_url, $param);
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 24 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取项目小语种数据失败', [], $e);
return false;
}
}
return $res;
}
}
... ...
... ... @@ -64,7 +64,7 @@ if(!function_exists('http_post')){
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
if (curl_errno($ch)) {
Log::write(print_r(curl_errno($ch),1),'debug---1');
\Illuminate\Support\Facades\Log::write(print_r(curl_errno($ch),1),'debug---1');
}
curl_close($ch);
return json_decode($res, true);
... ... @@ -139,7 +139,7 @@ if (!function_exists('checkDomain')) {
return false;
}
if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) {
return $scheme . '://' . $host;
return $scheme . '://' . $host . '/';
} else {
return false;
}
... ...
<?php
namespace App\Http\Controllers\Aside\Devops;
use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServerInformationLogic;
use App\Http\Requests\Aside\Devops\ServerInformationRequest;
use App\Models\Devops\ServerInformation;
use App\Models\Devops\ServerInformationLog;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class ServerInformationController extends BaseController
{
/**
* @return JsonResponse
*/
public function lists($deleted = ServerInformation::DELETED_NORMAL)
{
$size = request()->input('size', $this->row);
$data = ServerInformation::query()->select(['id', 'title', 'ip'])
->where('deleted', $deleted)
->orderBy('id', 'desc')
->paginate($size);
return $this->response('success', Code::SUCCESS, $data);
}
/**
* 添加
* @param ServerInformationRequest $serverInformationRequest
* @param ServerInformationLogic $serverInformationLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function add(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic)
{
$serverInformationRequest->validated();
$serverInformationLogic->create();
$this->response('服务器添加成功!');
}
/**
* 编辑
* @param ServerInformationRequest $serverInformationRequest
* @param ServerInformationLogic $serverInformationLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic)
{
$serverInformationRequest->validate([
'id' => ['required'],
], [
'id.required' => 'ID不能为空',
]);
$serverInformationLogic->update();
$this->response('服务器修改成功!');
}
/**
* 删除
* @param ServerInformationLogic $serverInformationLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function delete(ServerInformationLogic $serverInformationLogic)
{
$serverInformationLogic->get_batch_update();
$this->response('服务器删除成功!');
}
/**
* 获取软删除的数据
* @return JsonResponse
*/
public function delete_list()
{
return $this->lists(ServerInformation::DELETED_DELETE);
}
/**
* 恢复数据
* @param ServerInformationLogic $serverInformationLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function restore(ServerInformationLogic $serverInformationLogic)
{
$serverInformationLogic->get_batch_update(ServerInformationLog::ACTION_RECOVER, ServerInformation::DELETED_DELETE);
$this->response('服务器恢复成功!');
}
/**
* 搜索
* @param Request $request
* @return JsonResponse
*/
public function search(Request $request)
{
$search = [];
$ip = $request->input('ip');
if ($ip) {
$search['ip'] = $ip;
}
$remark = $request->input('title');
if ($remark) {
$search['title'] = $remark;
}
if (empty($search)) {
return $this->response('请输入搜索内容', Code::USER_ERROR);
}
$query = ServerInformation::query()->select(['id', 'title', 'ip']);
foreach ($search as $key => $item) {
$query = $query->Where("{$key}", 'like', "%{$item}%");
}
$size = $request->input('size', $this->row);
$query = $query->orderBy('id', 'desc')->paginate($size);
return $this->response('success', Code::SUCCESS, $query);
}
/**
* 服务器信息
* @param int $deleted
* @return JsonResponse
* @throws AsideGlobalException
* @throws BsideGlobalException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL)
{
$serverInformationLogic = new ServerInformationLogic();
$data = $serverInformationLogic->serverInfo($deleted);
if (!$data) {
return $this->response('服务器信息不存在', Code::USER_ERROR);
}
return $this->success($data->toArray());
}
/**
* @return JsonResponse
* @throws AsideGlobalException
* @throws BsideGlobalException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDeleteServerInfo()
{
return $this->getServerInfo(ServerInformation::DELETED_DELETE);
}
}
... ...
<?php
namespace App\Http\Controllers\Aside\Devops;
use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServerInformationLogic;
use App\Http\Requests\Aside\Devops\ServerInformationRequest;
use App\Models\Devops\ServerInformation;
use App\Models\Devops\ServerInformationLog;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class ServerInformationLogController extends BaseController
{
public function lists(Request $request)
{
$size = $request->input('size', $this->row);
$data = ServerInformationLog::query()
->orderBy('id', 'desc')
->paginate($size);
return $this->response('success', Code::SUCCESS, $data);
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Requests\Aside\Project\ProjectRequest;
use App\Models\InquirySet;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -47,4 +48,34 @@ class ProjectController extends BaseController
$data = $logic->save($this->param);
return $this->success($data);
}
/**
* 询盘通知设置
* @param ProjectRequest $request
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/5/17
*/
public function inquiry_set(Request $request, ProjectLogic $logic){
$request->validate([
'project_id'=>'required'
],[
'project_id.required' => '项目ID不能为空'
]);
if($request->isMethod('get')){
$data = InquirySet::where('project_id', $request->project_id)->first();
if(!$data){
$data = ['emails' => '', 'phones' => ''];
}else{
$data = $data->toArray();
}
return $this->success($data);
}
$data = $logic->saveInquirySet($this->param);
return $this->success($data);
}
}
... ...
<?php
namespace App\Http\Controllers\Aside\Template;
use App\Http\Controllers\Aside\BaseController;
/**
* 模板header footer
* @author:dc
* @time 2023/4/26 11:10
* Class HeaderFooterController
* @package App\Http\Controllers\Aside\Template
*/
class HeaderFooterController extends BaseController
{
}
... ...
... ... @@ -7,7 +7,7 @@ use App\Helper\AyrShare as AyrShareHelper;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
use App\Http\Requests\Bside\AyrRelease\AyrReleaseRequest;
use App\Http\Requests\Bside\AyrShare\AyrReleaseRequest;
/**
* @name:社交发布
... ... @@ -34,7 +34,7 @@ class AyrReleaseController extends BaseController
}
/**
* @name :(获取当前用户已绑定的社交链接)info
* @name :(获取当前用户已绑定的社交链接)
* @author :lyh
* @method :post
* @time :2023/5/9 16:00
... ... @@ -43,9 +43,9 @@ class AyrReleaseController extends BaseController
$this->request->validate([
'share_id'=>['required']
],[
'share_id.required' => 'SHARE_ID不能为空'
'share_id.required' => 'share_id不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
$info = $ayrShareLogic->ayr_share_info($this->param['share_id']);
$this->response('success',Code::SUCCESS,$info);
}
/**
... ... @@ -58,27 +58,32 @@ class AyrReleaseController extends BaseController
AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){
$ayrReleaseRequest->validated();
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
$share_info = $ayrShareLogic->ayr_share_info($this->param['share_id']);
//验证发送平台
$ayrShareLogic->verify_param($share_info);
$data = [
'images'=>$this->param['images'],
'files'=>$this->param['video'],
];
if(isset($this->param['video']) && !empty($this->param['video'])){
$data['files'] = $this->param['video'];
}
if(isset($this->param['images']) && !empty($this->param['images'])){
$data['images'] = $this->param['images'];
}
//参数处理
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);;
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);
//时间处理
$datetime = new \DateTime($this->param['schedule_date']);
$formattedTime = $datetime->format("Y-m-d\TH:i:s\Z");
//统一生成发布
$param = [
'post'=>$this->param['content'],
'platforms'=>$this->param['platforms'],
'mediaUrls'=>$this->param['mediaUrls'],//参数处理
'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布)
'scheduleDate'=>$formattedTime,//时间(如是过去时间,立即发布)
];
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
//保存数据库
$ayrReleaseLogic->release_add();
$this->response('success',Code::SUCCESS,$res);
$this->response('success',Code::SUCCESS,json_decode($res));
}
/**
... ... @@ -95,8 +100,6 @@ class AyrReleaseController extends BaseController
'share_id.required' => 'SHARE_ID不能为空',
'hash.required' => 'HASH不能为空'
]);
$image_info = $ayrShareLogic->save_img_info($this->param['hash']);
if(empty($image_info['ayr_id'])){
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
//向第三方存储图片
... ... @@ -106,8 +109,7 @@ class AyrReleaseController extends BaseController
$param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']);
//更新图片库
$ayrShareLogic->save_img($param_data);
}
$this->response('success',Code::SUCCESS,$image_info);
$this->response('success',Code::SUCCESS,$param_data);
}
/**
... ... @@ -124,8 +126,6 @@ class AyrReleaseController extends BaseController
'share_id.required' => 'SHARE_ID不能为空',
'hash.required' => 'HASH不能为空'
]);
$image_info = $ayrShareLogic->save_file_info($this->param['hash']);
if(empty($image_info['ayr_id'])){
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
//向第三方存储图片
... ... @@ -135,7 +135,6 @@ class AyrReleaseController extends BaseController
$param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']);
//更新图片库
$ayrShareLogic->save_file($param_data);
}
$this->response('success');
}
}
... ...
... ... @@ -40,7 +40,7 @@ class AyrShareController extends BaseController
}
}
}
$lists['list']['share_list'] = $share_list;
$lists['share_list'] = $share_list;
$this->response('列表',Code::SUCCESS,$lists);
}
... ... @@ -52,9 +52,9 @@ class AyrShareController extends BaseController
*/
public function save_account(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'share_id'=>['required'],
'id'=>['required'],
],[
'share_id.required' => 'SHARE_ID不能为空',
'id.required' => 'ID不能为空',
]);
$info = $ayrShareLogic->ayr_share_info();
$ayrShareHelper = new AyrShareHelper();
... ... @@ -62,12 +62,14 @@ class AyrShareController extends BaseController
if(isset($share_info['activeSocialAccounts'])){
$str = json_encode($share_info['activeSocialAccounts']);
if($str != $info['bind_platforms']){
$res = $ayrShareLogic->ayr_share_edit(['bind_platforms'=>$str],$this->param['share_id']);
$ayrShareLogic->ayr_share_edit(['bind_platforms'=>$str],$this->param['id']);
$res = true;
}else{
$res = false;
}
}else{
$res = $ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['share_id']);
$ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['id']);
$res = true;
}
$this->response('success',Code::SUCCESS,['is_true'=>$res]);
}
... ... @@ -107,7 +109,7 @@ class AyrShareController extends BaseController
]);
$info = $ayrShareLogic->ayr_share_info();
$data = [
'title'=>$info['title'],
// 'title'=>$info['title'],
'profileKey'=>$info['profile_key']
];
//发送请求删除社交用户
... ...
... ... @@ -3,12 +3,16 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\AyrShare as AyrShareHelper;
use App\Helper\Country;
use App\Models\AyrShare\AyrRelease as AyrReleaseModel;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use App\Models\Project\Project;
use App\Models\Project\Project as ProjectModel;
use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User as UserModel;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
... ... @@ -116,8 +120,60 @@ class ComController extends BaseController
$this->response('success');
}
public function get_country(){
$country = new Country();
return $country->set_country();
}
/**
* @name : (测试定时任务)检测用户是否无操作记录
* @author :lyh
* @method :post
* @time :2023/5/12 14:55
*/
// protected function ceShi(){
// $this->error = 0;
// //获取所有ayr_share用户
// $ayr_share_model = new AyrShareModel();
// $ayr_share_list = $ayr_share_model->list($this->map);
// if(!empty($ayr_share_list)){
// foreach ($ayr_share_list as $k => $v){
// //查询当前用户是否有未推送的博文
// $ayr_release = new AyrReleaseModel();
// $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
// //有推文时,直接跳出循环
// if($release_info !== false){
// continue;
// }
// //查看用户是否在一周内有发送博客
// $start_at = Carbon::now()->modify('-7 days')->toDateString();
// $end_at = Carbon::now()->toDateString();
// $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]);
// //有发送博文,则跳出循环
// if($release_info == false){
// continue;
// }
// //删除用户第三方配置
// $ayr_share_helper = new AyrShareHelper();
// $data_profiles = [
// 'title'=>$v['title'],
// 'profileKey'=>$v['profile_key']
// ];
// $res = $ayr_share_helper->deleted_profiles($data_profiles);
// if($res['status'] == 'fail'){
// $this->error++;
// continue;
// }
// //更新数据库
// $data = [
// 'title'=>null,
// 'bind_plat_from'=>null,
// 'profile_key'=>null,
// 'ref_id'=>null,
// ];
// $res = $ayr_share_model->edit($data,['id'=>$v['id']]);
// if($res == false){
// $this->error++;
// }
// }
// }
// return $this->error;
// }
}
... ...
... ... @@ -2,16 +2,12 @@
namespace App\Http\Controllers\Bside;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Http\Logic\Bside\InquiryLogic;
use App\Http\Requests\Bside\InquiryRequest;
use App\Rules\Ids;
use App\Services\BatchExportService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\ValidationException;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* 精准询盘
... ... @@ -25,23 +21,18 @@ class InquiryController extends BaseController
public function index(InquiryLogic $logic)
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['name|email|content', 'like', "%{$this->param['search']}%"];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'created_at']);
$data = $logic->getApiList();
return $this->success($data);
}
public function info(Request $request, InquiryLogic $logic){
$request->validate([
'id'=>'required'
'id' => 'required',
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'content', 'trans_content', 'created_at']));
return $this->success($data);
}
public function delete(Request $request, InquiryLogic $logic)
... ... @@ -52,8 +43,8 @@ class InquiryController extends BaseController
'ids.required' => 'ID不能为空'
]);
$data = $logic->delete($this->param['ids']);
return $this->success($data);
$logic->delete($this->param['ids']);
return $this->success();
}
/**
... ... @@ -66,22 +57,20 @@ class InquiryController extends BaseController
*/
public function export(InquiryLogic $logic)
{
$sort = ['id' => 'desc'];
//最多到1w条
$data = $logic->getList([], $sort, ['name', 'email', 'phone', 'url', 'ip', 'ip_country', 'content', 'created_at'], 10000);
$data = $logic->getApiList(true);
$data = $data['list'] ?? [];
foreach ($data as &$item){
$item['ip_address'] = "{$item['ip_country']}({$item['ip']})";
$item['ip_address'] = "{$item['country']}({$item['ip']})";
}
$map = [
'created_at' => '询盘发送时间',
'submit_time' => '询盘发送时间',
'name' => '姓名',
'email' => '邮箱',
'phone' => '电话',
'ip_address' => '访问国家/地区(IP)',
'url' => '发送页面',
'content' => '询盘内容',
'refer' => '发送页面',
'message' => '询盘内容',
];
//生成文件,发送到客户端
... ...
... ... @@ -25,13 +25,7 @@ class CategoryController extends BaseController
$map[] = ['title', 'like', "%{$this->param['search']}%"];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
foreach ($data as &$v){
$v['product_num'] = $logic->getProductNum($v['id']);
}
if(!$map){
$data = Arr::listToTree($data);
}
$data = $logic->getList($map, $sort, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
return $this->success($data);
}
... ... @@ -42,7 +36,7 @@ class CategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status']));
return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status', 'route', 'url']));
}
public function save(CategoryRequest $request, CategoryLogic $logic)
... ...
... ... @@ -26,13 +26,7 @@ class KeywordController extends BaseController
$map[] = ['title', 'like', "%{$this->param['search']}%"];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']);
foreach ($data['list'] as &$v){
$v['product_num'] = $logic->getProductNum($v['id']);
$v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
//todo 获取域名 拼接链接
$v['url'] = $v['route'];
}
$data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']);
return $this->success($data);
}
... ... @@ -43,7 +37,7 @@ class KeywordController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at']));
return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url']));
}
public function save(KeywordRequest $request, KeywordLogic $logic)
... ...
... ... @@ -55,7 +55,7 @@ class ProductController extends BaseController
$map[] = ['status', $this->param['status']];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
$data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
return $this->success($data);
}
... ... @@ -66,8 +66,8 @@ class ProductController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content',
'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route']));
return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content',
'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route', 'url']));
}
public function save(ProductRequest $request, ProductLogic $logic)
... ...
... ... @@ -3,12 +3,17 @@
namespace App\Http\Controllers\Bside;
use App\Helper\Arr;
use App\Helper\GoogleSpeedApi;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Bside\RankDataLogic;
use App\Models\RankData\RankData;
use App\Models\RankData\Speed as GoogleSpeedModel;
use App\Services\BatchExportService;
use App\Utils\HttpUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Support\Facades\Storage;
/**
... ... @@ -70,14 +75,23 @@ class RankDataController extends BaseController
* @date 2023/5/15
*/
public function export(RankDataLogic $logic){
$lang = $this->request['lang'] ??'';
$data = $logic->keywords_rank_list(true);
$img_position = $video_position= false;
foreach ($data as &$item){
$item['domain'] = explode(':', $item['domain'])[1];
$item['lang'] = $this->request['lang'] ?: 'en';
$item['g_text'] = $item['g'] == 1 ? '主关键词' : '拓展关键词';
$item['g_text'] = RankData::gMap()[$item['g']]??'';
$item['img_position'] = $item['img_position'] ?? '';
$item['video_position'] = $item['video_position'] ?? '';
foreach ($item['position'] as $date => $position){
$item[$date] = $position;
}
if(!empty($item['img_position'])){
$img_position = true;
}
if(!empty($item['video_position'])){
$video_position = true;
}
}
$map = [
... ... @@ -89,9 +103,11 @@ class RankDataController extends BaseController
foreach ($data[0]['position'] as $date => $position){
$map[$date] = $date;
}
$img_position && $map['img_position'] = '图片';
$video_position && $map['video_position'] = '视频';
//生成文件,发送到客户端
$table = new BatchExportService("关键词数据导出");
$table = new BatchExportService($lang . "关键词数据导出");
$file = $table->head($map)->data($data)->save();
if (!$file) {
throw new \Exception('文件生成失败,请重试');
... ... @@ -102,7 +118,7 @@ class RankDataController extends BaseController
}
/**
* 数据导出
* 历史数据导出
* @author zbj
* @date 2023/5/15
*/
... ... @@ -148,4 +164,56 @@ class RankDataController extends BaseController
// return Storage::disk('runtime')->download($file); //直接下载
return $this->success(['url' => $fileurl]);
}
/**
* 实时获取关键词排名
* @author zbj
* @date 2023/5/16
*/
public function get_google_rank(){
$url_arr = parse_url($this->request['url']);
$param = [
'keyword' => trim($this->request['keyword']),
'url' => $url_arr['host'] ?? $url_arr['path'],
'extend_urls' => $this->request['extend_urls'],
'lang' => $this->request['lang'],
'use_groups' => 2
];
if ($this->request['w']) {
$data = [
'position' => 0,
'image_position' => 0,
'video_position' => 0,
];
$client = new Client([
'base_uri' => 'http://45.136.131.71:8000',
'timeout' => '20'
]);
$promises['position'] = $client->getAsync('/luminati_rank?'.Arr::query($param));
$promises['image_position'] = $client->getAsync('/google_image?'.Arr::query($param));
$promises['video_position'] = $client->getAsync('/google_video?'.Arr::query($param));
// 等待所有请求响应完成
$results = Utils::settle($promises)->wait();
foreach ($results as $key => $result) {
if ($result['state'] == 'fulfilled') {
$res = Arr::s2a($result['value']->getBody()->getContents());
$data[$key] = $res['position'] ?? 0;
}
}
}else{
$data = [
'position' => 0,
];
$res = HttpUtils::get('http://45.136.131.71:8000/luminati_rank', $param);
if ($res) {
$res = Arr::s2a($res);
$data['position'] = $res['position'];
}
}
return $this->success($data);
}
}
... ...
... ... @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController
* @time :2023/5/8 16:23
*/
public function save(WebSettingReceivingLogic $webSettingReceivingLogic){
$lists = $webSettingReceivingLogic->setting_receiving_save();
$webSettingReceivingLogic->setting_receiving_save();
$this->response('success');
}
}
... ...
<?php
namespace App\Http\Controllers\Bside\Template;
use App\Http\Controllers\Bside\BaseController;
/**
* 模板header footer
* @author:dc
* @time 2023/4/26 11:10
* Class HeaderFooterController
* @package App\Http\Controllers\Bside\Template
*/
class HeaderFooterController extends BaseController
{
}
... ...
<?php
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\DeptUserLogic;
use App\Models\User\ViewDeptUser;
class DeptUserController extends BaseController
{
/**
* @name :name
* @return void
* @author :liyuhang
* @method
*/
public function lists(ViewDeptUser $viewDeptUser){
$this->map['project_id'] = $this->user['project_id'];
$lists = $viewDeptUser->lists($this->map,$this->page,$this->row,'user_id');
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @param ViewDeptUser $viewDeptUser
* @name :(详情)info
* @author :lyh
* @method :post
* @time :2023/5/18 9:32
*/
public function info(ViewDeptUser $viewDeptUser){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'id不能为空'
]);
$info = $viewDeptUser->read($this->param);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :(部门添加与更新用户)add
* @author :lyh
* @method :post
* @time :2023/5/17 17:36
*/
public function save(DeptUserLogic $deptUserLogic){
$this->request->validate([
'dept_id'=>['required'],
'user_id'=>['required']
],[
'dept_id.required' => '组织架构id不能为空',
'user_id.required' => '用户id不能为空',
]);
$deptUserLogic->dept_user_save();
$this->response('success');
}
/**
* @name :(设置管理员)set_admin
* @author :lyh
* @method :post
* @time :2023/5/18 10:32
*/
public function set_admin(DeptUserLogic $deptUserLogic){
$this->request->validate([
'id'=>['required'],
'is_admin'=>['required'],
],[
'id.required' => 'id不能为空',
'is_admin.required' => 'is_admin不能为空',
]);
$deptUserLogic->dept_user_edit();
$this->response('success');
}
/**
* @name :(设置用户角色)set_role
* @author :lyh
* @method :post
* @time :2023/5/19 9:32
*/
public function set_role(DeptUserLogic $deptUserLogic){
$this->request->validate([
'id'=>['required'],
'role_id'=>['required'],
],[
'id.required' => '用户id不能为空',
'role_id.required' => 'role_id不能为空',
]);
$deptUserLogic->user_edit_role();
$this->response('success');
}
}
... ...
<?php
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Controllers\Bside\Ids;
use App\Http\Controllers\Bside\json;
use App\Http\Logic\Bside\ProjectGroupLogic;
use App\Http\Logic\Bside\User\GroupLogic;
use App\Http\Requests\Bside\User\ProjectGroupRequest;
use App\Models\User\ProjectGroup;
/**
* @name:用户组相关
*/
class ProjectGroupController extends BaseController
{
/**
* @name :用户组列表
* @return json
* @author :liyuhang
* @method
*/
public function lists(ProjectGroup $projectGroup)
{
$lists = $projectGroup->list($this->map,'id',['name','user_list','pid','id']);
$menu = [];
foreach ($lists as $k => $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$menu[] = $v;
}
}
$this->response('success',Code::SUCCESS,$menu);
}
/**
* @name :详情
* @return json
* @author :liyuhang
* @method
*/
public function info(GroupLogic $groupLogic){
$this->request->validate([
'id'=>['required', new Ids()],
],[
'id.required' => 'ID不能为空',
]);
$groupLogic->group_info();
$this->response('success');
}
/**
* @name:添加用户组获取用户列表
* @return void
* @author :liyuhang
* @method
*/
public function get_user_lists(GroupLogic $groupLogic){
$lists = $groupLogic->user_list();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @param ProjectGroupRequest $request
* @param ProjectGroupLogic $logic
* @name : 添加用户组
* @return void
* @author :liyuhang
* @method
*/
public function add(ProjectGroupRequest $request,GroupLogic $groupLogic){
$request->validated();
$groupLogic->group_add();
$this->response('success');
}
/**
* @param ProjectGroupRequest $request
* @param ProjectGroupLogic $logic
* @name :编辑用户组
* @return void
* @author :liyuhang
* @method
*/
public function edit(ProjectGroupRequest $request,GroupLogic $groupLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$groupLogic->group_edit();
$this->response('success');
}
/**
* @name :删除用户组
* @return void
* @author :liyuhang
* @method
*/
public function del(GroupLogic $groupLogic){
$this->request->validate([
'id'=>['required','array'],
],[
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$groupLogic->group_del();
$this->response('success');
}
}
... ... @@ -7,7 +7,9 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Controllers\Bside\json;
use App\Http\Logic\Bside\User\UserLogic;
use App\Http\Requests\Bside\User\UserRequest;
use App\Models\User\ProjectRole;
use App\Models\User\User as UserModel;
use App\Models\User\ViewDeptUser;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
... ... @@ -23,13 +25,21 @@ class UserController extends BaseController
//TODO::搜索参数统一处理
$this->map['project_id'] = $this->user['project_id'];
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']);
if(empty($lists)){
$this->response('error',Code::USER_ERROR,[]);
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(添加管理员获取角色菜单)role_list
* @author :lyh
* @method :post
* @time :2023/5/18 17:04
*/
public function role_list(ProjectRole $projectRole){
$list = $projectRole->list(['status'=>0,'project_id'=>$this->user['project_id']],'id');
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :添加管理员
* @return void
* @author :liyuhang
... ...
<?php
namespace App\Http\Controllers\Cside;
use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class BaseController extends Controller
{
protected $param = [];//所有请求参数
protected $token = ''; //token
protected $request = [];//助手函数
protected $project = [];//当前登录用户详情
/**
* 获取所有参数
*/
public function __construct(Request $request)
{
$this->request = $request;
$this->param = $this->request->all();
$this->token = $this->request->header('token');
if(!empty($this->token) && !empty(Cache::get($this->token))){
$info = Cache::get($this->token);
$this->user = $info;
$this->uid = $info['id'];
}
}
/**
* 成功返回
* @param array $data
* @param string $code
* @param bool $objectData
* @return JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
{
if ($objectData) {
$data = (object)$data;
}
$code = Code::fromValue($code);
$response = [
'code' => $code->value,
'data' => $data,
'msg' => $code->description,
];
return response()->json($response,200);
}
}
<?php
namespace App\Http\Controllers\Cside;
use App\Http\Logic\Cside\InquiryLogic;
use App\Http\Requests\Cside\InquiryRequest;
/**
* 精准询盘
* Class InquiryController
* @package App\Http\Controllers\Bside
* @author zbj
* @date 2023/5/4
*/
class InquiryController extends BaseController
{
public function save(InquiryRequest $request, InquiryLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
}
}
... ... @@ -44,7 +44,7 @@ class FileController
* @method :post
* @time :2023/5/9 9:15
*/
public function index($hash = '', $type = 1)
public function index($hash = '', $w = 1)
{
// 检查是否有修改日期或ETag头部
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
... ...
... ... @@ -11,7 +11,6 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware;
use App\Http\Middleware\Bside\ParamMiddleware as BsideParamMiddleware;
use App\Http\Middleware\Aside\LoginAuthMiddleware as AsideLoginAuthMiddleware;
use App\Http\Middleware\Bside\LoginAuthMiddleware as BsideLoginAuthMiddleware;
use App\Http\Middleware\Cside\ParamMiddleware as CsideParamMiddleware;
use App\Http\Middleware\PreventRepeatQuitCallMiddleware;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
... ... @@ -77,11 +76,6 @@ class Kernel extends HttpKernel
//允许跨域请求
EnableCrossRequestMiddleware::class
],
//C端中间件组
'cside'=>[
//参数处理中间件--涉及-参数记录-参数加解密等
CsideParamMiddleware::class,
]
];
/**
... ...
<?php
namespace App\Http\Logic\Aside\Devops;
use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Devops\ServerInformation;
use App\Models\Devops\ServerInformationLog;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ServerInformationLogic extends BaseLogic
{
/**
* @var array
*/
private $param;
public function __construct()
{
parent::__construct();
$this->model = new ServerInformation();
$this->param = $this->requestAll;
}
/**
* 添加数据
* @return array
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function create()
{
$request = $this->param;
$service = new ServerInformation();
$this->extracted($request, $service);
if ($this->checkIp($service->ip)) {
return $this->fail('服务器信息添加失败,ip已存在');
}
DB::beginTransaction();
if ($service->save()) {
$original = [
'id' => $service->id,
'type' => $service->type,
'ip' => $service->ip,
'title' => $service->title,
'belong_to' => $service->belong_to,
'sshpass' => $service->sshpass,
'ports' => $service->ports,
];
// 添加日志
$this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id);
DB::commit();
return $this->success();
}
DB::rollBack();
return $this->fail('服务器信息添加失败');
}
/**
* 修改数据
* @return array
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function update()
{
$service = new ServerInformation();
$fields_array = $service->FieldsArray();
$request = $this->param;
$service = $this->ServerInfo();
$original = $service->toArray();
$this->extracted($request, $service);
// 检查ip是否存在
if ($service->ip != $request['ip']) {
if ($this->checkIp($request['ip'])) {
$this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR);
}
}
DB::beginTransaction();
if ($service->save()) {
$revised = [
'id' => $service->id,
'type' => $service->type,
'ip' => $service->ip,
'title' => $service->title,
'belong_to' => $service->belong_to,
'sshpass' => $service->sshpass,
'ports' => $service->ports,
'other' => $service->other,
'delete' => $service->delete,
];
$diff = array_diff_assoc($original, $revised);
unset($diff['create_at']);
unset($diff['update_at']);
unset($diff['deleted']);
$remarks = '';
if ($diff) {
$remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:';
foreach ($diff as $key => $value) {
$remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
}
}
// 添加日志
$this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks);
DB::commit();
return $this->success();
}
DB::rollBack();
return $this->fail('服务器信息修改失败');
}
/**
* 检查ip是否存在
* @param $ip
* @return bool
*/
public function checkIp($ip)
{
$usIp = ServerInformation::query()->where('ip', $ip)->first();
if ($usIp) {
return true;
} else {
return false;
}
}
/**
* 详情
* @param int $deleted
* @return array|Builder|Collection|Model
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL)
{
$id = \request()->input('id');
if (!$id) {
return $this->fail('参数错误');
}
$data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'sshpass', 'ports', 'create_at', 'update_at']);
if (!$data) {
return $this->fail('数据不存在!');
}
return $data;
}
/**
* 服务器操作日志
* @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表
* @param array $original 原始数据
* @param array $revised 修改后数据
*/
public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '')
{
// $action 1:添加 2:修改 3:删除 4:恢复
$actionArr = ServerInformationLog::actionArr();
$actionStr = $actionArr[$action];
$ip = request()->getClientIp();
$url = request()->getRequestUri();
$method = request()->getMethod();
$userId = $this->uid ?? 0;
$log = new ServerInformationLog();
$log->user_id = $userId;
$log->action = $actionStr;
$log->original = json_encode($original);
$log->revised = json_encode($revised);
$log->ip = $ip;
$log->url = $url;
$log->method = $method;
$log->remarks = $remarks;
DB::beginTransaction();
try {
$log->save();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
Log::error('服务器信息日志添加失败');
}
}
/**
* @param array $request
* @param $service
* @return void
*/
public function extracted(array $request, $service)
{
$service->type = trim($request['type']); // 服务器类型
$service->ip = trim($request['ip']); // 服务器ip
$service->title = trim($request['title']); // 服务器标题
$service->belong_to = trim($request['belong_to']); // 服务器归属
$service->sshpass = trim($request['sshpass']); // ssh密码
$service->ports = trim($request['ports']); // ssh端口
}
/**
* 批量获取数据删除
* @return array
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL)
{
$id = request()->input('id');
if (!$id) {
return $this->fail('参数错误');
}
$ids = [];
if (!is_array($id)) {
$ids = explode(',', $id);
}
$ids = array_filter($ids, 'intval');
if (empty($ids)) {
return $this->fail('参数错误');
}
$data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();
$restore_ids = $data->pluck('id')->toArray();
$actionArr = ServerInformationLog::actionArr();
$actionStr = $actionArr[$action];
if (empty($restore_ids)) {
$this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR);
}
$original = $data->toArray();
DB::beginTransaction();
try {
$update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL;
ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]);
$this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids));
DB::commit();
return $this->success();
} catch (\Exception $e) {
DB::rollBack();
return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR);
}
}
}
... ...
... ... @@ -20,7 +20,7 @@ class DomainInfoLogic extends BaseLogic
public function getDomainInfo($project_id)
{
$project = app(ProjectLogic::class)->getInfo($project_id);
$domain = $project['deploy_optimize']['domain'];
$domain = $project['deploy_optimize']['domain'] ?? '';
$info = $this->model->where('project_id', $project_id)->first();
//不存在或时间过期了 重新获取信息
$expiration_date = $info['domain_info']['expiration_date'] ?? '';
... ...
... ... @@ -4,11 +4,14 @@ namespace App\Http\Logic\Aside\Project;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\InquirySet;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -39,15 +42,15 @@ class ProjectLogic extends BaseLogic
}
public function save($param){
if(!empty($param['test_domain'])){
$param['test_domain'] = checkDomain($param['test_domain']);
if(!$param['test_domain']){
if(!empty($param['deploy_build']['test_domain'])){
$param['deploy_build']['test_domain'] = checkDomain($param['deploy_build']['test_domain']);
if(!$param['deploy_build']['test_domain']){
$this->fail('测试域名格式不正确');
}
}
if(!empty($param['domain'])){
$param['domain'] = checkDomain($param['domain']);
if(!$param['domain']){
if(!empty($param['deploy_optimize']['domain'])){
$param['deploy_optimize']['domain'] = checkDomain($param['deploy_optimize']['domain']);
if(!$param['deploy_optimize']['domain']){
$this->fail('正式域名格式不正确');
}
}
... ... @@ -122,4 +125,38 @@ class ProjectLogic extends BaseLogic
parent::setWith(['payment', 'deploy_build', 'deploy_optimize']);
parent::clearCache($id);
}
/**
* 保存询盘通知设置
* @author zbj
* @date 2023/5/17
*/
public function saveInquirySet($param)
{
$project = $this->getCacheInfo($param['project_id']);
//同步到接口
$domain = parse_url($project['deploy_optimize']['domain'])['host'];
$emails = Arr::arrToSet($param['emails']??'', 'trim');
$phones = Arr::arrToSet($param['phones']??'', 'trim');
$form_globalso_api = new FormGlobalsoApi();
$res = $form_globalso_api->setInquiry($domain, $emails, $phones);
if (!$res) {
$this->fail('保存失败');
}
if ($res['status'] != 200) {
$this->fail($res['message'] ?? '保存失败');
}
//保存
$set = InquirySet::where('project_id', $param['project_id'])->first();
if (!$set) {
$set = new InquirySet();
}
$set->project_id = $param['project_id'];
$set->emails = $emails;
$set->phones = $phones;
$set->save();
return $this->success();
}
}
... ...
<?php
namespace App\Http\Logic\Aside\User;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\User\ProjectMenu;
class ProjectGroupLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new ProjectMenu();
$this->param = $this->requestAll;
}
/**
* @name :详情
* @return void
* @author :liyuhang
* @method
*/
public function group_info(){
$info = $this->info($this->param);
return $this->success($info);
}
/**
* @name :添加
* @return void
* @author :liyuhang
* @method
*/
public function group_add(){
//查看当前用户组是否存在
$this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :编辑
* @return void
* @author :liyuhang
* @method
*/
public function group_edit(){
//查看当前用户组是否存在
$rs = $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :删除
* @return void
* @author :liyuhang
* @method
*/
public function group_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ... @@ -40,6 +40,8 @@ class AyrReleaseLogic extends BaseLogic
public function release_add(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['operator_id'] = $this->user['id'];
$this->param['images'] = implode(',',$this->param['images']);
$this->param['platforms'] = json_encode($this->param['platforms']);
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
... ... @@ -61,17 +63,17 @@ class AyrReleaseLogic extends BaseLogic
$imageModel = new Image();
$list = $imageModel->list(['hash'=>['in',$images]],'id');
foreach ($list as $v1){
$arr[] = $v1['ayr_url'];
$filename = basename($v1['path']);
$arr[] = url('/upload/images/'.$filename);
}
}else{
$arr[] = url('/b/file_hash/' . $v.rand(10000,99999).'mp4');;
$fileModel = new File();
$info = $fileModel->read(['hash'=>$v]);
$filename = basename($info['path']);
$arr[] = url('/upload/files/'.$filename);
}
}
return $this->success($arr);
}
public function platforms_request(){
}
}
... ...
... ... @@ -52,7 +52,7 @@ class AyrShareLogic extends BaseLogic
'title'=>$res['title'],
'ref_id'=>$res['refId'],
'profile_key'=>$res['profileKey'],
'user_id'=>$this->user['id'],
'operator_id'=>$this->user['id'],
'project_id'=>$this->user['project_id'],
'name'=>$this->param['name'],
];
... ... @@ -69,8 +69,11 @@ class AyrShareLogic extends BaseLogic
* @method :post
* @time :2023/5/6 10:16
*/
public function ayr_share_info(){
$info = $this->model->read(['id'=>$this->param['share_id']]);
public function ayr_share_info($share_id = ''){
if(isset($this->param['id'])){
$share_id = $this->param['id'];
}
$info = $this->model->read(['id'=>$share_id]);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
... ... @@ -97,7 +100,6 @@ class AyrShareLogic extends BaseLogic
* @time :2023/5/6 10:18
*/
public function ayr_share_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删出失败');
... ... @@ -207,16 +209,19 @@ class AyrShareLogic extends BaseLogic
if(!in_array($v,json_decode($info['bind_platforms']))){
$this->fail('未绑定平台');
}
if($v == 'reddit' && isset($this->param['video'])){
$this->fail('不支持视频');
}
//验证图片数
$img_num = count($this->param['images']);
if($img_num > $this->send_num[$v]){
$this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图');
}
//验证图片数
$img_num = count($this->param['video']);
if($img_num > 1){
$this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频');
}
// $img_num = count($this->param['video']);
// if($img_num > 1){
// $this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频');
// }
}
return $this->success();
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\File\ImageController;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Logic;
use App\Models\File\Image as ImageModel;
use Illuminate\Support\Facades\Cache;
... ... @@ -25,6 +26,8 @@ class BaseLogic extends Logic
protected $user;
protected $project;
protected $side = Common::B;
public function __construct()
... ... @@ -32,6 +35,7 @@ class BaseLogic extends Logic
$this->request = request();
$this->requestAll = request()->all();
$this->user = Cache::get(request()->header('token'));
$this->project = (new ProjectLogic())->getInfo($this->user['project_id']);
}
... ... @@ -152,4 +156,14 @@ class BaseLogic extends Logic
}
return $rs;
}
public function getProjectDomain(){
if(!empty($this->project['deploy_optimize']['domain'])){
return $this->project['deploy_optimize']['domain'];
}
if(!empty($this->project['deploy_build']['test_domain'])){
return $this->project['deploy_build']['test_domain'];
}
return '';
}
}
... ...
... ... @@ -3,7 +3,10 @@
namespace App\Http\Logic\Bside;
use App\Helper\Arr;
use App\Models\Inquiry;
use App\Helper\FormGlobalsoApi;
use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\InquirySet;
/**
* Class InquiryLogic
... ... @@ -13,23 +16,70 @@ use App\Models\Inquiry;
*/
class InquiryLogic extends BaseLogic
{
protected $form_globalso_api;
public function __construct()
{
parent::__construct();
$this->model = new Inquiry();
$this->form_globalso_api = new FormGlobalsoApi();
}
public function getApiList($export = false)
{
$page_size = $export ? 1000 : 20;
$search = $this->request['search'] ?: '';
$page = $this->request['page'] ?: 1;
$project = (new ProjectLogic())->getInfo($this->user['project_id']);
$domain = $project['deploy_optimize']['domain'] ?? '';
$list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size);
//处理格式 免得前端又改
$data = [
"list" => [],
"total" => 0,
"page" => $page,
"total_page" => 1,
"size" => $page_size
];
if (!empty($list['status']) && $list['status'] == 200) {
foreach ($list['data']['data'] as $item) {
$data['list'][] = $item;
}
$data['total'] = $list['data']['total'];
$data['total_page'] = $list['data']['last_page'];
}
return $this->success($data);
}
public function getInfo($id)
{
$info = $this->getCacheInfo($id);
if(!$info){
$this->fail('数据不存在或者已经删除');
$project = (new ProjectLogic())->getInfo($this->user['project_id']);
$domain = $project['deploy_optimize']['domain'] ?: '';
//修改状态为已读
if($this->request['read_status']){
$this->form_globalso_api->saveInquiryRead($domain, $id);
}
//翻译
$trans_message = '';
if($this->request['message']){
$trans_message = Translate::tran($this->request['message'], 'zh');
}
//标记已读
if($info->status == Inquiry::STATUS_UNREAD){
parent::save(['id' => $info['id'], 'status' => Inquiry::STATUS_READ]);
return $this->success(['trans_message' => $trans_message]);
}
return $this->success($info->toArray());
public function delete($ids, $map = [])
{
$project = (new ProjectLogic())->getInfo($this->user['project_id']);
$domain = $project['deploy_optimize']['domain'] ?: '';
$ids = array_filter(Arr::splitFilterToArray($ids), 'intval');
if(!$ids){
$this->fail('ID不能为空');
}
$this->form_globalso_api->delInquiry($domain, $ids);
return $this->success();
}
}
... ...
... ... @@ -2,11 +2,15 @@
namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
/**
* Class CategoryLogic
... ... @@ -23,6 +27,26 @@ class CategoryLogic extends BaseLogic
$this->model = new Category();
}
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data as &$v){
$v['url'] = $this->getProjectDomain() . $v['route'] ;
$v['product_num'] = $this->getProductNum($v['id']);
}
if(!$map){
$data = Arr::listToTree($data);
}
return $this->success($data);
}
public function getInfo($id)
{
$info = parent::getInfo($id);
$info['url'] = $this->getProjectDomain() . $info['route'] ;
return $this->success($info);
}
public function save($param){
$param['pid'] = $param['pid'] ?? 0;
if(!empty($param['pid'])){
... ... @@ -34,16 +58,31 @@ class CategoryLogic extends BaseLogic
$this->fail('上级分类不存在');
}
}
return parent::save($param);
DB::beginTransaction();
try {
$res = parent::save($param);
//路由映射
RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_CATE, $res['id'], $this->user['project_id']);
DB::commit();
} catch (\Exception $e){
DB::rollBack();
errorLog('产品分类保存失败', $param, $e);
$this->fail('保存失败');
}
return $this->success();
}
public function delete($ids, $map = []){
$ids= array_filter(Arr::splitFilterToArray($ids), 'intval');
DB::beginTransaction();
try {
foreach ($ids as $id){
$info = $this->getCacheInfo($id);
if(!$info){
continue;
}
//是否有子分类
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
$this->fail("分类{$info['title']}存在子分类,不能删除");
... ... @@ -52,8 +91,20 @@ class CategoryLogic extends BaseLogic
if(CategoryRelated::where('cate_id', $id)->count()){
$this->fail("分类{$info['title']}存在产品,不能删除");
}
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
}
parent::delete($ids);
DB::commit();
} catch (BsideGlobalException $e){
DB::rollBack();
$this->fail($e->getMessage());
} catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败');
}
return parent::delete($ids);
return $this->success();
}
/**
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\KeywordRelated;
... ... @@ -24,6 +25,24 @@ class KeywordLogic extends BaseLogic
$this->model = new Keyword();
}
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data['list'] as &$v){
$v['product_num'] = $this->getProductNum($v['id']);
$v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
$v['url'] = $this->getProjectDomain() . $v['route'];
}
return $this->success($data);
}
public function getInfo($id)
{
$info = parent::getInfo($id);
$info['url'] = $this->getProjectDomain() . $info['route'];
return $this->success($info);
}
public function save($param){
DB::beginTransaction();
try {
... ... @@ -44,8 +63,6 @@ class KeywordLogic extends BaseLogic
DB::beginTransaction();
try {
parent::delete($ids);
foreach ($ids as $id){
$info = $this->getCacheInfo($id);
if(!$info){
... ... @@ -60,8 +77,12 @@ class KeywordLogic extends BaseLogic
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
}
parent::delete($ids);
DB::commit();
} catch (BsideGlobalException $e){
DB::rollBack();
$this->fail($e->getMessage());
}catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败');
... ...
... ... @@ -53,6 +53,7 @@ class ProductLogic extends BaseLogic
$info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');
$info['status_text'] = Product::statusMap()[$info['status']] ?? '';
$info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';
$info['url'] = $this->getProjectDomain() . $info['route'] ;
return $info;
}
... ... @@ -85,8 +86,6 @@ class ProductLogic extends BaseLogic
DB::beginTransaction();
try {
parent::delete($ids);
foreach ($ids as $id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
... ... @@ -97,6 +96,7 @@ class ProductLogic extends BaseLogic
//删除关键词关联
KeywordRelated::where('product_id', $id)->delete();
}
parent::delete($ids);
DB::commit();
}catch (\Exception $e){
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Helper\Translate;
use App\Http\Logic\Aside\Project\DomainInfoLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
... ... @@ -39,7 +40,7 @@ class RankDataLogic extends BaseLogic
$external_links = ExternalLinks::where('project_id', $project_id)->first();
$indexed_pages = IndexedPages::where('project_id', $project_id)->first();
$speed = Speed::where('project_id', $project_id)->first();
$api_no = $project['deploy_optimize']['api_no'] ?? '';
//排名数据
$data = [
'first_num' => $rank['first_num'] ?? 0,
... ... @@ -51,24 +52,36 @@ class RankDataLogic extends BaseLogic
'external_links_num' => $external_links['total'] ?? 0,
];
//小语种列表
$langs = Arr::pluck($project['deploy_optimize']['minor_languages'], 'tl');
foreach ($langs as $lang) {
$data['langs'][$lang] = Translate::getTls($lang);
}
//项目信息
$data['project'] = [
'company' => $project['company'],
'domain' => $project['deploy_optimize']['domain'],
'domain' => $project['deploy_optimize']['domain'] ?? '',
'domain_info' => ($domain_info['domain_info']['creation_date'] ?? '') . ' - ' . ($domain_info['domain_info']['expiration_date'] ?? ''),
'cert_info' => ($domain_info['ssl']['start_time'] ?? '') . ' - ' . ($domain_info['ssl']['end_time'] ?? ''),
'plan' => str_replace('营销大师-', '全球搜-', $project['deploy_build']['plan'][0]),
'plan' => str_replace('营销大师-', '全球搜-', $project['deploy_build']['plan'][0] ?? ''),
'keyword_num' => $project['deploy_build']['keyword_num'],
'compliance_day' => $rank['compliance_day'] ?? 0,
'remain_day' => $project['deploy_build']['service_duration'] - ($rank['compliance_day'] ?? 0),
];
//小语种列表
$quanqiusou_api = new QuanqiusouApi();
$lang_data = $quanqiusou_api->getLangRankData($api_no);
$lang_data = Arr::setValueToKey($lang_data, 'language');
$data['langs'] = [];
foreach($project['deploy_optimize']['minor_languages']??[] as $lang){
$remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0;
$data['langs'][$lang['tl'] ?? ''] = [
'lang_text' => Translate::getTls($lang['tl'] ?? ''),
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
}
//测速
$data['speed'] = $speed['data'] ?? [];
... ... @@ -83,6 +96,7 @@ class RankDataLogic extends BaseLogic
];
//外链引荐域名
$recomm_domain = $recomm_domain ? $recomm_domain->toArray() : [];
$data['external_links_domain_chat'] = [
'labels' => array_map(function ($item) {
return Str::substrReplace($item, '***', 2, 3);
... ... @@ -107,8 +121,8 @@ class RankDataLogic extends BaseLogic
}
//关键词排名分析图
$data['rank_chat'] = [
'data' => $rank_week['data'],
'labels' => $rank_week['date'],
'data' => $rank_week['data'] ?? [],
'labels' => $rank_week['date'] ?? [],
];
return $data;
... ... @@ -168,12 +182,24 @@ class RankDataLogic extends BaseLogic
}
}
}
$domain_arr = explode(':', $domain_text);
$v = [
'keyword' => $key,
'domain' => $domain_text,
'domain_type' => $domain_arr[0],
'domain' => $domain_arr[1],
'domain_text' => $domain_text,
'g' => $last['g'], //1核心关键词
'position' => $data
'position' => $data,
];
//图片排名
if(isset($last['p_img'])){
$v['img_position'] = $last['p_img'];
}
//视频排名
if(isset($last['p_vid'])){
$v['video_position'] = $last['p_vid'];
}
if ($last['position'] == 0) {
$list0[] = $v;
} elseif ($last['position'] <= 30) {
... ...
... ... @@ -4,7 +4,7 @@ namespace App\Http\Logic\Bside\User;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\ProjectDept;
use App\Models\User\ProjectDept;
/**
* Class DeptLogic
... ...
<?php
namespace App\Http\Logic\Bside\User;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\User\DeptUser;
use App\Models\User\User as UserModel;
class DeptUserLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new DeptUser();
$this->param = $this->requestAll;
}
/**
* @name :(部门用户)dept_user_add
* @author :lyh
* @method :post
* @time :2023/5/18 10:21
*/
public function dept_user_save(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->dept_user_edit($this->param);
}else{
$rs = $this->dept_user_add();
}
if ($rs === false) {
$this->fail('部门添加成员失败');
}
return $this->success();
}
/**
* @name :(部门添加用户)dept_user_add
* @author :lyh
* @method :post
* @time :2023/5/18 10:21
*/
public function dept_user_add(){
$param = [
'dept_id'=> $this->param['dept_id'],
'project_id'=>$this->user['project_id'],
'user_id'=>$this->param['user_id'],
'operator_id'=>$this->user['id'],
'create_id'=>$this->user['id']
];
$rs = $this->model->add($param);
if($rs === false){
$this->fail('部门添加成员失败');
}
return $this->success();
}
/**
* @name :(用户更改部门)dept_user_edit
* @author :lyh
* @method :post
* @time :2023/5/17 17:54
*/
public function dept_user_edit($param){
$rs = $this->model->edit($param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(用户设置角色)user_edit_role
* @author :lyh
* @method :post
* @time :2023/5/19 9:35
*/
public function user_edit_role(){
$userModel = new UserModel();
$rs = $userModel->edit(['role_id'=>$this->param['role_id']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\User;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\User\ProjectGroup;
use App\Models\User\User as UserModel;
use Illuminate\Support\Facades\DB;
class GroupLogic extends BaseLogic
{
... ... @@ -15,17 +17,16 @@ class GroupLogic extends BaseLogic
$this->param = $this->requestAll;
}
/**
* @name :添加
* @name :添加用户组
* @return void
* @author :liyuhang
* @method
*/
public function group_add(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['admin_id'] = $this->user['admin_id'];
$this->param['create_id'] = $this->user['create_id'];
$this->param['operator_id'] = $this->user['operator_id'];
$this->param['user_list'] = ','.trim($this->param['user_list'],',').',';
$this->param['admin_id'] = $this->user['id'];
$this->param['create_id'] = $this->user['id'];
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
... ... @@ -34,13 +35,37 @@ class GroupLogic extends BaseLogic
}
/**
* @name :(添加成员)group_add_user
* @author :lyh
* @method :post
* @time :2023/5/17 15:58
*/
public function group_add_user(){
$info = $this->model->read(['id'=>$this->param['id']]);
//组装数据
$str = ltrim($info['user_list'],',').$this->param['user_list'];
$arr = array_unique(explode(',',$str));
sort($arr);
$str = ','.implode(',',$arr).',';
DB::beginTransaction();
try {
$this->model->edit(['user_list'=>$str],['id'=>$this->param['id']]);
//更新父类
$this->update_parent($this->param,$info);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('添加成员失败');
}
return $this->success();
}
/**
* @name :编辑
* @return void
* @author :liyuhang
* @method
*/
public function group_edit(){
$this->param['user_list'] = ','.trim($this->param['user_list'],',').',';
$rs = $this->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
... ... @@ -49,13 +74,29 @@ class GroupLogic extends BaseLogic
}
/**
* @name :(获取成员列表)user_list
* @author :lyh
* @method :post
* @time :2023/5/17 14:51
*/
public function user_list($data = [],$order = 'id'){
unset($this->param['id']);
$userModel = new UserModel();
$data = array_merge($data,$this->param);
$lists = $userModel->list($data,$order,['id','name','mobile','created_at']);
return $this->success($lists);
}
/**
* @name :详情
* @return void
* @author :liyuhang
* @method
*/
public function group_info(){
$info = $this->info($this->param);
public function group_info($param = []){
if(empty($param)){
$param = $this->param;
}
$info = $this->model->read($this->param);
return $this->success($info);
}
... ... @@ -66,12 +107,69 @@ class GroupLogic extends BaseLogic
* @method
*/
public function group_del(){
$ids = $this->param['id'];
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->del($this->param,$ids);
//查看当前是否拥有父类
$info = $this->model->read(['pid'=>$this->param['id']]);
if($info !== false){
$this->fail('当前删除组织拥有下级组织,不允许删除');
}
$rs = $this->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(更新父类成员)update_parent
* @author :lyh
* @method :post
* @time :2023/5/17 9:22
*/
public function update_parent($param,$info){
//查询当前组是否拥有父类
if($info['pid'] != 0){
$parent_info = $this->model->read(['id'=>$info['pid']]);
//把添加成员合并到上级
$str = trim(trim($param['user_list'],',').$parent_info['user_list'],',');
$arr = array_unique(explode(',', $str));
sort($arr);
$mergedString = ','.implode(',', $arr).',';
$rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]);
if($rs === false){
$this->fail('更新父级失败');
}
//查看当前父级是否还拥有父级
if($parent_info['pid'] != 0){
return $this->update_parent($param,$parent_info);
}
}
return $this->success();
}
/**
* @name :(更新子类,同时清空子集成员)edit_son
* @author :lyh
* @method :post
* @time :2023/5/17 13:52
*/
public function update_son($param,$id){
//当前数据详情
$info = $this->model->read(['id'=>$id]);
//子集详情
$son_list = $this->model->list(['pid'=>$info['id']],'id');
if(!empty($son_list)){
//循环查询
foreach ($son_list as $k => $v){
$son_data = explode(',',trim($v['user_list'],','));
$son_str = '';
foreach ($son_data as $v1){
if(strpos($param['user_list'],','.$v1.',') > -1){
$son_str .= $v1.',';
}
}
$this->model->edit(['user_list'=>','.$son_str],['id'=>$v['id']]);
}
}
return true;
}
}
... ...
... ... @@ -22,7 +22,7 @@ class UserLogic extends BaseLogic
* @method
*/
public function user_info(){
$info = $this->info($this->param);
$info = $this->model->read($this->param);
return $this->success($info);
}
/**
... ... @@ -97,9 +97,9 @@ class UserLogic extends BaseLogic
* @method
*/
public function user_del(){
$ids = $this->param['id'];
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
$this->model->del($this->param);
//对应删除组织架构
return $this->success();
}
... ...
<?php
namespace App\Http\Logic\Cside;
use App\Enums\Common\Common;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Logic;
/**
* @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常
*/
class BaseLogic extends Logic
{
protected $requestAll;
protected $param;
protected $request;
protected $project;
protected $side = Common::C;
public function __construct()
{
$this->request = request();
$this->requestAll = request()->all();
$this->project = $this->request->get('project');
}
/**
* 列表
* @param array $map
* @param array $sort
* @param array $columns
* @param int $limit
* @return array
* @author zbj
* @date 2023/4/13
*/
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
$map[] = ['project_id' => $this->project['id']];
return parent::getList($map, $sort, $columns, $limit);
}
/**
* @param $id
* @return mixed
* @author zbj
* @date 2023/4/15
*/
public function getCacheInfo($id)
{
$info = parent::getCacheInfo($id);
if ($info && $info['project_id'] != $this->project['id']) {
$info = null;
}
return $info;
}
/**
* 保存
* @param $param
* @return array
* @throws BsideGlobalException
* @author zbj
* @date 2023/4/13
*/
public function save($param)
{
$param['project_id'] = $this->project['id'];
return parent::save($param);
}
/**
* 批量删除
* @param $ids
* @param array $map
* @return array
* @author zbj
* @date 2023/4/13
*/
public function delete($ids, $map = [])
{
$map[] = ['project_id' => $this->project['id']];
return parent::delete($ids, $map);
}
}
<?php
namespace App\Http\Logic\Cside;
use App\Helper\Arr;
use App\Models\Inquiry;
/**
* Class InquiryLogic
* @package App\Http\Logic\Bside
* @author zbj
* @date 2023/5/4
*/
class InquiryLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Inquiry();
}
public function save($param)
{
$param['ip_info'] = Arr::s2a($param['ip_info']);
$param['ip'] = $param['ip_info']['ip'] ?? '';
$param['ip_country'] = $param['ip_info']['country'] ?? '';
return parent::save($param);
}
}
... ... @@ -4,7 +4,6 @@ namespace App\Http\Logic;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Exceptions\CsideGlobalException;
use \App\Helper\Common as CommonHelper;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
... ... @@ -46,9 +45,6 @@ class Logic
if((request()->path()[0]) == Common::B){
throw new BsideGlobalException($code, $message);
}
if((request()->path()[0]) == Common::C){
throw new CsideGlobalException($code, $message);
}
throw new AsideGlobalException($code, $message);
}
... ...
<?php
namespace App\Http\Middleware\Cside;
use App\Enums\Common\Code;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Closure;
use Illuminate\Http\Request;
class ParamMiddleware
{
protected $param = [];
protected $project = [];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$this->param = $request->all();
$domain = $request->header('domain');
if(!isset($domain) || empty($domain)){
return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']);
}
$project = Project::getProjectByDomain($domain);
if(empty($project)){
return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']);
}
// 设置数据信息
// $project = ProjectServer::useProject($project['id']);
// if($project){
// return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']);
// }
$request->attributes->add(['project' => $project]);
return $next($request);
}
}
<?php
namespace App\Http\Requests\Cside;
namespace App\Http\Requests\Aside\Devops;
use App\Models\Devops\ServerInformation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* Class InquiryRequest
* @package App\Http\Requests\Cside
* @author zbj
* @date 2023/5/4
*/
class InquiryRequest extends FormRequest
class ServerInformationRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
... ... @@ -30,16 +26,37 @@ class InquiryRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:200',
'email' => 'required|email|max:200',
'phone' => 'max:200',
'content' => 'required',
'type' => [ 'required', Rule::in( array_keys( ( new ServerInformation )->ServiceArray() ) ) ],
'ip' => 'required|ip',
'title' => 'required|max:200',
'belong_to' => 'required|integer|in:1,2', // 1:公司 2:客户
'sshpass' => 'required|max:100',
'ports' => 'required|integer|min:1|max:65535',
];
}
public function messages()
{
return [];
$service_array = ( new ServerInformation )->ServiceArray();
$serviceStr = implode( ', ', $service_array );
return [
'type.required' => '服务器类型不能为空',
'type.integer' => '服务器类型格式不正确',
'type.between' => '服务器类型 ' . $serviceStr,
'ip.required' => 'ip不能为空',
'ip.ip' => 'ip格式不正确',
'title.required' => '服务器标题不能为空',
'title.max' => '服务器标题不能超过200个字符',
'belong_to.required' => '服务器归属不能为空',
'belong_to.integer' => '服务器归属格式不正确',
'belong_to.in' => '服务器归属只能是公司或者客户',
'sshpass.required' => 'ssh密码不能为空',
'sshpass.max' => 'ssh密码不能超过100个字符',
'ports.required' => 'ssh端口不能为空',
'ports.integer' => 'ssh端口格式不正确',
'ports.min' => 'ssh端口不能小于1',
'ports.max' => 'ssh端口不能大于65535',
];
}
}
... ...
<?php
namespace App\Http\Requests\Bside\AyrRelease;
namespace App\Http\Requests\Bside\AyrShare;
use Illuminate\Foundation\Http\FormRequest;
... ... @@ -24,12 +24,12 @@ class AyrReleaseRequest extends FormRequest
{
return [
'title'=>'required',
'images'=>'required|array',
'video'=>'required',
// 'images'=>'required|array',
// 'video'=>'required',
'content'=>'required',
'share_id'=>'required',
'platforms'=>'required|array',
'idempotency_key'=>'required',
// 'schedule_date'=>'required',
];
}
... ...
<?php
namespace App\Models\Aside;
use App\Models\Base;
/**
* 模板 头部底部 对所有 客户
* @author:dc
* @time 2023/4/26 11:21
* Class TemplateHeaderFooter
* @package App\Models\Aside
*/
class TemplateHeaderFooter extends Base
{
protected $table = 'gl_aside_template_header_footer';
}
... ...
... ... @@ -84,7 +84,7 @@ class Base extends Model
* @author :liyuhang
* @method
*/
public function list($map,$order = 'sort',$fields = ['*']): array
public function list($map = [],$order = 'id',$fields = ['*']): array
{
$query = $this->formatQuery($map);
$lists = $query->select($fields)->orderBy($order)->get();
... ... @@ -187,7 +187,7 @@ class Base extends Model
// in查询 ['id'=>['in',[1,2,3]]]
$query->orWhere($k, $v[1]);
break;
case 'no in':
case 'not in':
// in查询 ['id'=>['not in',[1,2,3]]]
$query->whereNotIn($k, $v[1]);
break;
... ...
<?php
namespace App\Models\Bside;
use App\Models\Base;
/**
* 模板 头部底部 客户自己的
* @author:dc
* @time 2023/4/26 11:21
* Class TemplateHeaderFooter
* @package App\Models\Bside
*/
class TemplateHeaderFooter extends Base
{
protected $table = 'gl_bside_template_header_footer';
}
... ...
<?php
namespace App\Models\Devops;
use Illuminate\Database\Eloquent\Model;
class ServerInformation extends Model
{
protected $table = 'gl_server_information';
const CREATED_AT = 'create_at';
const UPDATED_AT = 'update_at';
// 软删除 0:正常 1:删除
const DELETED_NORMAL = 0;
const DELETED_DELETE = 1;
/**
* @param $num
*
* @return string
*/
public function Service($num)
{
return $this->ServiceArray()[$num];
}
/**
* @return array
*/
public function ServiceArray()
{
return [
1 => '阿里云',
2 => '腾讯云',
3 => 'linode',
4 => '尊云',
5 => '互联',
6 => '其他',
7 => 'Ramnode',
8 => 'CN2-SSD美国',
9 => '国内测试服务器',
];
}
/**
* 字段信息
* @return array
*/
public function FieldsArray()
{
return [
'type' => '服务器类型',
'ip' => '服务器IP',
'title' => '服务器标题',
'belong_to' => '服务器归属',
'sshpass' => 'SSH 密码',
'ports' => 'SSH 端口',
'other' => '其他信息 json格式',
];
}
/**
* 服务器归属信息
* @return array
*/
public function BelongToArray()
{
return [
1 => '公司',
2 => '客户',
];
}
public function BelongTo($num)
{
return $this->BelongToArray()[$num];
}
/**
* 返回服务器类型
* @param $value
*
* @return string
*/
public function getTypeAttribute($value)
{
return $this->Service($value);
}
/**
* 返回服务器归属
* @param $value
*
* @return string
*/
public function getBelongToAttribute($value)
{
return $this->BelongTo($value);
}
}
... ...
<?php
namespace App\Models\Devops;
use Illuminate\Database\Eloquent\Model;
class ServerInformationLog extends Model
{
protected $table = 'gl_server_information_log';
const CREATED_AT = 'create_at';
const UPDATED_AT = 'update_at';
public function getOriginalAttribute($value)
{
return json_decode($value, true);
}
public function getRevisedAttribute($value)
{
return json_decode($value, true);
}
/** @var int 日志添加 */
const ACTION_ADD = 1;
/** @var int 日志修改 */
const ACTION_UPDATE = 2;
/** @var int 日志删除 */
const ACTION_DELETE = 3;
/** @var int 日志恢复 */
const ACTION_RECOVER = 4;
/**
* @return string[]
*/
public static function actionArr()
{
return [
1 => '添加',
2 => '修改',
3 => '删除',
4 => '恢复',
];
}
}
... ...
<?php
namespace App\Models;
use App\Helper\Arr;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Inquiry
* @package App\Models
* @author zbj
* @date 2023/5/4
*/
class Inquiry extends Base
{
use SoftDeletes;
//设置关联表名
protected $table = 'gl_inquiry';
const STATUS_UNREAD = 0;
const STATUS_READ = 1;
public function setIpInfoAttribute($value){
$this->attributes['ip_info'] = Arr::a2s($value);
}
public function getIpInfoAttribute($value){
return Arr::s2a($value);
}
}
<?php
namespace App\Models;
/**
* Class InquirySet
* @package App\Models
* @author zbj
* @date 2023/5/17
*/
class InquirySet extends Base
{
//设置关联表名
protected $table = 'gl_inquiry_set';
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Product;
use App\Models\Base;
use App\Models\RouteMap;
use App\Services\Facades\Upload;
use Illuminate\Database\Eloquent\SoftDeletes;
... ... @@ -14,12 +15,21 @@ class Category extends Base
//设置关联表名
protected $table = 'gl_product_category';
const STATUS_ACTIVE = 1;
/**
* 子分类
* @var array
*/
protected $child_ids_arr = [];
protected $appends = ['route'];
public function getRouteAttribute(){
return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $this->id, $this->project_id);
}
public function getImageAttribute($value)
{
return Upload::path2url($value);
... ...
... ... @@ -17,6 +17,14 @@ class RankData extends Base
//设置关联表名
protected $table = 'gl_rank_data';
public static function gMap(){
return [
1 => '主关键词',
2 => '拓展关键词',
3 => '小语种关键词',
];
}
public function setDataAttribute($value)
{
$this->attributes['data'] = Arr::a2s($value);
... ...
... ... @@ -22,6 +22,7 @@ class RouteMap extends Model
const SOURCE_PRODUCT = 'product';
const SOURCE_PRODUCT_CATE = 'product_category';
const SOURCE_PRODUCT_KEYWORD = 'product_keyword';
const SOURCE_PAGE = 'page'; //单页面
//路由类型
const SOURCE_BLOG = 'blog';
... ...
... ... @@ -4,10 +4,7 @@ namespace App\Models\User;
use App\Models\Base;
class ProjectGroup extends Base
class DeptUser extends Base
{
//设置关联表名
protected $table = 'gl_project_group';
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
protected $table = 'gl_project_dept_user';
}
... ...
<?php
namespace App\Models;
namespace App\Models\User;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProjectDept extends Base
... ...
<?php
namespace App\Models\User;
use App\Models\Base;
class ViewDeptUser extends Base
{
protected $table = 'gl_view_dept_user';
}
... ...
... ... @@ -40,7 +40,6 @@ class RouteServiceProvider extends ServiceProvider
//预定义两个端的API路由
$this->mapAsideRoute();
$this->mapBsideRoute();
$this->mapCsideRoute();
// 暂时无用
$this->routes(function () {
... ... @@ -75,16 +74,6 @@ class RouteServiceProvider extends ServiceProvider
->namespace($this->namespace . '\Bside')
->group(base_path('routes/bside.php'));
}
/**
*C端API路由
* @return void
*/
protected function mapCsideRoute(){
Route::middleware('cside')
->prefix('c')
->namespace($this->namespace . '\Cside')
->group(base_path('routes/cside.php'));
}
/**
* Configure the rate limiters for the application.
... ...
此 diff 太大无法显示。
... ... @@ -60,12 +60,6 @@ return [
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'bside',
],
//自定义B端错误日志
'cside' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'cside',
],
'stack' => [
'driver' => 'stack',
... ...
... ... @@ -19,14 +19,14 @@ return [
'size' => [
'max' => 1024*1024*2, // 2M
],
'path' => '/image'
'path' => '/images'
],
//默认视频
'default_file' =>[
'size' => [
'max' => 1024*1024*20, // 2M
],
'path' => '/file'
'path' => '/files'
],
//博客图
'blog' =>[
... ...
... ... @@ -4,6 +4,7 @@
*/
use \Illuminate\Support\Facades\Route;
use \App\Http\Controllers\Aside;
//必须登录验证的路由组
Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件
Route::middleware(['aloginauth'])->group(function () {
... ... @@ -103,6 +104,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
Route::get('/', [Aside\Project\ProjectController::class, 'list'])->name('admin.project');
Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info');
Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save');
Route::any('/inquiry_set', [Aside\Project\ProjectController::class, 'inquiry_set'])->name('admin.project_inquiry_set');
});
//工单管理
... ... @@ -122,6 +124,21 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
Route::post('/update_database', [Aside\Devops\ServerConfigController::class, 'updateDatabase'])->name('admin.devops.server_config.update_database');
Route::post('/update_code', [Aside\Devops\ServerConfigController::class, 'updateCode'])->name('admin.devops.server_config.update_code');
});
// 服务器添加|修改|删除
Route::prefix('server')->group(function () {
Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表
Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息
Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息
Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加
Route::post('/edit', [Aside\Devops\ServerInformationController::class, 'edit'])->name('admin.devops.bt_edit'); // 修改
Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除
Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表
Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据
Route::get('/search', [Aside\Devops\ServerInformationController::class, 'search'])->name('admin.devops.bt_search'); //搜索
Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表
});
});
// 自定义页面 模板,头部底部
... ...
... ... @@ -21,6 +21,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/edit', [\App\Http\Controllers\Bside\User\UserController::class, 'edit'])->name('user_edit');
Route::any('/status', [\App\Http\Controllers\Bside\User\UserController::class, 'status'])->name('user_status');
Route::any('/info', [\App\Http\Controllers\Bside\User\UserController::class, 'info'])->name('user_info');
Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list');
Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del');
});
... ... @@ -42,16 +43,6 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\ProjectRoleController::class, 'get_user_list'])->name('project_role_get_user_list');
});
//group相关路
Route::prefix('group')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'lists'])->name('project_group_lists');
Route::any('/add', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'add'])->name('project_group_add');
Route::any('/edit', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'edit'])->name('project_group_edit');
Route::any('/info', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'info'])->name('project_group_info');
Route::any('/del', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'del'])->name('project_group_del');
Route::any('/get_user_lists', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists');
});
//新闻相关路由
Route::prefix('news')->group(function () {
//分类
... ... @@ -106,7 +97,7 @@ Route::middleware(['bloginauth'])->group(function () {
//公用ai自动生成
Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post');
});
//ai指令
//网站设置
Route::prefix('setting')->group(function () {
//首页设置
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists');
... ... @@ -182,6 +173,15 @@ Route::middleware(['bloginauth'])->group(function () {
Route::get('/info', [\App\Http\Controllers\Bside\User\DeptController::class, 'info'])->name('dept_info');
Route::post('/save', [\App\Http\Controllers\Bside\User\DeptController::class, 'save'])->name('dept_save');
Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptController::class, 'delete'])->name('dept_delete');
//成员管理
//组织架构
Route::prefix('user')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'lists'])->name('dept_user');
Route::any('/save', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'save'])->name('dept_user_add');
Route::any('/info', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'info'])->name('dept_user_info');
Route::any('/set_admin', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'set_admin'])->name('dept_user_set_admin');
Route::any('/set_role', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'set_role'])->name('dept_user_set_role');
});
});
//文件操作
... ... @@ -259,6 +259,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/speed', [\App\Http\Controllers\Bside\RankDataController::class, 'speed'])->name('rank_data_speed');
Route::any('/export', [\App\Http\Controllers\Bside\RankDataController::class, 'export'])->name('rank_data_export');
Route::any('/export_history', [\App\Http\Controllers\Bside\RankDataController::class, 'export_history'])->name('rank_data_export_history');
Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank');
});
... ... @@ -266,8 +267,8 @@ Route::middleware(['bloginauth'])->group(function () {
//无需登录验证的路由组
Route::group([], function () {
Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
// Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'ceShi'])->name('ce_shi');
Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show');
Route::any('/file_hash/{hash}/', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show');
Route::any('/file_hash/{hash}', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show');
});
... ...
<?php
/**
* C端用户路由文件
*/
use Illuminate\Support\Facades\Route;
//必须登录验证的路由组
Route::middleware([])->group(function () {
//添加询盘信息
Route::post('/inquiry/save', [\App\Http\Controllers\Cside\InquiryController::class, 'save'])->name('inquiry_save');
});