BlogExtendLogic.php
2.5 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
92
93
94
95
<?php
/**
* @remark :
* @name :NewsExtendLogic.php
* @author :lyh
* @method :post
* @time :2025/5/26 15:11
*/
namespace App\Http\Logic\Bside\Blog;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\News\BlogExtend;
use App\Models\Product\ExtendInfo;
class BlogExtendLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new BlogExtend();
$this->param = $this->requestAll;
}
/**
* @remark :列表页
* @name :list
* @author :lyh
* @method :post
* @time :2025/5/26 15:17
*/
public function list($map){
$map['status'] = 1;
$data = $this->model->list($map);
return $this->success($data);
}
/**
* @remark :保存扩展字段
* @name :extendSave
* @author :lyh
* @method :post
* @time :2025/5/26 15:13
* @param :id->主键;title->名称
*/
public function extendSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$info = $this->model->read(['title'=>$this->param['title']]);
if($info !== false){
$this->fail('当前扩展名称已存在');
}
$this->param['key'] = $this->model->getKey();
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success($this->param);
}
/**
* @remark :修改状态
* @name :extendStatus
* @author :lyh
* @method :post
* @time :2025/5/27 9:20
*/
public function extendStatus(){
$result = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
return $this->success(['result'=>$result]);
}
/**
* @remark :删除字段
* @name :extendDel
* @author :lyh
* @method :post
* @time :2025/5/26 15:45
* @param :id->主键
*/
public function extendDel(){
$info = $this->model->read(['id'=>$this->param['id']]);
//查看当前扩展字段是否设置了值
$extendInfoModel = new ExtendInfo();
$extendInfo = $extendInfoModel->read(['key'=>$info['key']]);
if($extendInfo !== false){
$this->fail('当前扩展字段已有产品在使用,不允许删除');
}
$this->model->del(['id'=>$this->param['id']]);
}
}