作者 赵彬吉
<?php
/**
* @remark :
* @name :Languages.php
* @author :lyh
* @method :post
* @time :2023/11/30 10:29
*/
namespace App\Console\Commands;
use App\Models\WebSetting\WebLanguage;
use Illuminate\Console\Command;
class Languages extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_language';
/**
* The console command description.
*
* @var string
*/
protected $description = '导入小语种';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
$data = '[{"short":"en","chinese":"英文","english":"English","language":"English"},
{"short":"zh","chinese":"简体中文","english":"Chinese","language":"Chinese Simplified"},
{"short":"zh-TW","chinese":"繁体中文","english":"Chinese","language":"Chinese Traditional"},
{"short":"fr","chinese":"法语","english":"French","language":"Français"},
{"short":"de","chinese":"德语","english":"German","language":"Deutsch"},
{"short":"pt","chinese":"葡萄牙语","english":"Portuguese","language":"Português"},
{"short":"es","chinese":"西班牙语","english":"Spanish","language":"Español"},
{"short":"ru","chinese":"俄语","english":"Russian","language":"Русский"},
{"short":"ja","chinese":"日语","english":"Japanese","language":"日本語"},
{"short":"ko","chinese":"韩语","english":"Korean","language":"한국어"},
{"short":"ar","chinese":"阿拉伯语","english":"Arabic","language":"العربية"},
{"short":"ga","chinese":"爱尔兰语","english":"Irish","language":"Gaeilge"},
{"short":"el","chinese":"希腊语","english":"Greek","language":"Ελληνικά"},
{"short":"tr","chinese":"土耳其语","english":"Turkish","language":"Türkçe"},
{"short":"it","chinese":"意大利语","english":"Italian","language":"Italiano"},
{"short":"da","chinese":"丹麦语","english":"Danish","language":"Dansk"},
{"short":"ro","chinese":"罗马尼亚语","english":"Romanian","language":"Română"},
{"short":"id","chinese":"印度尼西亚语","english":"Indonesian","language":"Bahasa Indonesia"},
{"short":"cs","chinese":"捷克语","english":"Czech","language":"Čeština"},
{"short":"af","chinese":"南非荷兰语","english":"Afrikaans","language":"Afrikaans"},
{"short":"sv","chinese":"瑞典语","english":"Swedish","language":"Svenska"},
{"short":"pl","chinese":"波兰语","english":"Polish","language":"Polski"},
{"short":"eu","chinese":"巴斯克语","english":"Basque","language":"Euskara"},
{"short":"ca","chinese":"加泰罗尼亚语","english":"Catalan","language":"Català"},
{"short":"eo","chinese":"世界语","english":"Esperanto","language":"Esperanto"},
{"short":"hi","chinese":"北印度语","english":"Hindi","language":"हिन्दी"},
{"short":"lo","chinese":"老挝语","english":"Lao","language":"Lao"},
{"short":"sq","chinese":"阿尔巴尼亚语","english":"Albanian","language":"Shqip"},
{"short":"am","chinese":"阿姆哈拉语","english":"Amharic","language":"አማርኛ"},
{"short":"hy","chinese":"亚美尼亚语","english":"Armenian","language":"Armenian"},
{"short":"az","chinese":"阿塞拜疆语","english":"Azerbaijani","language":"Azerbaijani"},
{"short":"be","chinese":"白俄罗斯语","english":"Belarusian","language":"беларуская м"},
{"short":"bn","chinese":"孟加拉语","english":"Bengali","language":"বাংলা"},
{"short":"bs","chinese":"波斯尼亚语","english":"Bosnian","language":"Bosnian"},
{"short":"bg","chinese":"保加利亚语","english":"Bulgarian","language":"Български"},
{"short":"ceb","chinese":"宿务语","english":"Cebuano","language":"Cebuano"},
{"short":"ny","chinese":"齐佩瓦语","english":"Chichewa","language":"Chichewa"},
{"short":"co","chinese":"科西嘉语","english":"Corsican","language":"Corsican"},
{"short":"hr","chinese":"克罗地亚语","english":"Croatian","language":"Hrvatski"},
{"short":"nl","chinese":"荷兰语","english":"Dutch","language":"Nederlands"},
{"short":"et","chinese":"爱沙尼亚语","english":"Estonian","language":"Eesti Keel"},
{"short":"tl","chinese":"菲律宾语","english":"Filipino","language":"Tagalog"},
{"short":"fi","chinese":"芬兰语","english":"Finnish","language":"Suomi"},
{"short":"fy","chinese":"弗利然语","english":"Frisian","language":"Frisian"},
{"short":"gl","chinese":"加利西亚语","english":"Galician","language":"Galego"},
{"short":"ka","chinese":"格鲁吉亚语","english":"Georgian","language":"ქართული"},
{"short":"gu","chinese":"古吉特拉语","english":"Gujarati","language":"ગુજરાતી"},
{"short":"ht","chinese":"海地-克里奥尔语","english":"Haitian","language":"Kreyòl Ayisyen"},
{"short":"ha","chinese":"豪撒语","english":"Hausa","language":"Hausa"},
{"short":"haw","chinese":"夏威夷语","english":"Hawaiian","language":"Hawaiian"},
{"short":"iw","chinese":"希伯来语","english":"Hebrew","language":"עברית"},
{"short":"hmn","chinese":"苗语","english":"Hmong","language":"Hmong"},
{"short":"hu","chinese":"匈牙利语","english":"Hungarian","language":"Magyar"},
{"short":"is","chinese":"冰岛语","english":"Icelandic","language":"Íslenska"},
{"short":"ig","chinese":"伊博语","english":"Igbo","language":"Igbo"},
{"short":"jw","chinese":"爪哇语","english":"Javanese","language":"Javanese"},
{"short":"kn","chinese":"坎纳达语","english":"Kannada","language":"ಕನ್ನಡ"},
{"short":"kk","chinese":"哈萨克语","english":"Kazakh","language":"Kazakh"},
{"short":"km","chinese":"高棉语","english":"Khmer","language":"Khmer"},
{"short":"ku","chinese":"库尔德语","english":"Kurdish","language":"هه‌رێمی کوردستان"},
{"short":"ky","chinese":"吉尔吉斯斯坦语","english":"Kyrgyz","language":"Kyrgyz"},
{"short":"la","chinese":"拉丁语","english":"Latin","language":"Latin"},
{"short":"lv","chinese":"拉脱维亚语","english":"Latvian","language":"Latviešu"},
{"short":"lt","chinese":"立陶宛语","english":"Lithuanian","language":"Lietuvių"},
{"short":"lb","chinese":"卢森堡语","english":"Luxembou..","language":"Herzogtum Lëtzebuerg"},
{"short":"mk","chinese":"马其顿语","english":"Macedonian","language":"македонски"},
{"short":"mg","chinese":"马尔加什语","english":"Malagasy","language":"Malagasy"},
{"short":"ms","chinese":"马来语","english":"Malay","language":"Bahasa Melayu"},
{"short":"ml","chinese":"德拉维族(Dravidian)语","english":"Malayalam","language":"Malayalam "},
{"short":"mt","chinese":"马其他语","english":"Maltese","language":"Malti"},
{"short":"mi","chinese":"毛利语","english":"Maori","language":"Maori"},
{"short":"mr","chinese":"马拉地语","english":"Marathi","language":"Marathi"},
{"short":"mn","chinese":"蒙古族语","english":"Mongolian","language":"Mongolian"},
{"short":"my","chinese":"缅甸语","english":"Burmese","language":"Burmese"},
{"short":"ne","chinese":"尼泊尔语","english":"Nepali","language":"Nepali"},
{"short":"no","chinese":"挪威语","english":"Norwegian","language":"Norsk"},
{"short":"ps","chinese":"普什图语","english":"Pashto","language":"Pashto"},
{"short":"fa","chinese":"波斯语","english":"Persian","language":"فارسی"},
{"short":"pa","chinese":"旁遮普语","english":"Punjabi","language":"Punjabi"},
{"short":"sr","chinese":"塞尔维亚语","english":"Serbian","language":"Српски"},
{"short":"st","chinese":"塞索托语","english":"Sesotho","language":"Sesotho"},
{"short":"si","chinese":"僧伽罗语","english":"Sinhala","language":"Sinhala"},
{"short":"sk","chinese":"斯洛伐克语","english":"Slovak","language":"Slovenčina"},
{"short":"sl","chinese":"斯洛文尼亚语","english":"Slovenian","language":"slovenščina"},
{"short":"so","chinese":"索马里语","english":"Somali","language":"Somali"},
{"short":"sm","chinese":"萨摩亚语","english":"Samoan","language":"Samoan"},
{"short":"gd","chinese":"苏格兰盖尔语","english":"Scots Gaelic","language":"Gàidhlig"},
{"short":"sn","chinese":"修纳语","english":"Shona","language":"Shona"},
{"short":"sd","chinese":"信德语","english":"Sindhi","language":"سنڌي‎"},
{"short":"su","chinese":"巽他语","english":"Sundanese","language":"Sundanese"},
{"short":"sw","chinese":"斯瓦西里语","english":"Swahili","language":"Kiswahili"},
{"short":"tg","chinese":"塔吉克语","english":"Tajik","language":"Tajik"},
{"short":"ta","chinese":"泰米尔语","english":"Tamil","language":"தமிழ்"},
{"short":"te","chinese":"泰卢固语","english":"Telugu","language":"తెలుగు"},
{"short":"th","chinese":"泰语","english":"Thai","language":"ภาษาไทย"},
{"short":"uk","chinese":"乌克兰语","english":"Ukrainian","language":"Українська"},
{"short":"ur","chinese":"乌尔都语","english":"Urdu","language":"اردو"},
{"short":"uz","chinese":"乌兹别克语","english":"Uzbek","language":"Uzbek"},
{"short":"vi","chinese":"越南语","english":"Vietnamese","language":"Tiếng Việt"},
{"short":"cy","chinese":"威尔士语","english":"Welsh","language":"Cymraeg"},
{"short":"xh","chinese":"科萨语","english":"Xhosa","language":"Xhosa"},
{"short":"yi","chinese":"意地绪语","english":"Yiddish","language":"ײִדיש"},
{"short":"yo","chinese":"约鲁巴语","english":"Yoruba","language":"Yoruba"},
{"short":"zu","chinese":"祖鲁语","english":"Zulu","language":"Zulu"},
{"short":"rw","english":"Kinyarwanda","chinese":"卢旺达","language":"Kinyarwanda"},
{"short":"tt","english":"Tatar","chinese":"鞑靼语","language":"Татар"},
{"short":"or","english":"Oriya","chinese":"奥利亚语","language":"ଓଡିଆ"},
{"short":"tk","english":"Turkmen","chinese":"土库曼语","language":"Türkmenler"},
{"short":"ug","english":"Uyghur","chinese":"维吾尔语","language":"ئۇيغۇر"}]';
$data = json_decode($data);
foreach ($data as $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' start: ' . $v['short'] . PHP_EOL;
$languageModel = new WebLanguage();
$languageModel->add($v);
echo date('Y-m-d H:i:s') . ' end: ' . $v['short'] . PHP_EOL;
}
return true;
}
}
... ...
... ... @@ -231,8 +231,11 @@ class SyncProject extends Command
$this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']);
//新增数据抓取任务
$task_list = [];
if(!in_array('category_news',$param['api_type'])){
array_push($param['api_type'],'category_news');
}
foreach ($param['api_type'] as $v_type){
if($v_type == 'category'){
if($v_type == 'category' || $v_type == 'category_news'){
UpdateLog::createLog($id,$v_type,$param['get_data_url']);
}else{
$task_list[] = $v_type;
... ...
... ... @@ -10,6 +10,7 @@ namespace App\Console\Commands\Test;
use App\Helper\Common;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\File\Image;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
... ... @@ -43,10 +44,10 @@ class Demo extends Command
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
// public function __construct()
// {
// parent::__construct();
// }
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
... ... @@ -77,6 +78,7 @@ class Demo extends Command
*/
public function handle()
{
return $this->domain();
$result = app(SyncService::class)->projectAcceptAddress(1);
dd($result);
$data = [
... ... @@ -293,4 +295,26 @@ class Demo extends Command
}
dd(1);
}
/**
* @remark :获取域名
* @name :domain
* @author :lyh
* @method :post
* @time :2023/11/29 18:47
*/
public function domain(){
$domainModel = new DomainInfo();
$lists = $domainModel->list();
foreach ($lists as $k => $v){
if($v['project_id'] != 0){
echo date('Y-m-d H:i:s') . ' start: ' . $v['project_id'] . PHP_EOL;
$domain = 'https://'.$v['domain'].'/';
$url = $domain.'/api/update_robots/?project_id='.$v['project_id'];
http_get($url);
echo date('Y-m-d H:i:s') . ' end: ' . $v['project_id'] . PHP_EOL;
}
}
return true;
}
}
... ...
... ... @@ -3,12 +3,14 @@
namespace App\Console\Commands\Update;
use App\Helper\Arr;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Logic\Bside\Product\CategoryLogic;
use App\Models\Blog\Blog;
use App\Models\Collect\CollectSource;
use App\Models\Collect\CollectTask;
use App\Models\Com\UpdateLog;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
... ... @@ -117,7 +119,7 @@ class ProjectUpdate extends Command
$project = ProjectServer::useProject($project_id);
if ($project) {
if ($api_type == 'category') {
//分类
//产品分类
$url = $api_url . '?' . http_build_query(['w' => 'category']);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
... ... @@ -126,6 +128,16 @@ class ProjectUpdate extends Command
} else {
return true;
}
} elseif ($api_type == 'category_news') {
// 新闻分类
$url = $api_url . '?' . http_build_query(['w' => 'category_news']);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$items = $data['data'] ?? [];
$this->category_news_insert($project_id, $items, 0);
} else {
return true;
}
} elseif ($api_type == 'tag') {
//关键词
$url = $api_url . '?' . http_build_query(['w' => 'tag', 'page' => 1, 'pagesize' => 0]);
... ... @@ -334,6 +346,8 @@ class ProjectUpdate extends Command
if ($api_type == 'news') {
$model = new News();
$category_model = new NewsCategory();
$logic = new NewsLogic();
} else {
$model = new Blog();
}
... ... @@ -343,6 +357,12 @@ class ProjectUpdate extends Command
if ($route) {
$news = $model->read(['url' => $route], 'id');
if (!$news) {
//分类
$category_id = '';
if ($api_type == 'news' && ($item['category'] ?? [])) {
$category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
}
try {
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
... ... @@ -355,6 +375,7 @@ class ProjectUpdate extends Command
$id = $model->insertGetId([
'project_id' => $project_id,
'name' => $item['ttile'],
'category_id' => $category_id,
'seo_title' => $item['ttile'],
'seo_keywords' => $item['keywords'] ?? '',
'seo_description' => $item['description'] ?? '',
... ... @@ -457,7 +478,7 @@ class ProjectUpdate extends Command
return $task_id;
}
$task_list = UpdateLog::where('project_id', 543)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(7)->get();
$task_list = UpdateLog::where('project_id', 528)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(8)->get();
if ($task_list->count() == 0) {
return false;
}
... ... @@ -473,7 +494,7 @@ class ProjectUpdate extends Command
//获取地址路由
protected function get_url_route($url)
{
$arr = parse_url($url);
$arr = parse_url(urldecode($url));
if (empty($arr['path'])) {
return '';
}
... ... @@ -485,10 +506,10 @@ class ProjectUpdate extends Command
$path_arr = explode('/', $path);
return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2];
return end($path_arr) ? generateRoute(end($path_arr)) : generateRoute($path_arr[count($path_arr) - 2]);
}
//多级分类入库
//产品多级分类入库
protected function category_insert($project_id, $items, $pid = 0)
{
$model = new Category();
... ... @@ -524,6 +545,38 @@ class ProjectUpdate extends Command
}
}
//新闻多级分类入库
protected function category_news_insert($project_id, $items, $pid = 0)
{
$model = new NewsCategory();
foreach ($items as $item) {
$item['name'] = $this->special2str($item['name'] ?? '');
if ($item['name']) {
$parent = $model->read(['pid' => $pid, 'name' => $item['name']], 'id');
if (!$parent) {
try {
$parent_id = $model->addReturnId([
'project_id' => $project_id,
'name' => $item['name'],
'pid' => $pid,
'original_id' => $item['id']
]);
$this->set_map($this->get_url_route($item['url'] ?? ''), RouteMap::SOURCE_NEWS_CATE, $parent_id, $project_id);
} catch (\Exception $e) {
echo 'date:' . date('Y-m-d H:i:s') . ', category_news_insert error: ' . $e->getMessage() . PHP_EOL;
continue;
}
} else {
$parent_id = $parent['id'];
}
if (!empty($item['children'])) {
$this->category_news_insert($project_id, $item['children'], $parent_id);
}
}
}
}
//特殊字符转换
protected function special2str($str)
{
... ...
... ... @@ -83,6 +83,7 @@ class OnlineController extends BaseController
'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',
'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.quality_mid AS quality_mid',
];
return $select;
}
... ... @@ -108,6 +109,7 @@ class OnlineController extends BaseController
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['quality_mid_name'] = $manageModel->getName($item['quality_mid']);
$item['plan'] = Project::planMap()[$item['plan']];
$item['created_at'] = date('Y年m月d日', strtotime($item['created_at']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\OptimizeLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiPrefix;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
... ... @@ -73,6 +74,7 @@ class OptimizeController extends BaseController
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['quality_mid_name'] = $manageModel->getName($item['quality_mid']);
$item['plan'] = Project::planMap()[$item['plan']];
$item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
... ... @@ -244,9 +246,20 @@ class OptimizeController extends BaseController
$projectModel = new Project();
$rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]);
if($rs === false){
$this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
$this->response('执行错误,请联系开发人员',Code::SYSTEM_ERROR);
}
//TODO::通知C端
$this->response('success');
$projectLogic = new ProjectLogic();
$project = $projectLogic->getProjectInfo($this->param['project_id']);
$domain = !empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '';
if(empty($domain)){
$domain = $project['deploy_build']['test_domain'];
}
$url = $domain.'api/update_robots/?project_id='.$this->param['project_id'];
$res = curlGet($url);
if(empty($res) || $res['status'] != 200){
$this->response('生成robots失败,请联系开发人员',Code::SYSTEM_ERROR,['url'=>$url]);
}
$this->response('success',Code::SUCCESS,['url'=>$domain.'robots.txt']);
}
}
... ...
... ... @@ -310,6 +310,7 @@ class ProjectController extends BaseController
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['quality_mid_name'] = $manageModel->getName($item['quality_mid']);
$item['plan'] = Project::planMap()[$item['plan']];
$item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
... ...
<?php
/**
* @remark :
* @name :LanguageController.php
* @author :lyh
* @method :post
* @time :2023/11/30 11:21
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\WebSetting\WebLanguage;
class LanguageController extends BaseController
{
/**
* @remark :获取小语种列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/11/30 10:59
*/
public function lists(){
$webLanguageModel = new WebLanguage();
$lists = $webLanguageModel->list();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -69,10 +69,12 @@ class OnlineCheckLogic extends BaseLogic
*/
public function saveOnlineCheck(){
$info = $this->model->read(['project_id'=>$this->param['id']]);
$projectModel = new Project();
if($info !== false){
$this->fail('已提交,请勿重复提交');
}else{
$projectModel = new Project();
//提交审核修改状态为审核中
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$this->param['id']]);
//组装数据
$data = [
'project_id' => $this->param['id'],
... ... @@ -85,8 +87,6 @@ class OnlineCheckLogic extends BaseLogic
if($rs === false){
$this->fail('error');
}
//提交审核修改状态为审核中
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$this->param['id']]);
}
return $this->success();
}
... ...
... ... @@ -64,7 +64,8 @@ class BTemplateLogLogic extends BaseLogic
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
}else{
$other = str_replace('<header','',characterTruncation($info['text'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
}
}catch (\Exception $e){
... ... @@ -118,7 +119,8 @@ class BTemplateLogLogic extends BaseLogic
$this->fail('当前数据不存在,或已被删除');
}
if(empty($info['other'])){
$info['other'] = str_replace('<header','',characterTruncation($info['text'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$info['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
}
$html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other'].
$info['head_html'].$info['main_html'].$info['footer_html'];
... ...
... ... @@ -277,7 +277,8 @@ class BTemplateLogic extends BaseLogic
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
];
$other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
... ... @@ -335,8 +336,9 @@ class BTemplateLogic extends BaseLogic
'main_css'=>$param['main_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=> str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
... ... @@ -376,8 +378,7 @@ class BTemplateLogic extends BaseLogic
$route = 'all';
}
}
return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]);
return $this->success();
return $this->addUpdateNotify($type,$route);
}
/**
... ...
... ... @@ -66,8 +66,8 @@ class CustomTemplateLogic extends BaseLogic
try {
$this->param['url'] = str_replace_url($this->param['url']);
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['url'] = $this->editCustomRoute($this->param['url']);
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']);
$this->editCustomRoute($this->param['url']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
... ... @@ -75,9 +75,10 @@ class CustomTemplateLogic extends BaseLogic
}
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
}
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
$this->model->edit(['url'=>$route],['id'=>$id]);
}
}catch (\Exception $e){
$this->fail('error');
}
... ... @@ -110,8 +111,8 @@ class CustomTemplateLogic extends BaseLogic
if($rs === false){
$this->fail('系统错误,请联系管理');
}
$data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$info['url']];
$this->updateNotify($data);
//通知
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
return $this->success();
}
... ... @@ -136,8 +137,9 @@ class CustomTemplateLogic extends BaseLogic
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'other'=> str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
... ... @@ -151,7 +153,6 @@ class CustomTemplateLogic extends BaseLogic
*/
public function saveCommonTemplate($html,$template_id){
$type = $this->getType();
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
... ... @@ -160,7 +161,8 @@ class CustomTemplateLogic extends BaseLogic
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
if($info === false){
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
... ... @@ -209,14 +211,10 @@ class CustomTemplateLogic extends BaseLogic
$this->fail('404页面链接不可修改');
}
if($info['url'] != $route){
//生成一条删除路由记录
$data = [
'source'=>RouteMap::SOURCE_PAGE,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
$this->curlDelRoute($info['url']);
}
return $route;
return true;
}
/**
... ... @@ -260,11 +258,7 @@ class CustomTemplateLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$data = [
'source' => RouteMap::SOURCE_NEWS,
'route' => $info['url'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['url']);
return $this->success();
}
... ...
... ... @@ -341,6 +341,8 @@ class VisualizationLogic extends BaseLogic
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
... ... @@ -362,7 +364,8 @@ class VisualizationLogic extends BaseLogic
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
if($info === false){
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
... ...
... ... @@ -142,49 +142,36 @@ class BaseLogic extends Logic
}
/**
* @name :(通知更新)projectUrl
* @name :生成一条新路由记录
* @author :lyh
* @method :post
* @time :2023/6/6 14:09
*/
function updateNotify($data)
public function addUpdateNotify($type,$route)
{
$updateNotifyModel = new UpdateNotify();
if($data['route'] != 'all'){
$info = $updateNotifyModel->read(['project_id'=>$data['project_id'],'route'=>$data['route'],'status'=>1]);
$info = $updateNotifyModel->read(['project_id'=>$this->user['project_id'],'route'=>$route,'status'=>1]);
if($info === false){
$param = [
'project_id'=>$data['project_id'],
'type'=>$data['type'],
'route'=>$data['route'],
'project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route,'status'=>1
];
$updateNotifyModel->add($param);
}
//单页面直接通知更新
$url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$data['route'];
}else{
$url = $this->user['domain'].'api/webInfo/?type=clear_website';
$updateNotifyModel->edit(['route'=>$route],['project_id'=>$this->user['project_id'],'type'=>$type,'status'=>1]);
}
curlGet($url);
return $this->success();
}
/**
* @remark :删除和编辑路由时生成一条记录
* @name :setRouteDeleteSave
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
* @method :post
* @time :2023/9/7 9:38
* @time :2023/11/30 14:43
*/
public function setRouteDeleteSave($param){
$routeDeleteModel = new RouteDelete();
$data = [
'project_id'=>$this->user['project_id'],
'source'=>$param['source'],
'created_at'=>date('Y-m-d H:i:s'),
'route'=>$param['route'],
];
$routeDeleteModel->insert($data);
public function curlDelRoute($route){
$url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$route;
curlGet($url);
return $this->success();
}
}
... ...
... ... @@ -32,8 +32,7 @@ class BlogCategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//查看路由是否更新
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
$this->editCategoryRoute($this->param['id'], $this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
... ... @@ -46,18 +45,17 @@ class BlogCategoryLogic extends BaseLogic
//拼接参数
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
$this->edit(['alias'=>$route],['id'=>$id]);
//处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->edit(['alias'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
return $this->success();
}
... ... @@ -114,11 +112,8 @@ class BlogCategoryLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
$this->curlDelRoute($info['alias']);
}
return true;
}
... ... @@ -311,11 +306,7 @@ class BlogCategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$data = [
'source'=>RouteMap::SOURCE_BLOG_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['alias']);
return $this->success();
}
... ... @@ -331,27 +322,22 @@ class BlogCategoryLogic extends BaseLogic
*/
public function importBlogCategory($project_id,$user_id,$category){
$return = [];
$cate_arr = explode('/',$category);
$pid = 0;
foreach ($cate_arr as $v){
if($v){
$category_info = $this->model->read(['name'=>$v,'pid'=>$pid]);
if(!$category_info){
$id = $this->model->addReturnId(['name'=>$v,'pid'=>$pid,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_BLOG_CATE, $id, $project_id);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}else{
$id = $category_info['id'];
}
$return[] = $id;
$pid = $id;
}
}
return $this->getLastCategory($return);
}
... ...
... ... @@ -34,22 +34,20 @@ class BlogLogic extends BaseLogic
try {
$this->param = $this->paramProcessing($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否更新路由
$id = $this->param['id'];
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
$this->editNewsRoute($this->param['id'],$this->param['url']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$id = $this->model->addReturnId($this->param);
}
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
$this->edit(['url'=>$route],['id'=>$id]);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG, 'route'=>$route]);
return $this->success();
}
... ... @@ -64,11 +62,8 @@ class BlogLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
if($info['url'] != $route){
$data = [
'source'=>RouteMap::SOURCE_BLOG,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
$this->curlDelRoute($info['url']);
}
return true;
}
... ... @@ -90,10 +85,11 @@ class BlogLogic extends BaseLogic
/**
* @name :获取数据详情
* @return array
* @author :liyuhang
* @method
* @remark :获取数据详情
* @name :blogInfo
* @author :lyh
* @method :post
* @time :2023/11/30 15:17
*/
public function blogInfo(){
$info = $this->model->read($this->param);
... ... @@ -110,11 +106,11 @@ class BlogLogic extends BaseLogic
/**
* @name :修改状态
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :修改状态
* @name :blogStatus
* @author :lyh
* @method :post
* @time :2023/11/30 15:16
*/
public function blogStatus(){
$this->param['operator_id'] = $this->user['id'];
... ... @@ -126,10 +122,11 @@ class BlogLogic extends BaseLogic
}
/**
* @name :删除
* @return void
* @author :liyuhang
* @method
* @remark :删除
* @name :blogDel
* @author :lyh
* @method :post
* @time :2023/11/30 15:17
*/
public function blogDel(){
DB::beginTransaction();
... ... @@ -158,11 +155,7 @@ class BlogLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
$data = [
'source'=>RouteMap::SOURCE_BLOG,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['url']);
return $this->success();
}
... ...
... ... @@ -55,7 +55,7 @@ class NavLogic extends BaseLogic
$this->model->add($this->param);
}
//编辑菜单后,通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
$this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all');
return $this->success();
}
... ... @@ -97,7 +97,7 @@ class NavLogic extends BaseLogic
$this->fail('error');
}
//编辑菜单后,通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
$this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all');
return $this->success();
}
... ...
... ... @@ -44,11 +44,10 @@ class NewsCategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->param['operator_id'] = $this->user['id'];
//查看路由是否更新
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
$this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
if(!isset($this->param['alias']) || empty($this->param['alias'])){
... ... @@ -56,18 +55,17 @@ class NewsCategoryLogic extends BaseLogic
}
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->model->edit(['alias'=>$route],['id'=>$id]);
//当父级分类拥有产品时,处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
//更新通知记录表
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
return $this->success();
}
... ... @@ -124,22 +122,19 @@ class NewsCategoryLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute($info['alias']);
}
return true;
}
/**
* @name :修改状态
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :修改状态
* @name :status_news_category
* @author :lyh
* @method :post
* @time :2023/11/30 15:13
*/
public function status_news_category(){
$this->param['operator_id'] = $this->user['id'];
... ... @@ -291,13 +286,8 @@ class NewsCategoryLogic extends BaseLogic
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['alias']);
return $this->success();
}
... ... @@ -313,22 +303,18 @@ class NewsCategoryLogic extends BaseLogic
*/
public function importNewsCategory($project_id,$user_id,$category){
$return = [];
$cate_arr = explode('/',$category);
$pid = 0;
foreach ($cate_arr as $v){
if($v){
$category_info = $this->model->read(['name'=>$v,'pid'=>$pid]);
if(!$category_info){
$id = $this->model->addReturnId(['name'=>$v,'pid'=>$pid,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_NEWS_CATE, $id, $project_id);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}else{
$id = $category_info['id'];
}
$return[] = $id;
$pid = $id;
}
... ...
... ... @@ -63,23 +63,22 @@ class NewsLogic extends BaseLogic
try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
//是否更新路由
$this->editNewsRoute($this->param['id'], $this->param['url']);
$id = $this->param['id'];
$this->edit($this->param, ['id' => $this->param['id']]);
} else {
$id = $this->model->addReturnId($this->param);
}
//更新路由
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->edit(['url' => $route], ['id' => $id]);
}
//更新路由
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
//通知更新
$this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
return $this->success();
}
... ... @@ -95,11 +94,8 @@ class NewsLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
if ($info['url'] != $route) {
$data = [
'source' => RouteMap::SOURCE_NEWS,
'route' => $info['url'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->curlDelRoute($info['url']);
}
return true;
}
... ... @@ -271,11 +267,7 @@ class NewsLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$data = [
'source' => RouteMap::SOURCE_NEWS,
'route' => $info['url'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['url']);
return $this->success();
}
... ...
... ... @@ -113,19 +113,20 @@ class CategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否编辑路由
$id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $this->param['id'], $this->user['project_id']);
$this->editCategoryRoute($this->param['id'],$this->param['route']);
//处理子集
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
$this->edit(['route'=>$route],['id'=>$id]);
//处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$this->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
... ... @@ -133,9 +134,6 @@ class CategoryLogic extends BaseLogic
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
//通知更新
$notifyData = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route];
$this->updateNotify($notifyData);
return $this->success();
}
... ... @@ -234,13 +232,10 @@ class CategoryLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
if($info['route'] != $route){
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_CATE,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
$this->curlDelRoute($info['route']);
}
return $id;
return true;
}
/**
... ... @@ -283,11 +278,7 @@ class CategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_CATE,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['route']);
return $this->success();
}
... ... @@ -302,27 +293,22 @@ class CategoryLogic extends BaseLogic
*/
public function importProductCategory($project_id,$category){
$return = [];
$cate_arr = explode('/',$category);
$pid = 0;
foreach ($cate_arr as $v){
if($v){
$category_info = $this->model->read(['title'=>$v,'pid'=>$pid]);
if(!$category_info){
$id = $this->model->addReturnId(['title'=>$v,'pid'=>$pid,'project_id'=>$project_id]);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_CATE, $id, $project_id);
$this->model->edit(['route'=>$route],['id'=>$id]);
}else{
$id = $category_info['id'];
}
$return[] = $id;
$pid = $id;
}
}
//清除缓存
Common::del_user_cache('product_category',$project_id);
return $this->getLastCategory($return);
... ...
... ... @@ -56,17 +56,16 @@ class KeywordLogic extends BaseLogic
try {
$this->param = $this->handleSaveParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
//TODO::不能修改路由
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->param['id'];
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$this->param = $this->addHandleParam($this->param);
$id = $this->model->insertGetId($this->param);
}
//路由映射
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
DB::commit();
... ... @@ -74,12 +73,24 @@ class KeywordLogic extends BaseLogic
DB::rollBack();
$this->fail('保存失败');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_KEYWORD, 'route'=>$route]);
return $this->success();
}
/**
* @remark :添加组装数据
* @name :addHandleParam
* @author :lyh
* @method :post
* @time :2023/11/30 15:00
*/
public function addHandleParam($param){
$param['project_id'] = $this->user['project_id'];
$param['created_at'] = date('Y-m-d H:i:s');
$param['updated_at'] = $param['created_at'];
return $this->success($param);
}
/**
* @remark :保存数据时参数处理
* @name :handleSaveParam
* @author :lyh
... ... @@ -174,11 +185,7 @@ class KeywordLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['route']);
return $this->success();
}
... ... @@ -193,9 +200,7 @@ class KeywordLogic extends BaseLogic
*/
public function importProductKeyword($project_id,$keyword){
$return = [];
$keyword_arr = explode(',',$keyword);
foreach ($keyword_arr as $v){
$keyword_info = $this->model->read(['title'=>$v]);
if(!$keyword_info){
... ... @@ -207,7 +212,6 @@ class KeywordLogic extends BaseLogic
}
$return[] = $k_id;
}
//清除缓存
Common::del_user_cache('product_keyword',$project_id);
return ','.implode(',',$return).',';
... ...
... ... @@ -56,16 +56,17 @@ class ProductLogic extends BaseLogic
DB::connection('custom_mysql')->beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
//查看路由是否更新
$this->param['route'] = $this->editProductRoute($this->param['route']);
$this->editProductRoute($this->param['id'],$this->param['route']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param = $this->addHandleParam($this->param);
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->model->edit(['route'=> $this->param['route']],['id'=>$id]);
//产品分类关联
CategoryRelated::saveRelated($id, $category_ids);
//保存扩展字段
... ... @@ -75,8 +76,6 @@ class ProductLogic extends BaseLogic
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误请联系管理员');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$this->param['route']]);
return $this->success();
}
... ... @@ -154,10 +153,15 @@ class ProductLogic extends BaseLogic
}else{
$this->param['thumb'] = Arr::a2s([]);
}
try {
if(isset($this->param['route']) && !empty($this->param['route'])){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
$this->editProductRoute($this->param['route']);
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
}catch (\Exception $e){
$this->fail('系统错误,请连续管理员');;
}
return $this->success();
}
... ... @@ -285,15 +289,11 @@ class ProductLogic extends BaseLogic
* @method :post
* @time :2023/9/7 10:02
*/
public function editProductRoute($route){
$info = $this->model->read(['id'=>$this->param['id']]);
public function editProductRoute($id,$route){
$info = $this->model->read(['id'=>$id]);
if($info['route'] != $route){
//生成一条删除路由记录
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$route,
];
$this->setRouteDeleteSave($data);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
$this->curlDelRoute($info['route']);
}
return $route;
}
... ... @@ -340,11 +340,7 @@ class ProductLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
$this->curlDelRoute($info['route']);
return $this->success();
}
... ...
... ... @@ -33,8 +33,8 @@ class UpdateLog extends Model
$log->project_id = $project_id;
$log->api_type = $type;
$log->api_url = $url;
$log->sort = $type == 'category' ? 0 : 1;
$log->collect_status = ($type == 'category' || $type == 'website_info' || $type == 'tag') ? 1 : 0;
$log->sort = ($type == 'category' || $type == 'category_news') ? 0 : 1;
$log->collect_status = ($type == 'category' || $type == 'category_news' || $type == 'website_info' || $type == 'tag') ? 1 : 0;
return $log->save();
}
return true;
... ...
<?php
/**
* @remark :
* @name :WebLanguage.php
* @author :lyh
* @method :post
* @time :2023/11/30 10:50
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class WebLanguage extends Base
{
protected $table = 'gl_web_language';
}
... ...
... ... @@ -418,6 +418,11 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/upload', [\App\Http\Controllers\Bside\FileManage\FileManageController::class, 'upload'])->name('file_manager_upload');
Route::any('/delete', [\App\Http\Controllers\Bside\FileManage\FileManageController::class, 'delete'])->name('file_manager_delete');
});
//小语种
Route::prefix('language')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...