GeoArticleLogic.php
3.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* @remark :
* @name :GeoArticleLogic.php
* @author :lyh
* @method :post
* @time :2025/7/14 16:21
*/
namespace App\Http\Logic\Aside\Geo;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoArticle;
/**
* @remark :GEO文章列表
* @name :GeoArticleLogic
* @author :lyh
* @method :post
* @time :2025/7/14 16:22
*/
class GeoArticleLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new GeoArticle();
}
/**
* @remark :列表数据
* @name :getArticleList
* @author :lyh
* @method :post
* @time :2025/7/14 16:24
*/
public function getArticleList($map = [],$page = 1,$row = 20,$order = 'id'){
if(isset($map['filename']) && !empty($map['filename'])){
$map['filename'] = ['like','%'.$map['filename'].'%'];
}
$filed = ['*'];
$lists = $this->model->lists($map,$page,$row,$order,$filed);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $key => $item){
$item['download_url'] = url('a/download_files?path='.$item['url']);
$item['url_link'] = getFileUrl($item['url']);
$lists['list'][$key] = $item;
}
}
return $this->success($lists);
}
/**
* @remark :获取数据详情
* @name :getArticleInfo
* @author :lyh
* @method :post
* @time :2025/7/14 16:26
*/
public function getArticleInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
$info['url'] = getFileUrl($info['url']);
return $this->success($info);
}
/**
* @remark :更新单个数据
* @name :editArticle
* @author :lyh
* @method :post
* @time :2025/7/15 10:29
*/
public function editArticle(){
$this->param['url'] = str_replace_url($this->param['url']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
return $this->success(['id'=>$this->param['id']]);
}
/**
* @remark :保存数据
* @name :saveArticle
* @author :lyh
* @method :post
* @time :2025/7/14 16:26
*/
public function saveArticle(){
try {
if(!empty($this->param['data'])){
$data = [];
foreach ($this->param['data'] as $item){
$info = $this->model->read(['url'=>$item['url'],'filename'=>$item['filename']],['id','url']);
if($info === false){
$data[] = [
'filename' => $item['filename'],
'url'=> $item['url'],
'project_id'=>$this->param['project_id']
];
}
}
$this->model->insertAll($data);
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :删除数据
* @name :delArticle
* @author :lyh
* @method :post
* @time :2025/7/14 16:28
*/
public function delArticle(){
try {
$this->model->del(['id'=>['in',$this->param['ids']]]);
}catch (\Exception $e){
$this->fail('删除失败,请联系管理员.');
}
return $this->success();
}
}