ATemplateLogic.php
2.6 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
<?php
namespace App\Http\Logic\Aside\Template;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Template\ATemplate;
use App\Models\Template\BSetting;
class ATemplateLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new ATemplate();
$this->param = $this->requestAll;
}
/**
* @remark :公共模块模板
* @name :aTemplateList
* @author :lyh
* @method :post
* @time :2023/6/28 17:03
*/
public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
/**
* @remark :添加或编辑模块
* @name :aTemplateSave
* @author :lyh
* @method :post
* @time :2023/6/28 17:13
*/
public function aTemplateSave(){
//字符串截取
$this->param['head_html'] = characterTruncation($this->param['html']);
$this->param['main_html'] = characterTruncation($this->param['html'],2);
$this->param['footer_html'] = characterTruncation($this->param['html'],3);
if(isset($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :修改模块状态
* @name :aTemplateStatus
* @author :lyh
* @method :post
* @time :2023/6/28 17:15
*/
public function aTemplateStatus(){
$rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :逻辑删除模板数据
* @name :aTemplateDel
* @author :lyh
* @method :post
* @time :2023/6/28 17:17
*/
public function aTemplateDel(){
//查看当前模板是否有模板在使用
$BSettingModel = new BSetting();
$info = $BSettingModel->read(['template_id'=>$this->param['id']]);
if($info !== false){
$this->fail('当前模板有项目在使用,不允许删除');
}
$rs = $this->model->edit(['deleted_status'=>$this->param['deleted_status'],'deleted_at'=>date('Y-m-d H:i:s')],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}