作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -9,6 +9,17 @@ @@ -9,6 +9,17 @@
9 9
10 namespace App\Console\Commands\ReplaceHtml; 10 namespace App\Console\Commands\ReplaceHtml;
11 11
  12 +use App\Models\Blog\Blog;
  13 +use App\Models\Blog\BlogCategory;
  14 +use App\Models\CustomModule\CustomModule;
  15 +use App\Models\CustomModule\CustomModuleCategory;
  16 +use App\Models\CustomModule\CustomModuleContent;
  17 +use App\Models\News\News;
  18 +use App\Models\News\NewsCategory;
  19 +use App\Models\Product\Category;
  20 +use App\Models\Product\Product;
  21 +use App\Models\RouteMap\RouteMap;
  22 +use App\Models\Template\BCustomTemplate;
12 use App\Models\Template\BTemplate; 23 use App\Models\Template\BTemplate;
13 use App\Models\Template\TemplateReplaceHtmlLog; 24 use App\Models\Template\TemplateReplaceHtmlLog;
14 use App\Services\ProjectServer; 25 use App\Services\ProjectServer;
@@ -52,12 +63,16 @@ class ReplaceHtml extends Command @@ -52,12 +63,16 @@ class ReplaceHtml extends Command
52 $replaceHtmlModel = new TemplateReplaceHtml(); 63 $replaceHtmlModel = new TemplateReplaceHtml();
53 $replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]); 64 $replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]);
54 if(!empty($replaceHtmlList)){ 65 if(!empty($replaceHtmlList)){
55 - foreach ($replaceHtmlList as $k => $v){ 66 + foreach ($replaceHtmlList as $v){
56 ProjectServer::useProject($v['project_id']); 67 ProjectServer::useProject($v['project_id']);
57 echo '开始,任务id:'.$v['id'].PHP_EOL; 68 echo '开始,任务id:'.$v['id'].PHP_EOL;
58 - $this->createReplaceHtmlLog($v); 69 + if($v['source'] == 9){//单页面
  70 + $count = $this->createReplacePageHtmlLog($v);
  71 + }else{
  72 + $count = $this->createReplaceHtmlLog($v);
  73 + }
59 //修改当前主任务状态为待执行 74 //修改当前主任务状态为待执行
60 - $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START],['id'=>$v['id']]); 75 + $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START,'total_num'=>$count],['id'=>$v['id']]);
61 echo '结束'.PHP_EOL; 76 echo '结束'.PHP_EOL;
62 DB::disconnect('custom_mysql'); 77 DB::disconnect('custom_mysql');
63 } 78 }
@@ -68,31 +83,28 @@ class ReplaceHtml extends Command @@ -68,31 +83,28 @@ class ReplaceHtml extends Command
68 } 83 }
69 84
70 /** 85 /**
71 - * @remark :生成子任务  
72 - * @name :createReplaceHtmlLog 86 + * @remark :生成单页面记录
  87 + * @name :createReplacePageHtmlLog
73 * @author :lyh 88 * @author :lyh
74 * @method :post 89 * @method :post
75 - * @time :2024/5/10 17:26 90 + * @time :2024/5/13 11:40
76 */ 91 */
77 - public function createReplaceHtmlLog($info){  
78 - //获取当前页面所有数据 92 + public function createReplacePageHtmlLog($info){
79 $saveData = []; 93 $saveData = [];
80 - $bTemplateModel = new BTemplate();  
81 - $condition = ['source'=>$info['source'],'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];  
82 - $bTemplateList = $bTemplateModel->list($condition,'id',['id','source_id']);  
83 - foreach ($bTemplateList as $v){ 94 + $customTemplateModel = new BCustomTemplate();
  95 + $list = $customTemplateModel->list(['status'=>BCustomTemplate::STATUS_ACTIVE]);
  96 + foreach ($list as $v){
84 $saveData[] = [ 97 $saveData[] = [
85 'replace_id'=>$info['id'], 98 'replace_id'=>$info['id'],
86 'project_id'=>$info['project_id'], 99 'project_id'=>$info['project_id'],
87 'status'=>0, 100 'status'=>0,
88 'old_html'=>$info['old_html'], 101 'old_html'=>$info['old_html'],
89 'html'=>$info['html'], 102 'html'=>$info['html'],
90 - 'source'=>$info['source'],  
91 - 'source_id'=>$info['source'] == 1 ? 0 : $v['source_id'],  
92 - 'is_custom'=>$info['is_custom'],  
93 - 'is_list'=>$info['is_list'], 103 + 'source'=>9,
  104 + 'source_id'=>$v['id'],
94 'is_rollback'=>$info['is_rollback'], 105 'is_rollback'=>$info['is_rollback'],
95 'template_id'=>$info['template_id'], 106 'template_id'=>$info['template_id'],
  107 + 'name'=>$v['name'],
96 'created_at'=>date('Y-m-d H:i:s'), 108 'created_at'=>date('Y-m-d H:i:s'),
97 'updated_at'=>date('Y-m-d H:i:s') 109 'updated_at'=>date('Y-m-d H:i:s')
98 ]; 110 ];
@@ -101,8 +113,214 @@ class ReplaceHtml extends Command @@ -101,8 +113,214 @@ class ReplaceHtml extends Command
101 $templateHtmlLogModel = new TemplateReplaceHtmlLog(); 113 $templateHtmlLogModel = new TemplateReplaceHtmlLog();
102 $templateHtmlLogModel->insert($saveData); 114 $templateHtmlLogModel->insert($saveData);
103 } 115 }
104 - return true; 116 + return count($saveData);
  117 + }
  118 +
  119 + /**
  120 + * @remark :生成子任务
  121 + * @name :createReplaceHtmlLog
  122 + * @author :lyh
  123 + * @method :post
  124 + * @time :2024/5/10 17:26
  125 + */
  126 + public function createReplaceHtmlLog($info){
  127 + $bTemplateModel = new BTemplate();
  128 + $condition = ['is_custom'=>$info['is_custom'], 'is_list'=>$info['is_list'], 'template_id'=>$info['template_id']];
  129 + if($info['source'] != 0){
  130 + $condition['source'] = $info['source'];
  131 + }
  132 + if($info['template_id'] != 0){
  133 + $condition['main_html'] = ['like','%'.trim($info['old_html']).'%'];
  134 + }else{
  135 + $condition['html'] = ['like','%'.trim($info['old_html']).'%'];
  136 + }
  137 + $bTemplateList = $bTemplateModel->list($condition);
  138 + $saveData = [];
  139 + foreach ($bTemplateList as $v){
  140 + $source_id = $v['source'] == 1 ? 0 : $v['source_id'];
  141 + $name = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']);
  142 + $saveData[] = $this->saveData($info,$v,$source_id,$name);
  143 + }
  144 + if(!empty($saveData)){
  145 + $templateHtmlLogModel = new TemplateReplaceHtmlLog();
  146 + $templateHtmlLogModel->insert($saveData);
  147 + }
  148 + return count($saveData);
  149 + }
  150 +
  151 + /**
  152 + * @remark :组装数据
  153 + * @name :saveData
  154 + * @author :lyh
  155 + * @method :post
  156 + * @time :2024/5/13 11:29
  157 + */
  158 + public function saveData($info,$v,$source_id,$name){
  159 + return [
  160 + 'replace_id'=>$info['id'],
  161 + 'project_id'=>$info['project_id'],
  162 + 'status'=>0,
  163 + 'old_html'=>$info['old_html'],
  164 + 'html'=>$info['html'],
  165 + 'source'=>$v['source'],
  166 + 'source_id'=>$source_id,
  167 + 'is_custom'=>$v['is_custom'],
  168 + 'is_list'=>$v['is_list'],
  169 + 'is_rollback'=>$info['is_rollback'],
  170 + 'template_id'=>$info['template_id'],
  171 + 'source_name'=>$name,
  172 + 'created_at'=>date('Y-m-d H:i:s'),
  173 + 'updated_at'=>date('Y-m-d H:i:s')
  174 + ];
  175 + }
  176 +
  177 + /**
  178 + * @remark :生成子任务获取对应数据id名称
  179 + * @name :getSourceName
  180 + * @author :lyh
  181 + * @method :post
  182 + * @time :2024/5/13 10:47
  183 + */
  184 + public function getSourceName($source,$source_id,$is_list,$is_custom){
  185 + if($is_custom == 1){//扩展模块
  186 + return $this->getCustomName($source,$source_id,$is_list);
  187 + }
  188 + if($source == BTemplate::SOURCE_HOME){
  189 + return '';
  190 + }elseif ($source == BTemplate::SOURCE_PRODUCT){
  191 + return $this->getProductName($source_id,$is_list);
  192 + }elseif ($source == BTemplate::SOURCE_BLOG){
  193 + return $this->getBlogName($source_id,$is_list);
  194 + }elseif ($source == BTemplate::SOURCE_NEWS){
  195 + return $this->getNewsName($source_id,$is_list);
  196 + }else {//单页面管理
  197 + return $this->getPageName($source_id);
  198 + }
  199 + return false;
  200 + }
  201 +
  202 + /**
  203 + * @remark :获取单页面名称
  204 + * @name :getPageName
  205 + * @author :lyh
  206 + * @method :post
  207 + * @time :2024/5/13 11:10
  208 + */
  209 + public function getPageName($source_id){
  210 + $customTemplateModel = new BCustomTemplate();
  211 + $info = $customTemplateModel->read(['id'=>$source_id]);
  212 + if($info === false){
  213 + return false;
  214 + }
  215 + return $info['name'];
105 } 216 }
106 217
  218 + /**
  219 + * @remark :获取新闻名称
  220 + * @name :getNewsName
  221 + * @author :lyh
  222 + * @method :post
  223 + * @time :2024/5/13 11:07
  224 + */
  225 + public function getNewsName($source_id,$is_list){
  226 + if($is_list == BTemplate::IS_LIST){
  227 + $cateModel = new NewsCategory();
  228 + $cateInfo = $cateModel->read(['id'=>$source_id]);
  229 + if($cateInfo === false){
  230 + return false;
  231 + }
  232 + $name = $cateInfo['name'];
  233 + }else{
  234 + $newsModel = new News();
  235 + $newsInfo = $newsModel->read(['id'=>$source_id]);
  236 + if($newsInfo === false){
  237 + return false;
  238 + }
  239 + $name = $newsInfo['name'];
  240 + }
  241 + return $name;
  242 + }
107 243
  244 + /**
  245 + * @remark :获取blog名称
  246 + * @name :getBlogName
  247 + * @author :lyh
  248 + * @method :post
  249 + * @time :2024/5/13 11:05
  250 + */
  251 + public function getBlogName($source_id,$is_list){
  252 + if($is_list == BTemplate::IS_LIST){
  253 + $cateModel = new BlogCategory();
  254 + $cateInfo = $cateModel->read(['id'=>$source_id]);
  255 + if($cateInfo === false){
  256 + return false;
  257 + }
  258 + $name = $cateInfo['name'];
  259 + }else{
  260 + $blogModel = new Blog();
  261 + $productInfo = $blogModel->read(['id'=>$source_id]);
  262 + if($productInfo === false){
  263 + return false;
  264 + }
  265 + $name = $productInfo['name'];
  266 + }
  267 + return $name;
  268 + }
  269 +
  270 + /**
  271 + * @remark :获取产品名称
  272 + * @name :getProductName
  273 + * @author :lyh
  274 + * @method :post
  275 + * @time :2024/5/13 11:00
  276 + */
  277 + public function getProductName($source_id,$is_list){
  278 + if($is_list == BTemplate::IS_LIST){
  279 + $cateModel = new Category();
  280 + $cateInfo = $cateModel->read(['id'=>$source_id]);
  281 + if($cateInfo === false){
  282 + return false;
  283 + }
  284 + $name = $cateInfo['title'];
  285 + }else{
  286 + $productModel = new Product();
  287 + $productInfo = $productModel->read(['id'=>$source_id]);
  288 + if($productInfo === false){
  289 + return false;
  290 + }
  291 + $name = $productInfo['title'];
  292 + }
  293 + return $name;
  294 + }
  295 +
  296 + /**
  297 + * @remark :获取扩展模块名称
  298 + * @name :getCustomName
  299 + * @author :lyh
  300 + * @method :post
  301 + * @time :2024/5/13 10:55
  302 + */
  303 + public function getCustomName($source,$source_id,$is_list){
  304 + $customModuleModel = new CustomModule();
  305 + $moduleInfo = $customModuleModel->read(['id'=>$source]);
  306 + if($moduleInfo === false){
  307 + return false;
  308 + }
  309 + if($is_list == BTemplate::IS_LIST){
  310 + $categoryModel = new CustomModuleCategory();
  311 + $cateInfo = $categoryModel->read(['id'=>$source_id],['id','name']);
  312 + if($cateInfo === false){
  313 + return false;
  314 + }
  315 + $name = $cateInfo['name'];
  316 + }else{
  317 + $contentModel = new CustomModuleContent();
  318 + $contentInfo = $contentModel->read(['id'=>$source_id],['id','name']);
  319 + if($contentInfo === false){
  320 + return false;
  321 + }
  322 + $name = $contentInfo['name'];
  323 + }
  324 + return $name;
  325 + }
108 } 326 }
@@ -640,6 +640,21 @@ function characterTruncation($string,$pattern){ @@ -640,6 +640,21 @@ function characterTruncation($string,$pattern){
640 return ''; 640 return '';
641 } 641 }
642 } 642 }
  643 +
  644 +/**
  645 + * @remark :字符串截取
  646 + * @name :characterTruncationStr
  647 + * @author :lyh
  648 + * @method :post
  649 + * @time :2024/5/14 16:24
  650 + */
  651 +function characterTruncationStr($string,$startStr,$endStr){
  652 + $start = strpos($string, $startStr);
  653 + $end = strpos($string, $endStr) + strlen($endStr);
  654 + return substr($string, $start, $end - $start);
  655 +}
  656 +
  657 +
643 if (!function_exists('getAutoLoginCode')) { 658 if (!function_exists('getAutoLoginCode')) {
644 /** 659 /**
645 * @remark :自动登录加密 660 * @remark :自动登录加密
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TutorialController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/13 17:36
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Com;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Tutorial\TutorialLogic;
  15 +use App\Models\Tutorial\Tutorial;
  16 +
  17 +/**
  18 + * @remark :oa教程
  19 + * @name :TutorialController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/5/13 17:36
  23 + */
  24 +class TutorialController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :oa列表
  28 + * @name :lists
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2024/5/13 17:36
  32 + */
  33 + public function lists(Tutorial $tutorial){
  34 + $data = $tutorial->lists($this->map,$this->page,$this->row,$this->order = ['sort','id']);
  35 + $this->response('success',Code::SUCCESS,$data);
  36 + }
  37 +
  38 + /**
  39 + * @remark :保存数据
  40 + * @name :save
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2024/5/13 17:39
  44 + */
  45 + public function save(TutorialLogic $logic){
  46 + $this->request->validate([
  47 + 'name'=>'required',
  48 + 'url'=>'required',
  49 + ], [
  50 + 'name.required' => '标识name不为空',
  51 + 'url.required' => '文件链接url不为空',
  52 + ]);
  53 + $data = $logic->saveTutorial();
  54 + $this->response('success',Code::SUCCESS,$data);
  55 + }
  56 +
  57 + /**
  58 + * @remark :排序
  59 + * @name :sort
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2024/5/14 9:39
  63 + */
  64 + public function sort(TutorialLogic $logic){
  65 + $this->request->validate([
  66 + 'id'=>'required',
  67 + 'sort'=>'required',
  68 + ], [
  69 + 'id.required' => '标识id不为空',
  70 + 'sort.required' => '排序sort不为空',
  71 + ]);
  72 + $data = $logic->sortTutorial();
  73 + $this->response('success',Code::SUCCESS,$data);
  74 + }
  75 +
  76 + /**
  77 + * @remark :修改状态
  78 + * @name :status
  79 + * @author :lyh
  80 + * @method :post
  81 + * @time :2024/5/13 17:40
  82 + */
  83 + public function status(TutorialLogic $logic){
  84 + $this->request->validate([
  85 + 'id'=>'required',
  86 + 'status'=>'required',
  87 + ], [
  88 + 'id.required' => '标识id不为空',
  89 + 'status.required' => '标识status不为空',
  90 + ]);
  91 + $data = $logic->statusTutorial();
  92 + $this->response('success',Code::SUCCESS,$data);
  93 + }
  94 +
  95 + /**
  96 + * @remark :删除数据
  97 + * @name :del
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2024/5/13 17:40
  101 + */
  102 + public function del(TutorialLogic $logic){
  103 + $this->request->validate([
  104 + 'id'=>'required',
  105 + ], [
  106 + 'id.required' => '标识id不为空',
  107 + ]);
  108 + $data = $logic->delTutorial();
  109 + $this->response('success',Code::SUCCESS,$data);
  110 + }
  111 +}
@@ -85,7 +85,7 @@ class ReplaceHtmlController extends BaseController @@ -85,7 +85,7 @@ class ReplaceHtmlController extends BaseController
85 * @method :post 85 * @method :post
86 * @time :2024/5/11 11:09 86 * @time :2024/5/11 11:09
87 */ 87 */
88 - public function replaceTemplateSonLog(TemplateReplaceHtmlLog $replaceHtmlLog){ 88 + public function replaceTemplateSonLog(TemplateReplaceHtmlLog $replaceHtmlLog,ReplaceHtmlLogic $logic){
89 $this->request->validate([ 89 $this->request->validate([
90 'replace_id'=>'required', 90 'replace_id'=>'required',
91 ],[ 91 ],[
@@ -96,7 +96,7 @@ class ReplaceHtmlController extends BaseController @@ -96,7 +96,7 @@ class ReplaceHtmlController extends BaseController
96 } 96 }
97 97
98 /** 98 /**
99 - * @remark :还原 99 + * @remark :主任务还原
100 * @name :reductionHtml 100 * @name :reductionHtml
101 * @author :lyh 101 * @author :lyh
102 * @method :post 102 * @method :post
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TutorialController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/14 9:59
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Tutorial\Tutorial;
  15 +
  16 +/**
  17 + * @remark :oa教程
  18 + * @name :TutorialController
  19 + * @author :lyh
  20 + * @method :post
  21 + * @time :2024/5/14 10:00
  22 + */
  23 +class TutorialController extends BaseController
  24 +{
  25 + /**
  26 + * @remark :oa列表
  27 + * @name :lists
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2024/5/14 10:00
  31 + */
  32 + public function lists(Tutorial $tutorial){
  33 + $this->map['status'] = 0;
  34 + $lists = $tutorial->lists($this->map,$this->page,$this->row,$this->order);
  35 + if(!empty($lists) && !empty($lists['list'])){
  36 + foreach ($lists['list'] as $k => $v){
  37 + $v['download_url'] = url('b/file_manager_downLoad?path='.$v['url']);
  38 + $lists['list'][$k] = $v;
  39 + }
  40 + }
  41 + $this->response('success',Code::SUCCESS,$lists);
  42 + }
  43 +}
@@ -34,7 +34,7 @@ class BTemplateLogController extends BaseController @@ -34,7 +34,7 @@ class BTemplateLogController extends BaseController
34 */ 34 */
35 public function lists(BTemplateLog $bTemplateLog){ 35 public function lists(BTemplateLog $bTemplateLog){
36 // unset($this->map['template_id']); 36 // unset($this->map['template_id']);
37 - $this->map['project_id'] = $this->user['project_id']; 37 +
38 $this->map['source'] = 1; 38 $this->map['source'] = 1;
39 $this->map['is_custom'] = 0; 39 $this->map['is_custom'] = 0;
40 $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']); 40 $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
@@ -53,6 +53,38 @@ class BTemplateLogController extends BaseController @@ -53,6 +53,38 @@ class BTemplateLogController extends BaseController
53 } 53 }
54 54
55 /** 55 /**
  56 + * @remark :根据页面数据ID获取当前数据的装修记录
  57 + * @name :getSourceLogLists
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2024/5/15 9:12
  61 + */
  62 + public function getSourceLogLists(BTemplateLog $bTemplateLog){
  63 + $this->request->validate([
  64 + 'source'=>['required'],
  65 + 'source_id'=>['required'],
  66 + ],[
  67 + 'source'=>'对应数据类型不能为空',
  68 + 'source_id.required' => '当前数据ID不能为空',
  69 + ]);
  70 + $is_custom = $this->param['is_custom'] ?? 0;
  71 + $this->map = ['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'is_custom'=>$is_custom,'project_id'=>$this->user['project_id']];
  72 + $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
  73 + if(!empty($lists['list'])){
  74 + $templateModel = new Template();
  75 + $userModel = new User();
  76 + foreach ($lists['list'] as $k => $v){
  77 + if(!empty($v['template_id'])){
  78 + $v['template_name'] = $templateModel->read(['id'=>$v['template_id']],['name'])['name'];
  79 + }
  80 + $v['operator_name'] = $userModel->getName($v['operator_id']);
  81 + $lists['list'][$k] = $v;
  82 + }
  83 + }
  84 + $this->response('success',Code::SUCCESS,$lists);
  85 + }
  86 +
  87 + /**
56 * @remark :获取数据详情 88 * @remark :获取数据详情
57 * @name :info 89 * @name :info
58 * @author :lyh 90 * @author :lyh
@@ -126,7 +126,6 @@ class ReplaceHtmlLogic extends BaseLogic @@ -126,7 +126,6 @@ class ReplaceHtmlLogic extends BaseLogic
126 $data = $this->sourceTypeInfo($this->param['project_id']); 126 $data = $this->sourceTypeInfo($this->param['project_id']);
127 $typeInfo = $data[$this->param['name']]; 127 $typeInfo = $data[$this->param['name']];
128 ProjectServer::useProject($this->param['project_id']); 128 ProjectServer::useProject($this->param['project_id']);
129 - $bTemplateModel = new BTemplate();  
130 if($typeInfo['source'] == 0){//所有页面 129 if($typeInfo['source'] == 0){//所有页面
131 $bSettingModel = new Setting(); 130 $bSettingModel = new Setting();
132 $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]); 131 $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
@@ -134,16 +133,11 @@ class ReplaceHtmlLogic extends BaseLogic @@ -134,16 +133,11 @@ class ReplaceHtmlLogic extends BaseLogic
134 $this->fail('请先选择模版'); 133 $this->fail('请先选择模版');
135 } 134 }
136 $template_id = $templateInfo['template_id']; 135 $template_id = $templateInfo['template_id'];
137 - $condition = ['template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];  
138 - $total_num = $bTemplateModel->formatQuery($condition)->count();  
139 }else{ 136 }else{
140 $template_id = $this->getTemplateId($typeInfo); 137 $template_id = $this->getTemplateId($typeInfo);
141 - $condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'], 'is_list'=>$typeInfo['is_list'],  
142 - 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];  
143 - $total_num = $bTemplateModel->formatQuery($condition)->count();  
144 } 138 }
145 DB::disconnect('custom_mysql'); 139 DB::disconnect('custom_mysql');
146 - $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num ?? 0); 140 + $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id);
147 return $this->success(['id'=>$replaceId]); 141 return $this->success(['id'=>$replaceId]);
148 } 142 }
149 143
@@ -154,7 +148,7 @@ class ReplaceHtmlLogic extends BaseLogic @@ -154,7 +148,7 @@ class ReplaceHtmlLogic extends BaseLogic
154 * @method :post 148 * @method :post
155 * @time :2024/5/8 9:23 149 * @time :2024/5/8 9:23
156 */ 150 */
157 - public function saveReplaceHtml($param,$typeInfo,$template_id,$total_num){ 151 + public function saveReplaceHtml($param,$typeInfo,$template_id){
158 $logData = [ 152 $logData = [
159 'source'=>$typeInfo['source'], 153 'source'=>$typeInfo['source'],
160 'is_custom'=>$typeInfo['is_custom'], 154 'is_custom'=>$typeInfo['is_custom'],
@@ -164,7 +158,7 @@ class ReplaceHtmlLogic extends BaseLogic @@ -164,7 +158,7 @@ class ReplaceHtmlLogic extends BaseLogic
164 'old_html'=>$param['old_html'], 158 'old_html'=>$param['old_html'],
165 'html'=>$param['html'], 159 'html'=>$param['html'],
166 'project_id'=>$param['project_id'], 160 'project_id'=>$param['project_id'],
167 - 'total_num'=>$total_num, 161 + 'total_num'=>0,
168 'operator_id'=>$this->manager['id'] 162 'operator_id'=>$this->manager['id']
169 ]; 163 ];
170 return $this->model->addReturnId($logData); 164 return $this->model->addReturnId($logData);
@@ -204,19 +198,19 @@ class ReplaceHtmlLogic extends BaseLogic @@ -204,19 +198,19 @@ class ReplaceHtmlLogic extends BaseLogic
204 * @method :post 198 * @method :post
205 * @time :2024/5/10 10:01 199 * @time :2024/5/10 10:01
206 */ 200 */
207 - public function saveResultReplaceHtml($info){ 201 + public function saveResultReplaceHtml($info,$status = 0,$num = 0){
208 $logData = [ 202 $logData = [
209 'source'=>$info['source'], 203 'source'=>$info['source'],
210 'is_custom'=>$info['is_custom'], 204 'is_custom'=>$info['is_custom'],
211 'is_list'=>$info['is_list'], 205 'is_list'=>$info['is_list'],
212 'template_id'=>$info['template_id'], 206 'template_id'=>$info['template_id'],
213 - 'status'=>$this->model::STATUS, 207 + 'status'=>$status != 0 ? $status : $this->model::STATUS,
214 'old_html'=>$info['html'], 208 'old_html'=>$info['html'],
215 'html'=>$info['old_html'], 209 'html'=>$info['old_html'],
216 'project_id'=>$info['project_id'], 210 'project_id'=>$info['project_id'],
217 'is_rollback'=>1, 211 'is_rollback'=>1,
218 'rollback_id'=>$info['id'], 212 'rollback_id'=>$info['id'],
219 - 'total_num'=>$info['total_num'], 213 + 'total_num'=>($num != 0) ? $num : $info['total_num'],
220 'operator_id'=>$this->manager['id'] 214 'operator_id'=>$this->manager['id']
221 ]; 215 ];
222 return $this->model->addReturnId($logData); 216 return $this->model->addReturnId($logData);
@@ -268,23 +262,48 @@ class ReplaceHtmlLogic extends BaseLogic @@ -268,23 +262,48 @@ class ReplaceHtmlLogic extends BaseLogic
268 * @time :2024/5/11 11:31 262 * @time :2024/5/11 11:31
269 */ 263 */
270 public function rollbackIdHtml(){ 264 public function rollbackIdHtml(){
271 - $replaceHtmlLogModel = new TemplateReplaceHtmlLog();  
272 - $info = $replaceHtmlLogModel->read(['id'=>$this->param['id']]);  
273 - ProjectServer::useProject($info['project_id']);  
274 - $bTemplateModel = new BTemplate();  
275 - $condition = ['source'=>$info['source'],'source_id'=>$info['source_id'],  
276 - 'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];  
277 - $old_html = $info['old_html'];  
278 - $html = $info['html'];  
279 - if($info['template_id'] == 0){  
280 - $bTemplateModel->formatQuery($condition)->update(['html' => DB::raw("REPLACE(html, '$old_html', '$html')")]);  
281 - }else{  
282 - $bTemplateModel->formatQuery($condition)->update(['main_html' => DB::raw("REPLACE(main_html, '$old_html', '$html')")]); 265 + if(is_array($this->param['id']) && isset($this->param['id'])){
  266 + $save_id = 0;
  267 + foreach ($this->param['id'] as $k => $id){
  268 + $replaceHtmlLogModel = new TemplateReplaceHtmlLog();
  269 + $logInfo = $replaceHtmlLogModel->read(['id'=>$id]);
  270 + //查询当前主任务
  271 + $replaceHtmlModel = new TemplateReplaceHtml();
  272 + $info = $replaceHtmlModel->read(['id'=>$logInfo['replace_id']]);
  273 + if($k == 0){
  274 + //生成一条已完成的主记录
  275 + $save_id = $this->saveResultReplaceHtml($info,TemplateReplaceHtml::STATUS_END,count($this->param['id']));
  276 + }
  277 + //生成一条子记录
  278 + $this->saveResultSonInfo($save_id,$logInfo);
  279 + }
283 } 280 }
284 - //修改当前数据为还原数据  
285 - $replaceHtmlLogModel->edit(['is_rollback'=>1],['id'=>$this->param['id']]);  
286 - DB::disconnect('custom_mysql');  
287 return $this->success(); 281 return $this->success();
288 } 282 }
289 283
  284 + /**
  285 + * @remark :生成一条还原子记录
  286 + * @name :saveResultSonInfo
  287 + * @author :lyh
  288 + * @method :post
  289 + * @time :2024/5/13 15:14
  290 + */
  291 + public function saveResultSonInfo($save_id,$logInfo){
  292 + $saveData = [
  293 + 'replace_id'=>$save_id,
  294 + 'project_id'=>$logInfo['project_id'],
  295 + 'status'=>TemplateReplaceHtmlLog::STATUS,
  296 + 'old_html'=>$logInfo['html'],
  297 + 'html'=>$logInfo['old_html'],
  298 + 'source'=>$logInfo['source'],
  299 + 'source_id'=>$logInfo['source_id'],
  300 + 'is_custom'=>$logInfo['is_custom'],
  301 + 'is_list'=>$logInfo['is_list'],
  302 + 'is_rollback'=>1,
  303 + 'template_id'=>$logInfo['template_id'],
  304 + 'source_name'=>$logInfo['source_name']
  305 + ];
  306 + $replaceHtmlLogModel = new TemplateReplaceHtmlLog();
  307 + return $replaceHtmlLogModel->addReturnId($saveData);
  308 + }
290 } 309 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TutorialLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/13 17:38
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Tutorial;
  11 +
  12 +use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Tutorial\Tutorial;
  14 +
  15 +class TutorialLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->model = new Tutorial();
  21 + $this->param = $this->requestAll;
  22 + }
  23 +
  24 + /**
  25 + * @remark :保存数据
  26 + * @name :saveTutorial
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2024/5/13 17:39
  30 + */
  31 + public function saveTutorial(){
  32 + if(isset($this->param['id']) && !empty($this->param['id'])){
  33 + $id = $this->param['id'];
  34 + $this->model->edit($this->param,['id'=>$id]);
  35 + }else{
  36 + $id = $this->model->addReturnId($this->param);
  37 + }
  38 + return $this->success(['id'=>$id]);
  39 + }
  40 +
  41 + /**
  42 + * @remark :修改状态
  43 + * @name :statusTutorial
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2024/5/13 17:42
  47 + */
  48 + public function statusTutorial(){
  49 + $rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
  50 + return $this->success($rs);
  51 + }
  52 +
  53 + /**
  54 + * @remark :修改状排序
  55 + * @name :statusTutorial
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2024/5/13 17:42
  59 + */
  60 + public function sortTutorial(){
  61 + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
  62 + return $this->success($rs);
  63 + }
  64 +
  65 +
  66 + /**
  67 + * @remark :删除数据
  68 + * @name :delTutorial
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2024/5/13 17:41
  72 + */
  73 + public function delTutorial(){
  74 + $rs = $this->model->del(['id'=>$this->param['id']]);
  75 + return $this->success($rs);
  76 + }
  77 +}
@@ -598,7 +598,7 @@ class BTemplateLogic extends BaseLogic @@ -598,7 +598,7 @@ class BTemplateLogic extends BaseLogic
598 */ 598 */
599 public function handleTemplateHtml($html){ 599 public function handleTemplateHtml($html){
600 //字符串截取 600 //字符串截取
601 - $param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); 601 + $param['main_html'] = characterTruncationStr($html,"<main","</main>");
602 $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 602 $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
603 return $this->success($param); 603 return $this->success($param);
604 } 604 }
@@ -646,6 +646,7 @@ class BTemplateLogic extends BaseLogic @@ -646,6 +646,7 @@ class BTemplateLogic extends BaseLogic
646 if($is_custom != BTemplate::IS_NO_CUSTOM){ 646 if($is_custom != BTemplate::IS_NO_CUSTOM){
647 return true; 647 return true;
648 } 648 }
  649 + $main_html = characterTruncationStr($html,"<main","</main>");
649 $data = [ 650 $data = [
650 'template_id'=>$template_id, 651 'template_id'=>$template_id,
651 'project_id'=>$this->user['project_id'], 652 'project_id'=>$this->user['project_id'],
@@ -656,7 +657,7 @@ class BTemplateLogic extends BaseLogic @@ -656,7 +657,7 @@ class BTemplateLogic extends BaseLogic
656 'is_list'=>$is_list, 657 'is_list'=>$is_list,
657 'source'=>$source, 658 'source'=>$source,
658 'source_id'=>$source_id, 659 'source_id'=>$source_id,
659 - 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'), 660 + 'main_html' => $main_html,
660 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'), 661 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
661 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), 662 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
662 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), 663 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
@@ -747,7 +748,7 @@ class BTemplateLogic extends BaseLogic @@ -747,7 +748,7 @@ class BTemplateLogic extends BaseLogic
747 public function handleSaveParam($param){ 748 public function handleSaveParam($param){
748 //字符串截取 749 //字符串截取
749 $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); 750 $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
750 - $param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); 751 + $param['main_html'] = characterTruncationStr($param['html'],"<main","</main>");
751 $param['footer_html'] = characterTruncation($param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'); 752 $param['footer_html'] = characterTruncation($param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s');
752 $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'); 753 $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
753 $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 754 $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
@@ -70,6 +70,9 @@ class CustomTemplateLogic extends BaseLogic @@ -70,6 +70,9 @@ class CustomTemplateLogic extends BaseLogic
70 $six_read = $this->param['six_read'] ?? 0;//5.0数据时,是否按6.0显示 70 $six_read = $this->param['six_read'] ?? 0;//5.0数据时,是否按6.0显示
71 if($is_upgrade == 0 || $six_read == 1) { 71 if($is_upgrade == 0 || $six_read == 1) {
72 $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); 72 $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
  73 + if($this->param['url'] == 'news' || $this->param['url'] == 'product' || $this->param['url'] == 'blog'){
  74 + $this->fail('不允许创建'.$this->param['url']);
  75 + }
73 } 76 }
74 $this->editCustomRoute($this->param['url']); 77 $this->editCustomRoute($this->param['url']);
75 $rs = $this->model->edit($this->param,['id'=>$id]); 78 $rs = $this->model->edit($this->param,['id'=>$id]);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Tutorial.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/13 17:34
  8 + */
  9 +
  10 +namespace App\Models\Tutorial;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :oa教程
  16 + * @name :Tutorial
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2024/5/13 17:34
  20 + */
  21 +class Tutorial extends Base
  22 +{
  23 + protected $table = 'gl_tutorial';
  24 +}
@@ -386,13 +386,22 @@ Route::middleware(['aloginauth'])->group(function () { @@ -386,13 +386,22 @@ Route::middleware(['aloginauth'])->group(function () {
386 Route::any('/pageType', [Aside\Template\ReplaceHtmlController::class, 'pageType'])->name('admin.replace_pageType'); 386 Route::any('/pageType', [Aside\Template\ReplaceHtmlController::class, 'pageType'])->name('admin.replace_pageType');
387 }); 387 });
388 388
389 - //可视化数据替换 389 + //v6更新日志
390 Route::prefix('v6_update')->group(function () { 390 Route::prefix('v6_update')->group(function () {
391 Route::any('/', [Aside\Com\V6UpdateLogController::class, 'lists'])->name('admin.v6_update'); 391 Route::any('/', [Aside\Com\V6UpdateLogController::class, 'lists'])->name('admin.v6_update');
392 Route::any('/save', [Aside\Com\V6UpdateLogController::class, 'save'])->name('admin.v6_update_save'); 392 Route::any('/save', [Aside\Com\V6UpdateLogController::class, 'save'])->name('admin.v6_update_save');
393 Route::any('/del', [Aside\Com\V6UpdateLogController::class, 'del'])->name('admin.v6_update_del'); 393 Route::any('/del', [Aside\Com\V6UpdateLogController::class, 'del'])->name('admin.v6_update_del');
394 }); 394 });
395 395
  396 + //oa教程
  397 + Route::prefix('tutorial')->group(function () {
  398 + Route::any('/', [Aside\Com\TutorialController::class, 'lists'])->name('admin.tutorial_lists');
  399 + Route::any('/save', [Aside\Com\TutorialController::class, 'save'])->name('admin.tutorial_save');
  400 + Route::any('/sort', [Aside\Com\TutorialController::class, 'sort'])->name('admin.tutorial_sort');
  401 + Route::any('/status', [Aside\Com\TutorialController::class, 'status'])->name('admin.tutorial_status');
  402 + Route::any('/del', [Aside\Com\TutorialController::class, 'del'])->name('admin.tutorial_del');
  403 + });
  404 +
396 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token'); 405 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token');
397 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken'); 406 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken');
398 }); 407 });
@@ -381,6 +381,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -381,6 +381,7 @@ Route::middleware(['bloginauth'])->group(function () {
381 Route::prefix('log')->group(function () { 381 Route::prefix('log')->group(function () {
382 //获取所有左侧模版 382 //获取所有左侧模版
383 Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'lists'])->name('template_log_lists'); 383 Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'lists'])->name('template_log_lists');
  384 + Route::any('/getSourceLogLists', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'getSourceLogLists'])->name('template_log_getSourceLogLists');
384 Route::any('/info', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'info'])->name('template_log_info'); 385 Route::any('/info', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'info'])->name('template_log_info');
385 Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'rollbackVersion'])->name('template_log_rollbackVersion'); 386 Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'rollbackVersion'])->name('template_log_rollbackVersion');
386 }); 387 });
@@ -530,6 +531,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -530,6 +531,10 @@ Route::middleware(['bloginauth'])->group(function () {
530 Route::any('/month', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'getMonth'])->name('month_report_getMonth'); 531 Route::any('/month', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'getMonth'])->name('month_report_getMonth');
531 Route::any('/read', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'monthReportInfo'])->name('month_report_read'); 532 Route::any('/read', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'monthReportInfo'])->name('month_report_read');
532 }); 533 });
  534 + //oa教程
  535 + Route::prefix('tutorial')->group(function () {
  536 + Route::any('/', [\App\Http\Controllers\Bside\BCom\TutorialController::class, 'lists'])->name('tutorial_lists');
  537 + });
533 }); 538 });
534 //无需登录验证的路由组 539 //无需登录验证的路由组
535 Route::group([], function () { 540 Route::group([], function () {