作者 lyh

gx

@@ -12,7 +12,6 @@ namespace App\Http\Controllers\Aside\Template; @@ -12,7 +12,6 @@ namespace App\Http\Controllers\Aside\Template;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Http\Logic\Aside\Template\ReplaceHtmlLogic; 14 use App\Http\Logic\Aside\Template\ReplaceHtmlLogic;
15 -use App\Models\CustomModule\CustomModule;  
16 use App\Models\Template\TemplateReplaceHtml; 15 use App\Models\Template\TemplateReplaceHtml;
17 use App\Models\Template\TemplateReplaceHtmlLog; 16 use App\Models\Template\TemplateReplaceHtmlLog;
18 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
@@ -67,21 +66,16 @@ class ReplaceHtmlController extends BaseController @@ -67,21 +66,16 @@ class ReplaceHtmlController extends BaseController
67 * @time :2024/5/8 10:28 66 * @time :2024/5/8 10:28
68 */ 67 */
69 public function replaceTemplateLog(TemplateReplaceHtml $replaceModel){ 68 public function replaceTemplateLog(TemplateReplaceHtml $replaceModel){
70 - $this->request->validate([  
71 - 'project_id'=>'required',  
72 - ],[  
73 - 'project_id.required' => 'project_id不能为空',  
74 - ]);  
75 - ProjectServer::useProject($this->param['project_id']);  
76 $lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order); 69 $lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order);
77 if(!empty($lists) && !empty($lists['list'])){ 70 if(!empty($lists) && !empty($lists['list'])){
78 - $templateLogModel = new TemplateReplaceHtmlLog();  
79 foreach ($lists['list'] as $k => $v){ 71 foreach ($lists['list'] as $k => $v){
  72 + ProjectServer::useProject($v['project_id']);
  73 + $templateLogModel = new TemplateReplaceHtmlLog();
80 $v['sub'] = $templateLogModel->list(['replace_id'=>$v['id']]); 74 $v['sub'] = $templateLogModel->list(['replace_id'=>$v['id']]);
81 $lists['list'][$k] = $v; 75 $lists['list'][$k] = $v;
  76 + DB::disconnect('custom_mysql');
82 } 77 }
83 } 78 }
84 - DB::disconnect('custom_mysql');  
85 $this->response('success',Code::SUCCESS,$lists); 79 $this->response('success',Code::SUCCESS,$lists);
86 } 80 }
87 81
@@ -66,7 +66,7 @@ class ReplaceHtmlLogic extends BaseLogic @@ -66,7 +66,7 @@ class ReplaceHtmlLogic extends BaseLogic
66 * @time :2024/5/7 15:52 66 * @time :2024/5/7 15:52
67 */ 67 */
68 public function replaceTemplateMainHtml(){ 68 public function replaceTemplateMainHtml(){
69 - ProjectServer::useProject($this->param['project_id']); 69 +
70 $data = $this->sourceTypeInfo(); 70 $data = $this->sourceTypeInfo();
71 $typeInfo = $data[$this->param['name']]; 71 $typeInfo = $data[$this->param['name']];
72 if(!isset($typeInfo)){ 72 if(!isset($typeInfo)){
@@ -76,8 +76,9 @@ class ReplaceHtmlLogic extends BaseLogic @@ -76,8 +76,9 @@ class ReplaceHtmlLogic extends BaseLogic
76 //TODO::生成一条任务记录 76 //TODO::生成一条任务记录
77 $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id); 77 $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id);
78 //查询当前类型所有装修的记录 78 //查询当前类型所有装修的记录
  79 + $bTemplateModel = new BTemplate();
79 $condition = ['source'=>$typeInfo['type'],'is_custom'=>$typeInfo['is_custom'],'is_list'=>$typeInfo['is_list'], 'template_id'=>$template_id]; 80 $condition = ['source'=>$typeInfo['type'],'is_custom'=>$typeInfo['is_custom'],'is_list'=>$typeInfo['is_list'], 'template_id'=>$template_id];
80 - $list = $this->model->list($condition); 81 + $list = $bTemplateModel->list($condition);
81 foreach ($list as $v){ 82 foreach ($list as $v){
82 if($v['type'] == 0){ 83 if($v['type'] == 0){
83 $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']); 84 $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
@@ -88,7 +89,6 @@ class ReplaceHtmlLogic extends BaseLogic @@ -88,7 +89,6 @@ class ReplaceHtmlLogic extends BaseLogic
88 } 89 }
89 $this->saveReplaceHtmlLog($replaceId,$v['id']); 90 $this->saveReplaceHtmlLog($replaceId,$v['id']);
90 } 91 }
91 - DB::disconnect('custom_mysql');  
92 return $this->success(); 92 return $this->success();
93 } 93 }
94 94
@@ -120,13 +120,16 @@ class ReplaceHtmlLogic extends BaseLogic @@ -120,13 +120,16 @@ class ReplaceHtmlLogic extends BaseLogic
120 * @time :2024/5/8 9:37 120 * @time :2024/5/8 9:37
121 */ 121 */
122 public function saveReplaceHtmlLog($replace_id,$replace_template_id){ 122 public function saveReplaceHtmlLog($replace_id,$replace_template_id){
  123 + ProjectServer::useProject($this->param['project_id']);
123 $logData = [ 124 $logData = [
124 'replace_id'=>$replace_id, 125 'replace_id'=>$replace_id,
125 'replace_template_id'=>$replace_template_id, 126 'replace_template_id'=>$replace_template_id,
126 'uid'=>$this->user['manager_id'], 127 'uid'=>$this->user['manager_id'],
127 ]; 128 ];
128 $replaceHtmlModel = new TemplateReplaceHtmlLog(); 129 $replaceHtmlModel = new TemplateReplaceHtmlLog();
129 - return $replaceHtmlModel->add($logData); 130 + $save_id = $replaceHtmlModel->addReturnId($logData);
  131 + DB::disconnect('custom_mysql');
  132 + return $this->success($save_id);
130 } 133 }
131 134
132 /** 135 /**
@@ -137,12 +140,12 @@ class ReplaceHtmlLogic extends BaseLogic @@ -137,12 +140,12 @@ class ReplaceHtmlLogic extends BaseLogic
137 * @time :2024/5/8 10:35 140 * @time :2024/5/8 10:35
138 */ 141 */
139 public function reductionHtml(){ 142 public function reductionHtml(){
140 - ProjectServer::useProject($this->param['project_id']);  
141 $info = $this->model->read(['id'=>$this->param['id']]); 143 $info = $this->model->read(['id'=>$this->param['id']]);
142 if($info === false){ 144 if($info === false){
143 $this->fail('当前数据不存在'); 145 $this->fail('当前数据不存在');
144 } 146 }
145 $replaceId = $this->saveResultReplaceHtml($info); 147 $replaceId = $this->saveResultReplaceHtml($info);
  148 + ProjectServer::useProject($this->param['project_id']);
146 $replaceLogModel = new TemplateReplaceHtmlLog(); 149 $replaceLogModel = new TemplateReplaceHtmlLog();
147 $logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]); 150 $logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]);
148 $replaceArr = []; 151 $replaceArr = [];
@@ -149,7 +149,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -149,7 +149,7 @@ class CustomModuleContentLogic extends BaseLogic
149 * @time :2023/12/7 15:04 149 * @time :2023/12/7 15:04
150 */ 150 */
151 public function contentAdd(){ 151 public function contentAdd(){
152 - try { 152 +// try {
153 $this->param['sort'] = $this->setNewsSort(); 153 $this->param['sort'] = $this->setNewsSort();
154 $id = $this->model->addReturnId($this->param); 154 $id = $this->model->addReturnId($this->param);
155 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE, 155 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE,
@@ -157,9 +157,9 @@ class CustomModuleContentLogic extends BaseLogic @@ -157,9 +157,9 @@ class CustomModuleContentLogic extends BaseLogic
157 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route); 157 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
158 $this->curlDelRoute(['new_route'=>$route]); 158 $this->curlDelRoute(['new_route'=>$route]);
159 $this->edit(['route' => $route], ['id' => $id]); 159 $this->edit(['route' => $route], ['id' => $id]);
160 - }catch (\Exception $e){  
161 - $this->fail('系统错误,请联系管理员');  
162 - } 160 +// }catch (\Exception $e){
  161 +// $this->fail('系统错误,请联系管理员');
  162 +// }
163 return $id; 163 return $id;
164 } 164 }
165 165
@@ -14,9 +14,6 @@ use App\Models\Base; @@ -14,9 +14,6 @@ use App\Models\Base;
14 class TemplateReplaceHtml extends Base 14 class TemplateReplaceHtml extends Base
15 { 15 {
16 protected $table = 'gl_replace_html'; 16 protected $table = 'gl_replace_html';
17 - //连接数据库  
18 - protected $connection = 'custom_mysql';  
19 -  
20 /** 17 /**
21 * @remark :默认类型 18 * @remark :默认类型
22 * @name :sourceType 19 * @name :sourceType