TemplateLabelLogic.php
1.9 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
<?php
/**
* @remark :
* @name :TemplateLabelLogic.php
* @author :lyh
* @method :post
* @time :2024/5/16 9:54
*/
namespace App\Http\Logic\Aside\Template;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Template\TemplateLabel;
/**
* @remark :模版标签
* @name :TemplateLabelLogic
* @author :lyh
* @method :post
* @time :2024/5/16 9:54
*/
class TemplateLabelLogic extends BaseLogic
{
/**
* 初始化数据
*/
public function __construct()
{
parent::__construct();
$this->model = new TemplateLabel();
$this->param = $this->requestAll;
}
/**
* @remark :保存标签
* @name :saveLabel
* @author :lyh
* @method :post
* @time :2024/5/16 9:55
*/
public function saveLabel(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$info = $this->model->read(['name'=>$this->param['name'],['template_id'=>$this->param['template_id']],'id'=>['!=',$id]],['id']);
if($info === false){
$this->model->edit($this->param,['id'=>$id]);
}
}else{
$info = $this->model->read(['name'=>$this->param['name'],['template_id'=>$this->param['template_id']]],['id']);
if($info === false){
$this->param['manager_id'] = $this->manager['id'];
$id = $this->model->addReturnId($this->param);
}else{
$id = $info['id'];
}
}
return $this->success(['id'=>$id]);
}
/**
* @remark :删除标签
* @name :delLabel
* @author :lyh
* @method :post
* @time :2024/5/16 10:03
*/
public function delLabel(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删除失败,请联系管理员');
}
return $this->success();
}
}