CustomController.php
2.2 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
<?php
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\CustomLogic;
use App\Http\Requests\Bside\Custom\CustomRequest;
use App\Models\BCustom;
/**
* 自定义 页面
* @author:dc
* @time 2023/5/9 10:08
* Class CustomController
* @package App\Http\Controllers\Bside
*/
class CustomController extends BaseController
{
/**
* 列表数据
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/8 16:37
*/
public function index(){
// 每页数量
$limit = intval($this->param['limit']??20);
$lists = CustomLogic::instance()->getList(
[],
[],
['id','name','title','status','url','keywords','description','created_at','updated_at'],
$limit
);
return $this->success($lists);
}
/**
* 新增修改
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/8 17:06
*/
public function save(CustomRequest $request){
return $this->success(CustomLogic::instance()->save($request->validated()));
}
/**
* 删除数据
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/9 9:20
*/
public function delete(CustomRequest $request){
CustomLogic::instance()->delete($request->validated()['id']);
return $this->response('删除成功');
}
/**
* @param $id
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/10 14:10
*/
public function html($id)
{
$data = BCustom::_find($this->user['project_id'],$id);
if(!$data){
return $this->response('数据不存在',Code::SYSTEM_ERROR);
}
if($this->isPost()){
$html = $this->param['html']??'';
$data->html = $html;
$data->save();
}
return $this->response('',Code::SUCCESS,$data['html']);
}
}