ProjectController.php
9.6 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?php
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\OnlineCheckLogic;
use App\Http\Logic\Aside\Project\ProcessRecordsLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Requests\Aside\Project\ProcessRecordsRequest;
use App\Http\Requests\Aside\Project\ProjectRequest;
use App\Models\Com\City;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\ManageHr;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use Illuminate\Http\Request;
/**
* 项目管理
* Class ProjectController
* @package App\Http\Controllers\Aside\Project
* @author zbj
* @date 2023/4/25
*/
class ProjectController extends BaseController
{
public function list(ProjectLogic $logic)
{
$map = [];
//搜索类型
if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_THREE){
$map[] = ['type', 'in' ,[Project::TYPE_FOUR,Project::TYPE_SIX]];
}
if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_TWO){
$map[] = ['type', 'in', [Project::TYPE_TWO,Project::TYPE_THREE]];
}
if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_ONE){
$map[] = ['type','in',[Project::TYPE_ONE]];
}
if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_ZERO){
$map[] = ['type','in',[Project::TYPE_ZERO]];
}
//搜索技术组
if(!empty($this->param['dep_id'])){
$map[] = ['id', 'in', DeployBuild::where('dept_id', $this->param['dep_id'])->pluck('project_id')->toArray()];
}
//搜索技术人员
if(!empty($this->param['manage_id'])){
$map[] = ['id', 'in', DeployBuild::where('leader_mid', $this->param['manage_id'])
->orwhere('manager_mid', $this->param['manage_id'])
->orwhere('designer_mid', $this->param['manage_id'])
->orwhere('tech_mid', $this->param['manage_id'])
->pluck('project_id')
->toArray()];
}
//按类型搜索
if(!empty($this->param['search']) && !empty($this->param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];
}else{
$map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];
}
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort,['*'],$this->row);
return $this->success($data);
}
/**
* @remark :获取数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/17 16:42
*/
public function info(Request $request, ProjectLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getProjectInfo($this->param['id']);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/17 16:42
*/
public function save(ProjectRequest $request, ProjectLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
}
/**
* 询盘通知设置
* @param ProjectRequest $request
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/5/17
*/
public function inquiry_set(Request $request, ProjectLogic $logic){
$request->validate([
'project_id'=>'required'
],[
'project_id.required' => '项目ID不能为空'
]);
if($request->isMethod('get')){
$data = InquirySet::where('project_id', $request->project_id)->first();
if(!$data){
$data = ['emails' => '', 'phones' => ''];
}else{
$data = $data->toArray();
}
return $this->success($data);
}
$data = $logic->saveInquirySet($this->param);
return $this->success($data);
}
/**
* 数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/20
*/
public function data_source(ProjectLogic $logic){
$data = $logic->dataSource();
return $this->success($data);
}
/**
* 省市数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
public function city_source(){
$data = City::source($this->param['id'] ?? 0);
return $this->success($data);
}
/**
* 渠道数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
public function channel_source(ProjectLogic $logic){
$data = $logic->channelSource($this->param);
return $this->success($data);
}
/**
* 进程记录
* @author zbj
* @date 2023/6/25
*/
public function get_process_records(Request $request, ProcessRecordsLogic $logic){
$request->validate([
'project_id'=>'required'
],[
'project_id.required' => '项目ID不能为空'
]);
$data = $logic->getInfo($this->param['project_id']);
return $this->success($data);
}
/**
* 保存进程记录
* @author zbj
* @date 2023/6/25
*/
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){
$data = $logic->save($this->param);
return $this->success($data);
}
/**
* 获取合同票据
* @author zbj
* @date 2023/6/27
*/
public function get_contract_bill(Request $request){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$payment = Payment::where('project_id', $this->param['id'])->select(['contract', 'bill'])->first();
$data = $payment->makeVisible(['contract', 'bill']);
return $this->success($data ? $data->toArray() : []);
}
/**
* 提交审核
* @author zbj
* @date 2023/6/29
*/
public function submit_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$logic->saveOnlineCheck();
return $this->success();
}
/**
* 上线审核
* @author zbj
* @date 2023/6/29
*/
public function online_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:0,1'
],[
'id.required' => 'ID不能为空',
'type.required' => '请选择审核类型',
'type.in' => '审核类型值无效',
'status.required' => '请选择审核状态',
'status.in' => '审核状态值无效',
]);
$logic->onlineCheck($this->param);
return $this->success();
}
/**
* @remark :获取组
* @name :getBelongingGroup
* @author :lyh
* @method :post
* @time :2023/8/4 16:27
*/
public function getBelongingGroup(){
$this->request->validate([
'type'=>'required',
],[
'type.required' => '请选择审核类型'
]);
$belongGroupModel = new BelongingGroup();
$lists = $belongGroupModel->list($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :根据用户组获取成员
* @name :getManager
* @author :lyh
* @method :post
* @time :2023/8/8 10:29
*/
public function getManagerList(){
$hrManagerModel = new ManageHr();
$lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取项目服务器与数据库列表
* @name :getServiceConfig
* @author :lyh
* @method :post
* @time :2023/8/14 10:23
*/
public function getServiceConfig(){
$serviceConfigModel = new ServerConfig();
$list = $serviceConfigModel->list($this->param);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取域名列表
* @name :getDomain
* @author :lyh
* @method :post
* @time :2023/8/14 10:29
*/
public function getDomain(){
$domainModel = new DomainInfo();
$list = $domainModel->list(['status'=>0]);
$this->response('success',Code::SUCCESS,$list);
}
}