添加:swoole配置文件添加忽略
This commit is contained in:
parent
f4b8f544c4
commit
16a276efa7
|
|
@ -19,6 +19,7 @@ use crmeb\basic\BaseController;
|
|||
use crmeb\services\HttpService;
|
||||
use crmeb\services\UploadService;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Class Common
|
||||
|
|
@ -428,5 +429,227 @@ class Common extends BaseController
|
|||
app()->make(CacheRepository::class)->saveAll($data);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function test(){
|
||||
|
||||
|
||||
$this->sqlInit();
|
||||
|
||||
|
||||
|
||||
debug("调试结束...");
|
||||
|
||||
}
|
||||
|
||||
/******** 数据库批量处理 ***************************************/
|
||||
private function sqlInit(){
|
||||
// 不清除数据的表
|
||||
$notCleanUp = [
|
||||
// 文章
|
||||
'tk_article',
|
||||
'tk_article_category',
|
||||
'tk_article_content',
|
||||
// 社区
|
||||
'tk_community',
|
||||
'tk_community_category',
|
||||
// 'tk_community_topic',
|
||||
|
||||
// 系统
|
||||
'tk_cache',
|
||||
'tk_city_area',
|
||||
'tk_diy',
|
||||
'tk_express',
|
||||
'tk_relevance',
|
||||
'tk_system_admin',
|
||||
'tk_system_attachment',
|
||||
'tk_system_attachment_category',
|
||||
'tk_system_config',
|
||||
'tk_system_config_classify',
|
||||
'tk_system_config_value',
|
||||
'tk_system_group',
|
||||
'tk_system_group_data',
|
||||
'tk_system_menu',
|
||||
'tk_system_notice_config',
|
||||
'tk_system_role',
|
||||
'tk_template_message',
|
||||
'tk_sms_record',
|
||||
// 反馈建议
|
||||
'tk_feedback_category',
|
||||
// 保障服务
|
||||
'tk_guarantee',
|
||||
'tk_guarantee_template',
|
||||
'tk_guarantee_value',
|
||||
// 平台&商户积分
|
||||
// 'tk_integral',
|
||||
// 'tk_integral_give_record',
|
||||
// 用户相关
|
||||
'tk_member_interests',
|
||||
'tk_user',
|
||||
'tk_user_address',
|
||||
'tk_user_bill',
|
||||
'tk_user_history',
|
||||
'tk_user_merchant',
|
||||
'tk_user_order',
|
||||
'tk_user_relation',
|
||||
'tk_user_spread_log',
|
||||
'tk_user_brokerage',// 分销商等级
|
||||
'tk_wechat_user',
|
||||
// 商户相关
|
||||
'tk_merchant',
|
||||
'tk_merchant_admin',
|
||||
'tk_merchant_category',
|
||||
// 'tk_merchant_intention',
|
||||
'tk_merchant_type',
|
||||
'tk_shipping_template',
|
||||
'tk_shipping_template_free',
|
||||
'tk_shipping_template_region',
|
||||
'tk_shipping_template_undelivery',
|
||||
// 装修相关
|
||||
'tk_page_category',
|
||||
'tk_page_link',
|
||||
// 商品相关
|
||||
'tk_parameter',
|
||||
'tk_parameter_template',
|
||||
'tk_parameter_value',
|
||||
'price_rule',
|
||||
'tk_store_attr_template',
|
||||
'tk_store_brand',
|
||||
'tk_store_brand_category',
|
||||
'tk_store_category',
|
||||
'tk_store_product',
|
||||
'tk_store_product_attr',
|
||||
'tk_store_product_attr_value',
|
||||
'tk_store_product_cate',
|
||||
'tk_store_product_content',
|
||||
'tk_store_product_label',
|
||||
'tk_store_spu',
|
||||
// 'tk_store_product_reply',// 商品评论
|
||||
'tk_price_rule',
|
||||
// 商品助力
|
||||
// 'tk_store_product_assist',
|
||||
// 'tk_store_product_assist_set',
|
||||
// 'tk_store_product_assist_sku',
|
||||
// 'tk_store_product_assist_user',
|
||||
// 优惠券相关
|
||||
// 'tk_store_coupon',
|
||||
// 'tk_store_coupon_issue_user',
|
||||
// 'tk_store_coupon_product',
|
||||
// 'tk_store_coupon_send',
|
||||
// 'tk_store_coupon_user',
|
||||
// 套餐相关
|
||||
// 'tk_store_discounts',
|
||||
// 'tk_store_discounts_product',
|
||||
// 拼团商品
|
||||
// 'tk_store_product_group',
|
||||
// 'tk_store_product_group_buying',
|
||||
// 'tk_store_product_group_sku',
|
||||
// 'tk_store_product_group_user',
|
||||
// 预售商品
|
||||
// 'tk_store_product_presell',
|
||||
// 'tk_store_product_presell_sku',
|
||||
// 活动商品
|
||||
'tk_store_product_sku',
|
||||
// 供应商
|
||||
'tk_system_supplier',
|
||||
// 兑换
|
||||
'tk_exchange_pickup_point',
|
||||
// 活动
|
||||
'tk_store_activity',
|
||||
|
||||
|
||||
|
||||
];
|
||||
// 获取全部数据库列表
|
||||
$tables = $this->getAllTable();
|
||||
// 获取存在数据的表
|
||||
// $hasTable = $this->getHasSpecifyDataTable($tables);
|
||||
$hasTable = $this->getHasDataTable($tables,$notCleanUp);
|
||||
|
||||
debug($hasTable);
|
||||
// 执行清除操作
|
||||
// foreach($tables as $name){
|
||||
// if(!in_array($name,$notCleanUp)){
|
||||
// // 执行清除操作
|
||||
// $res = Db::query('TRUNCATE TABLE '.$name.';');
|
||||
// }
|
||||
// }
|
||||
|
||||
debug("处理完成");
|
||||
}
|
||||
// 数据库处理 - 获取全部数据库
|
||||
private function getAllTable(){
|
||||
$database = Db::query('SELECT DATABASE() as database_name')[0]['database_name'];
|
||||
$tables = Db::query('SHOW TABLES');
|
||||
return array_column($tables,'Tables_in_'.$database);
|
||||
}
|
||||
// 数据库处理 - 获取存在数据的表(任意数据)
|
||||
private function getHasDataTable($tables,$notCleanUp){
|
||||
$tableList = [];
|
||||
foreach($tables as $tableName){
|
||||
if(!in_array($tableName,$notCleanUp)){
|
||||
// echo "{$tableName}<br />\n\r";
|
||||
// 获取字段信息
|
||||
$result = Db::query("select count(*) as count_data from {$tableName}");
|
||||
$countData = $result[0]['count_data'] ?? 0;
|
||||
if($countData > 0){
|
||||
$tableList[] = $tableName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $tableList;
|
||||
}
|
||||
// 数据库处理 - 域名替换
|
||||
private function getHasSpecifyDataTable($tables){
|
||||
$tableList = [];
|
||||
foreach($tables as $tableName){
|
||||
echo "{$tableName}\n\r";
|
||||
// 获取字段信息
|
||||
$allFieldDesc = Db::query("show columns from {$tableName}");
|
||||
$allField = array_column($allFieldDesc,'Field');
|
||||
// if($this->isHasSpecifyData($allField,$name)) $tableList[] = $name;
|
||||
$res = $this->isHasSpecifyData($allField,$tableName);
|
||||
echo $res ? "存在\n\r" : "不存在\n\r";
|
||||
if($res){
|
||||
// 批量替换
|
||||
$query = "UPDATE {$tableName} SET ";
|
||||
$handleFieldNum = 0;
|
||||
foreach($allFieldDesc as $fieldInfo){
|
||||
if(strpos($fieldInfo['Type'], 'int') !== false || $fieldInfo['Key'] == 'PRI') continue;
|
||||
|
||||
$fieldName = $fieldInfo['Field'];
|
||||
$query .= "`{$fieldName}` = REPLACE(`{$fieldName}`,'bt.test.cdlfjy.com','mp.scwmbh.cn'),";
|
||||
++$handleFieldNum;
|
||||
}
|
||||
$query = trim($query);
|
||||
$query = trim($query,',');
|
||||
$query = trim($query);
|
||||
echo "SQL({$handleFieldNum}):{$query}\n";
|
||||
if($handleFieldNum > 0) Db::query($query);
|
||||
}
|
||||
|
||||
echo "\n\n\n";
|
||||
}
|
||||
|
||||
return $tableList;
|
||||
}
|
||||
// 数据库处理 - 判断当前表是否具有指定内容
|
||||
private function isHasSpecifyData($allField,$tableName){
|
||||
$query = "select * from {$tableName} where (";
|
||||
foreach($allField as $fieldName){
|
||||
$query .= "`{$fieldName}` like '%bt.test.cdlfjy.com%' OR ";
|
||||
}
|
||||
$query = trim($query);
|
||||
$query = trim($query,'OR');
|
||||
$query = trim($query) . ")";
|
||||
|
||||
$result = Db::query($query);
|
||||
if($result) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
./swoole.php
|
||||
|
|
@ -9,6 +9,9 @@ use app\common\middleware\LogMiddleware;
|
|||
use app\common\middleware\RequestLockMiddleware;
|
||||
use think\facade\Route;
|
||||
|
||||
|
||||
Route::any('admin/test', 'admin.Common/test');
|
||||
|
||||
Route::group(config('admin.admin_prefix'), function () {
|
||||
Route::miss(function () {
|
||||
$DB = DIRECTORY_SEPARATOR;
|
||||
|
|
|
|||
Loading…
Reference in New Issue