CheckLogController.php
4.0 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
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* @remark :
* @name :CheckLogController.php
* @author :lyh
* @method :post
* @time :2025/4/17 10:07
*/
namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Project\OptimizeCheckList;
use App\Models\Project\OptimizeCheckLog;
use Illuminate\Http\Request;
/**
* @remark :检查日志
* @name :CheckLogController
* @author :lyh
* @method :post
* @time :2025/4/17 10:15
*/
class CheckLogController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->model = new OptimizeCheckLog();
}
/**
* @remark :检查日志列表
* @name :lists
* @author :lyh
* @method :post
* @time :2025/4/17 10:17
*/
public function lists(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
$field = ['id','check_id','date','status','images','result','created_at'];
$this->map['status'] = 1;
$this->map['type'] = $this->map['type'] ?? 1;
$lists = $this->model->lists($this->map,$this->page,$this->row,'id',$field);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2025/4/17 16:18
*/
public function info(){
$this->request->validate([
'id'=>'required',
],[
'id.required' => '主键不能为空',
]);
$data = $this->model->read($this->map);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2025/4/17 10:27
*/
public function save(){
$this->request->validate([
'project_id'=>'required', 'check_id'=>'required',
'date'=>'required', 'result'=>'required',
],[
'project_id.required' => 'project_id不能为空', 'check_id.required' => '问题id不能为空',
'date.required' => '时间不能为空', 'result.required' => '检查结果不能为空',
]);
$checkListModel = new OptimizeCheckList();
$listInfo = $checkListModel->read(['id'=>$this->param['check_id']],['id','type']);
if($listInfo !== false){
$this->param['type'] = $listInfo['type'];
}
$this->param = $this->model->saveHandleParam($this->param,$this->manage['id']);
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$id = $this->model->addReturnId($this->param);
}
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
/**
* @remark :修改状态
* @name :status
* @author :lyh
* @method :post
* @time :2025/4/17 10:43
*/
public function status(){
$this->request->validate([
'id'=>'required',
'status'=>'required',
],[
'id.required' => '主键不能为空',
'status.required' => 'status不能为空',
]);
$data = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2025/4/17 10:52
*/
public function del(){
$this->request->validate([
'id'=>'required',
],[
'id.required' => '主键不能为空',
]);
if(!is_array($this->param['id'])){
$this->param['id'] = ['in',[$this->param['id']]];
}
$data = $this->model->del($this->map);
$this->response('success',Code::SUCCESS,$data);
}
}