作者 lyh

gx

@@ -6,6 +6,7 @@ use App\Utils\LogUtils; @@ -6,6 +6,7 @@ use App\Utils\LogUtils;
6 use GuzzleHttp\Client; 6 use GuzzleHttp\Client;
7 use GuzzleHttp\Exception\GuzzleException; 7 use GuzzleHttp\Exception\GuzzleException;
8 use Illuminate\Support\Carbon; 8 use Illuminate\Support\Carbon;
  9 +use App\Models\UpdateNotify;
9 10
10 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); 11 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
11 /** 12 /**
@@ -439,6 +440,27 @@ if (!function_exists('getImageUrl')) { @@ -439,6 +440,27 @@ if (!function_exists('getImageUrl')) {
439 } 440 }
440 } 441 }
441 442
  443 +if (!function_exists('getImageUrl')) {
  444 + /**
  445 + * @name :(获取当前登录用户域名并通知更新)projectUrl
  446 + * @author :lyh
  447 + * @method :post
  448 + * @time :2023/6/6 14:09
  449 + */
  450 + function updateNotify($domain,$data)
  451 + {
  452 + $param = [
  453 + 'project_id'=>$data['project_id'],
  454 + 'type'=>$data['type'],
  455 + 'route'=>$data['route'],
  456 + 'created_at'=>date('Y-m-d H:i:s'),
  457 + 'updated_at'=>date('Y-m-d H:i:s')
  458 + ];
  459 + $id = (new UpdateNotify())->insertGetId($data);
  460 + $urlStr = $domain.'api/updateHtmlNotify?id=' . $id;
  461 + return http_get($urlStr);
  462 + }
  463 +}
442 /** 464 /**
443 * @remark :字符串截取 465 * @remark :字符串截取
444 * @name :characterTruncation 466 * @name :characterTruncation
@@ -198,22 +198,6 @@ class BaseController extends Controller @@ -198,22 +198,6 @@ class BaseController extends Controller
198 } 198 }
199 199
200 /** 200 /**
201 - * @name :(获取当前登录用户域名并通知更新)projectUrl  
202 - * @author :lyh  
203 - * @method :post  
204 - * @time :2023/6/6 14:09  
205 - */  
206 - public function projectUrlNotify($str = ''){  
207 - $urlStr = 'api/updateHtmlNotify?model='.$str;  
208 - $domain = $this->getProjectDomain();  
209 - if(!empty($domain)){  
210 - $url = $domain.$urlStr;  
211 - return http_get($url);  
212 - }  
213 - return false;  
214 - }  
215 -  
216 - /**  
217 * @remark :获取域名 201 * @remark :获取域名
218 * @name :getProjectDomain 202 * @name :getProjectDomain
219 * @author :lyh 203 * @author :lyh
@@ -89,9 +89,7 @@ class BlogController extends BaseController @@ -89,9 +89,7 @@ class BlogController extends BaseController
89 */ 89 */
90 public function add(BlogRequest $request,BlogLogic $blogLogic){ 90 public function add(BlogRequest $request,BlogLogic $blogLogic){
91 $request->validated(); 91 $request->validated();
92 - $blogLogic->blog_add();  
93 - //TODO::通知网站更新  
94 - $this->projectUrlNotify($this->updateModelView); 92 + $blogLogic->blogAdd();
95 $this->response('success'); 93 $this->response('success');
96 } 94 }
97 95
@@ -106,9 +104,7 @@ class BlogController extends BaseController @@ -106,9 +104,7 @@ class BlogController extends BaseController
106 ],[ 104 ],[
107 'id.required' => 'ID不能为空' 105 'id.required' => 'ID不能为空'
108 ]); 106 ]);
109 - $blogLogic->blog_edit();  
110 - //TODO::通知网站更新  
111 - $this->projectUrlNotify($this->updateModelView); 107 + $blogLogic->blogEdit();
112 $this->response('success'); 108 $this->response('success');
113 } 109 }
114 110
@@ -87,9 +87,7 @@ class NewsController extends BaseController @@ -87,9 +87,7 @@ class NewsController extends BaseController
87 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ 87 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){
88 $newsRequest->validated(); 88 $newsRequest->validated();
89 $newsLogic->news_add(); 89 $newsLogic->news_add();
90 - //TODO::通知网站更新  
91 - $res = $this->projectUrlNotify($this->updateModelView);  
92 - $this->response('success',Code::SUCCESS,$res); 90 + $this->response('success');
93 } 91 }
94 92
95 /** 93 /**
@@ -72,8 +72,6 @@ class ProductController extends BaseController @@ -72,8 +72,6 @@ class ProductController extends BaseController
72 public function save(ProductRequest $request, ProductLogic $logic) 72 public function save(ProductRequest $request, ProductLogic $logic)
73 { 73 {
74 $data = $logic->save($this->param); 74 $data = $logic->save($this->param);
75 - //通知更新界面  
76 - $this->projectUrlNotify('product');  
77 return $this->success($data); 75 return $this->success($data);
78 } 76 }
79 77
@@ -64,9 +64,9 @@ class ATemplateLogic extends BaseLogic @@ -64,9 +64,9 @@ class ATemplateLogic extends BaseLogic
64 $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); 64 $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
65 $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); 65 $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
66 $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'); 66 $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s');
67 - $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/s');  
68 - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s');  
69 - $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/s'); 67 + $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
  68 + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  69 + $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
70 } 70 }
71 /** 71 /**
72 * @remark :修改模块状态 72 * @remark :修改模块状态
@@ -124,14 +124,14 @@ class BTemplateLogic extends BaseLogic @@ -124,14 +124,14 @@ class BTemplateLogic extends BaseLogic
124 if($homeTemplateInfo === false){ 124 if($homeTemplateInfo === false){
125 $this->fail('请先装修首页'); 125 $this->fail('请先装修首页');
126 } 126 }
127 - $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $homeTemplateInfo['html']); 127 + $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
128 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html); 128 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
129 }else{ 129 }else{
130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); 130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
131 if($homeTemplateInfo === false){ 131 if($homeTemplateInfo === false){
132 $this->fail('请先装修首页'); 132 $this->fail('请先装修首页');
133 } 133 }
134 - $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']); 134 + $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
135 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html); 135 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
136 } 136 }
137 $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据 137 $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
@@ -199,7 +199,7 @@ class BTemplateLogic extends BaseLogic @@ -199,7 +199,7 @@ class BTemplateLogic extends BaseLogic
199 public function templateSaveParam($template_id){ 199 public function templateSaveParam($template_id){
200 $this->param['project_id'] = $this->user['project_id']; 200 $this->param['project_id'] = $this->user['project_id'];
201 if($this->param['source'] == 1){//首页 201 if($this->param['source'] == 1){//首页
202 - $this->param['html'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/footer>/s'); 202 + $this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
203 }else{ 203 }else{
204 $this->param['html'] = $this->param['main_html']; 204 $this->param['html'] = $this->param['main_html'];
205 } 205 }
@@ -240,9 +240,9 @@ class BTemplateLogic extends BaseLogic @@ -240,9 +240,9 @@ class BTemplateLogic extends BaseLogic
240 $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); 240 $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
241 $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); 241 $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
242 $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'); 242 $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s');
243 - $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/s');  
244 - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s');  
245 - $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/s'); 243 + $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
  244 + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  245 + $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
246 } 246 }
247 247
248 248
@@ -60,7 +60,7 @@ class CustomTemplateLogic extends BaseLogic @@ -60,7 +60,7 @@ class CustomTemplateLogic extends BaseLogic
60 if(isset($this->param['html']) && !empty($this->param['html'])){ 60 if(isset($this->param['html']) && !empty($this->param['html'])){
61 $html = $this->param['html']; 61 $html = $this->param['html'];
62 $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s'); 62 $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
63 - $this->param['html_style'] = characterTruncation($html,'/<style id="vvvebjs-styles">(.*?)<\/style>/s'); 63 + $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
64 } 64 }
65 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 65 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
66 }else{ 66 }else{
@@ -108,9 +108,9 @@ class CustomTemplateLogic extends BaseLogic @@ -108,9 +108,9 @@ class CustomTemplateLogic extends BaseLogic
108 ]); 108 ]);
109 if(empty($preg_html)){ 109 if(empty($preg_html)){
110 $preg_html = "<main></main>"; 110 $preg_html = "<main></main>";
111 - $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $TemplateInfo['html']); 111 + $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']);
112 }else{ 112 }else{
113 - $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']); 113 + $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']);
114 } 114 }
115 //内容 115 //内容
116 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html); 116 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html);
@@ -166,4 +166,5 @@ class BaseLogic extends Logic @@ -166,4 +166,5 @@ class BaseLogic extends Logic
166 } 166 }
167 return ''; 167 return '';
168 } 168 }
  169 +
169 } 170 }
@@ -55,12 +55,19 @@ class BlogCategoryLogic extends BaseLogic @@ -55,12 +55,19 @@ class BlogCategoryLogic extends BaseLogic
55 $cate_id = $this->model->insertGetId($this->param); 55 $cate_id = $this->model->insertGetId($this->param);
56 //处理子集 56 //处理子集
57 $this->addProcessingSon($cate_id); 57 $this->addProcessingSon($cate_id);
58 - RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $cate_id, $this->user['project_id']); 58 + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $cate_id, $this->user['project_id']);
59 DB::commit(); 59 DB::commit();
60 }catch (\Exception $e){ 60 }catch (\Exception $e){
61 DB::rollBack(); 61 DB::rollBack();
62 $this->fail('error'); 62 $this->fail('error');
63 } 63 }
  64 + //TODO::通知网站更新
  65 + $data = [
  66 + 'project_id'=>$this->user['project_id'],
  67 + 'type'=>RouteMap::SOURCE_BLOG_CATE,
  68 + 'route'=>$route,
  69 + ];
  70 + updateNotify($this->user['domain'],$data);
64 return $this->success(); 71 return $this->success();
65 } 72 }
66 73
@@ -91,7 +98,14 @@ class BlogCategoryLogic extends BaseLogic @@ -91,7 +98,14 @@ class BlogCategoryLogic extends BaseLogic
91 } 98 }
92 $this->param['operator_id'] = $this->user['id']; 99 $this->param['operator_id'] = $this->user['id'];
93 $this->edit($this->param,['id'=>$this->param['id']]); 100 $this->edit($this->param,['id'=>$this->param['id']]);
94 - RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); 101 + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
  102 + //TODO::通知网站更新
  103 + $data = [
  104 + 'project_id'=>$this->user['project_id'],
  105 + 'type'=>RouteMap::SOURCE_BLOG_CATE,
  106 + 'route'=>$route,
  107 + ];
  108 + updateNotify($this->user['domain'],$data);
95 return $this->success(); 109 return $this->success();
96 } 110 }
97 111
@@ -53,19 +53,25 @@ class BlogLogic extends BaseLogic @@ -53,19 +53,25 @@ class BlogLogic extends BaseLogic
53 * @author :liyuhang 53 * @author :liyuhang
54 * @method 54 * @method
55 */ 55 */
56 - public function blog_add(){ 56 + public function blogAdd(){
57 //拼接参数 57 //拼接参数
58 DB::beginTransaction(); 58 DB::beginTransaction();
59 try { 59 try {
60 $this->param = $this->paramProcessing($this->param); 60 $this->param = $this->paramProcessing($this->param);
61 $rs = $this->model->insertGetId($this->param); 61 $rs = $this->model->insertGetId($this->param);
62 - RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); 62 + $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
63 DB::commit(); 63 DB::commit();
64 }catch (\Exception $e){ 64 }catch (\Exception $e){
65 DB::rollBack(); 65 DB::rollBack();
66 $this->fail('error'); 66 $this->fail('error');
67 } 67 }
68 - //TODO::写入日志 68 + //TODO::通知网站更新
  69 + $data = [
  70 + 'project_id'=>$this->user['project_id'],
  71 + 'type'=>RouteMap::SOURCE_BLOG,
  72 + 'route'=>$this->param['url'],
  73 + ];
  74 + updateNotify($this->user['domain'],$data);
69 return $this->success(); 75 return $this->success();
70 } 76 }
71 77
@@ -75,18 +81,25 @@ class BlogLogic extends BaseLogic @@ -75,18 +81,25 @@ class BlogLogic extends BaseLogic
75 * @author :liyuhang 81 * @author :liyuhang
76 * @method 82 * @method
77 */ 83 */
78 - public function blog_edit(){ 84 + public function blogEdit(){
79 //拼接参数 85 //拼接参数
80 $this->param = $this->paramProcessing($this->param); 86 $this->param = $this->paramProcessing($this->param);
81 DB::beginTransaction(); 87 DB::beginTransaction();
82 try { 88 try {
83 - RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); 89 + $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
84 $this->edit($this->param,['id'=>$this->param['id']]); 90 $this->edit($this->param,['id'=>$this->param['id']]);
85 DB::commit(); 91 DB::commit();
86 }catch (\Exception $e){ 92 }catch (\Exception $e){
87 DB::rollBack(); 93 DB::rollBack();
88 $this->fail('error'); 94 $this->fail('error');
89 } 95 }
  96 + //TODO::通知网站更新
  97 + $data = [
  98 + 'project_id'=>$this->user['project_id'],
  99 + 'type'=>RouteMap::SOURCE_BLOG,
  100 + 'route'=>$this->param['url'],
  101 + ];
  102 + updateNotify($this->user['domain'],$data);
90 return $this->success(); 103 return $this->success();
91 } 104 }
92 /** 105 /**
@@ -64,12 +64,19 @@ class NewsCategoryLogic extends BaseLogic @@ -64,12 +64,19 @@ class NewsCategoryLogic extends BaseLogic
64 $cate_id = $this->model->insertGetId($this->param); 64 $cate_id = $this->model->insertGetId($this->param);
65 //当父级分类拥有产品时,处理产品 65 //当父级分类拥有产品时,处理产品
66 $this->addProcessingSon($cate_id); 66 $this->addProcessingSon($cate_id);
67 - RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $cate_id, $this->user['project_id']); 67 + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $cate_id, $this->user['project_id']);
68 DB::commit(); 68 DB::commit();
69 }catch (\Exception $e){ 69 }catch (\Exception $e){
70 DB::rollBack(); 70 DB::rollBack();
71 $this->fail('error'); 71 $this->fail('error');
72 } 72 }
  73 + //TODO::通知网站更新
  74 + $data = [
  75 + 'project_id'=>$this->user['project_id'],
  76 + 'type'=>RouteMap::SOURCE_NEWS_CATE,
  77 + 'route'=>$route,
  78 + ];
  79 + updateNotify($this->user['domain'],$data);
73 return $this->success(); 80 return $this->success();
74 } 81 }
75 82
@@ -82,6 +89,29 @@ class NewsCategoryLogic extends BaseLogic @@ -82,6 +89,29 @@ class NewsCategoryLogic extends BaseLogic
82 public function edit_news_category(){ 89 public function edit_news_category(){
83 //验证名称是否存在 90 //验证名称是否存在
84 $this->verifyParamName(); 91 $this->verifyParamName();
  92 + //验证是否可编辑
  93 + $this->verifyEditParam();
  94 + $this->param['operator_id'] = $this->user['id'];
  95 + $this->edit($this->param,['id'=>$this->param['id']]);
  96 + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
  97 + //TODO::通知网站更新
  98 + $data = [
  99 + 'project_id'=>$this->user['project_id'],
  100 + 'type'=>RouteMap::SOURCE_NEWS_CATE,
  101 + 'route'=>$route,
  102 + ];
  103 + updateNotify($this->user['domain'],$data);
  104 + return $this->success();
  105 + }
  106 +
  107 + /**
  108 + * @remark :验证是否可编辑
  109 + * @name :verifyEditParam
  110 + * @author :lyh
  111 + * @method :post
  112 + * @time :2023/7/31 15:41
  113 + */
  114 + public function verifyEditParam(){
85 $info = $this->model->read(['id'=>$this->param['id']]); 115 $info = $this->model->read(['id'=>$this->param['id']]);
86 if($info['id'] == $this->param['pid']){ 116 if($info['id'] == $this->param['pid']){
87 $this->fail('不能成为自己的上级'); 117 $this->fail('不能成为自己的上级');
@@ -98,9 +128,6 @@ class NewsCategoryLogic extends BaseLogic @@ -98,9 +128,6 @@ class NewsCategoryLogic extends BaseLogic
98 $this->fail('当前分类下已存在新闻,不允许修改上级'); 128 $this->fail('当前分类下已存在新闻,不允许修改上级');
99 } 129 }
100 } 130 }
101 - $this->param['operator_id'] = $this->user['id'];  
102 - $this->edit($this->param,['id'=>$this->param['id']]);  
103 - RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);  
104 return $this->success(); 131 return $this->success();
105 } 132 }
106 133
@@ -59,12 +59,19 @@ class NewsLogic extends BaseLogic @@ -59,12 +59,19 @@ class NewsLogic extends BaseLogic
59 try { 59 try {
60 $this->param = $this->paramProcessing($this->param); 60 $this->param = $this->paramProcessing($this->param);
61 $rs = $this->model->insertGetId($this->param); 61 $rs = $this->model->insertGetId($this->param);
62 - RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); 62 + $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
63 DB::commit(); 63 DB::commit();
64 }catch (\Exception $e){ 64 }catch (\Exception $e){
65 DB::rollBack(); 65 DB::rollBack();
66 $this->fail('添加失败'); 66 $this->fail('添加失败');
67 } 67 }
  68 + //TODO::通知网站更新
  69 + $data = [
  70 + 'project_id'=>$this->user['project_id'],
  71 + 'type'=>RouteMap::SOURCE_NEWS,
  72 + 'route'=>$this->param['url'],
  73 + ];
  74 + updateNotify($this->user['domain'],$data);
68 return $this->success(); 75 return $this->success();
69 } 76 }
70 77
@@ -80,14 +87,20 @@ class NewsLogic extends BaseLogic @@ -80,14 +87,20 @@ class NewsLogic extends BaseLogic
80 DB::beginTransaction(); 87 DB::beginTransaction();
81 try { 88 try {
82 //设置路由 89 //设置路由
83 - RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); 90 + $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
84 $this->edit($this->param,['id'=>$this->param['id']]); 91 $this->edit($this->param,['id'=>$this->param['id']]);
85 DB::commit(); 92 DB::commit();
86 }catch (\exception $e){ 93 }catch (\exception $e){
87 DB::rollBack(); 94 DB::rollBack();
88 $this->fail('参数错误或其他服务器原因,编辑失败'); 95 $this->fail('参数错误或其他服务器原因,编辑失败');
89 } 96 }
90 - //TODO::写入日志 97 + //TODO::通知网站更新
  98 + $data = [
  99 + 'project_id'=>$this->user['project_id'],
  100 + 'type'=>RouteMap::SOURCE_NEWS,
  101 + 'route'=>$this->param['url'],
  102 + ];
  103 + updateNotify($this->user['domain'],$data);
91 return $this->success(); 104 return $this->success();
92 } 105 }
93 106
@@ -64,13 +64,19 @@ class CategoryLogic extends BaseLogic @@ -64,13 +64,19 @@ class CategoryLogic extends BaseLogic
64 try { 64 try {
65 $res = parent::save($param); 65 $res = parent::save($param);
66 //路由映射 66 //路由映射
67 - RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_CATE, $res['id'], $this->user['project_id']); 67 + $route = RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_CATE, $res['id'], $this->user['project_id']);
68 DB::commit(); 68 DB::commit();
69 } catch (\Exception $e){ 69 } catch (\Exception $e){
70 DB::rollBack(); 70 DB::rollBack();
71 errorLog('产品分类保存失败', $param, $e); 71 errorLog('产品分类保存失败', $param, $e);
72 $this->fail('保存失败'); 72 $this->fail('保存失败');
73 } 73 }
  74 + $data = [
  75 + 'project_id'=>$this->user['project_id'],
  76 + 'type'=>RouteMap::SOURCE_PRODUCT,
  77 + 'route'=>$route,
  78 + ];
  79 + updateNotify($this->user['domain'],$data);
74 return $this->success(); 80 return $this->success();
75 } 81 }
76 82
@@ -82,13 +82,19 @@ class ProductLogic extends BaseLogic @@ -82,13 +82,19 @@ class ProductLogic extends BaseLogic
82 //关联关键词 82 //关联关键词
83 KeywordRelated::saveRelated($res['id'], $data['keyword_id']); 83 KeywordRelated::saveRelated($res['id'], $data['keyword_id']);
84 //路由映射 84 //路由映射
85 - RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']); 85 + $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']);
86 DB::commit(); 86 DB::commit();
87 }catch (\Exception $e){ 87 }catch (\Exception $e){
88 DB::rollBack(); 88 DB::rollBack();
89 errorLog('产品保存失败', $param, $e); 89 errorLog('产品保存失败', $param, $e);
90 $this->fail('保存失败'); 90 $this->fail('保存失败');
91 } 91 }
  92 + $data = [
  93 + 'project_id'=>$this->user['project_id'],
  94 + 'type'=>RouteMap::SOURCE_PRODUCT,
  95 + 'route'=>$param['route'],
  96 + ];
  97 + updateNotify($this->user['domain'],$data);
92 return $this->success(); 98 return $this->success();
93 } 99 }
94 100
  1 +<?php
  2 +/**
  3 + * @remark :通知更新
  4 + * @name :UpdateNotify.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/7/31 15:10
  8 + */
  9 +
  10 +namespace App\Models;
  11 +
  12 +class UpdateNotify extends Base
  13 +{
  14 + protected $table = 'gl_update_notify';
  15 +}