ReplaceHtmlController.php
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* @remark :
* @name :ReplaceHtmlController.php
* @author :lyh
* @method :post
* @time :2024/5/8 10:02
*/
namespace App\Http\Controllers\Aside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Template\ReplaceHtmlLogic;
use App\Models\Template\TemplateReplaceHtml;
use App\Models\Template\TemplateReplaceHtmlLog;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class ReplaceHtmlController extends BaseController
{
/**
* @remark :替换同一种类型的html代码
* @name :replaceTemplateMainHtml
* @author :lyh
* @method :post
* @time :2024/5/7 14:39
*/
public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){
$this->request->validate([
'old_html'=>'required',
'html'=>'required',
'type'=>'required',
'is_list'=>'required',
'is_custom'=>'required',
'project_id'=>'required',
],[
'old_html.required' => '需替换的html不能为空',
'html.required' => 'html不能为空',
'type.required' => '类型type不能为空',
'is_custom.required' => '类型is_custom不能为空',
'is_list.required' => '类型is_list不能为空',
'project_id.required' => 'project_id不能为空',
]);
$logic->replaceHtml();
$this->response('success');
}
/**
* @remark :替换的记录
* @name :replaceTemplateLog
* @author :lyh
* @method :post
* @time :2024/5/8 10:28
*/
public function replaceTemplateLog(TemplateReplaceHtml $replaceModel){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$templateLogModel = new TemplateReplaceHtmlLog();
foreach ($lists['list'] as $k => $v){
$v['sub'] = $templateLogModel->list(['replace_id'=>$v['id']]);
$lists['list'][$k] = $v;
}
}
DB::disconnect('custom_mysql');
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :还原
* @name :reductionHtml
* @author :lyh
* @method :post
* @time :2024/5/8 10:27
*/
public function reductionHtml(ReplaceHtmlLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$logic->reductionHtml();
$this->response('success');
}
}