TicketUploadDataController.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
96
<?php
/**
* @remark :
* @name :TicketUploadDataController.php
* @author :lyh
* @method :post
* @time :2025/9/25 09:40
*/
namespace App\Http\Controllers\Api\WorkOrder;
use App\Enums\Common\Code;
use App\Http\Controllers\Api\BaseController;
use App\Models\Ticket\TicketUploadData;
use Illuminate\Http\Request;
/**
* @remark :上传产品/博客/新闻模块
* @name :TicketUploadDataController
* @author :lyh
* @method :post
* @time :2025/9/25 09:40
*/
class TicketUploadDataController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->model = new TicketUploadData();
}
/**
* @remark :已提交列表
* @name :lists
* @author :lyh
* @method :post
* @time :2025/9/25 10:28
*/
public function lists()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
$data = $this->model->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2025/9/25 10:35
*/
public function info(){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$data = $this->model->read($this->param);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :提交数据
* @name :save
* @author :lyh
* @method :post
* @time :2025/9/25 09:48
*/
public function save()
{
$this->request->validate([
'project_id'=>'required',
'type'=>'required',
'text'=>'required'
],[
'project_id.required' => 'project_id不能为空',
'type.required' => '上传类型不能为空',
'text'=>'数据详情不为空'
]);
//验证当前数据是否已提交
$this->param['text'] = json_encode($this->param['text'],true);
$info = $this->model->read(['project_id'=>$this->$this->param['project_id'],'type'=>$this->param['type'],'text'=>$this->param['text'],'status'=>0]);
if($info === false){
$id = $this->model->addReturnId($this->param);
}else{
$id = $info['id'];
}
$data = ['id'=>$id];
$this->response('success',Code::SUCCESS,$data);
}
}