|
@@ -13,6 +13,7 @@ use App\Enums\Common\Code; |
|
@@ -13,6 +13,7 @@ use App\Enums\Common\Code; |
|
13
|
use App\Http\Controllers\Api\BaseController;
|
13
|
use App\Http\Controllers\Api\BaseController;
|
|
14
|
use App\Models\Ticket\Project5Cate;
|
14
|
use App\Models\Ticket\Project5Cate;
|
|
15
|
use App\Models\WorkOrder\TicketProject;
|
15
|
use App\Models\WorkOrder\TicketProject;
|
|
|
|
16
|
+use Illuminate\Support\Facades\Http;
|
|
16
|
|
17
|
|
|
17
|
class Project5CateController extends BaseController
|
18
|
class Project5CateController extends BaseController
|
|
18
|
{
|
19
|
{
|
|
@@ -26,12 +27,14 @@ class Project5CateController extends BaseController |
|
@@ -26,12 +27,14 @@ class Project5CateController extends BaseController |
|
26
|
public function getProject5Cate(){
|
27
|
public function getProject5Cate(){
|
|
27
|
$this->request->validate([
|
28
|
$this->request->validate([
|
|
28
|
'post_id'=>'required',
|
29
|
'post_id'=>'required',
|
|
|
|
30
|
+ 'type'=>'required',
|
|
29
|
],[
|
31
|
],[
|
|
30
|
'post_id.required' => 'post_id不能为空',
|
32
|
'post_id.required' => 'post_id不能为空',
|
|
|
|
33
|
+ 'type.required' => '类型不能为空',
|
|
31
|
]);
|
34
|
]);
|
|
32
|
//查询是否有值
|
35
|
//查询是否有值
|
|
33
|
$project5CateModel = new Project5Cate();
|
36
|
$project5CateModel = new Project5Cate();
|
|
34
|
- $cateInfo = $project5CateModel->read(['project_id' => $this->param['post_id'],'updated_at'=>['>', date('Y-m-d H:i:s', strtotime('-48 hours'))]]);
|
37
|
+ $cateInfo = $project5CateModel->read(['project_id' => $this->param['post_id'],'type'=>$this->param['type'],'updated_at'=>['>', date('Y-m-d H:i:s', strtotime('-48 hours'))]]);
|
|
35
|
if($cateInfo !== false){
|
38
|
if($cateInfo !== false){
|
|
36
|
$resultData = $cateInfo['text'];
|
39
|
$resultData = $cateInfo['text'];
|
|
37
|
$this->response('success', Code::SUCCESS, $resultData);
|
40
|
$this->response('success', Code::SUCCESS, $resultData);
|
|
@@ -42,18 +45,72 @@ class Project5CateController extends BaseController |
|
@@ -42,18 +45,72 @@ class Project5CateController extends BaseController |
|
42
|
if($projectInfo === false){
|
45
|
if($projectInfo === false){
|
|
43
|
$this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
46
|
$this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
|
44
|
}
|
47
|
}
|
|
45
|
- $url = $projectInfo['website'].'/wp-admin/admin-ajax.php?action=get_products_category';
|
48
|
+ //todo::目前写死
|
|
|
|
49
|
+ $projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
50
|
+ $action = $project5CateModel->getCateTypeAction($this->param['type']);
|
|
|
|
51
|
+ if(empty($action)){
|
|
|
|
52
|
+ $this->response('未知请求',Code::SYSTEM_ERROR);
|
|
|
|
53
|
+ }
|
|
|
|
54
|
+ $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
46
|
$data = http_get($url);
|
55
|
$data = http_get($url);
|
|
47
|
if($data && $data['status'] == 200){
|
56
|
if($data && $data['status'] == 200){
|
|
48
|
$resultData = $data['data'];
|
57
|
$resultData = $data['data'];
|
|
49
|
$saveData = [
|
58
|
$saveData = [
|
|
50
|
'project_id' => $projectInfo['post_id'],
|
59
|
'project_id' => $projectInfo['post_id'],
|
|
51
|
- 'domain' => $projectInfo['domain'],
|
60
|
+ 'domain' => $projectInfo['website'],
|
|
52
|
'text'=>json_encode($data['data']),
|
61
|
'text'=>json_encode($data['data']),
|
|
|
|
62
|
+ 'type' => $this->param['type'],
|
|
53
|
];
|
63
|
];
|
|
54
|
$project5CateModel->addReturnId($saveData);
|
64
|
$project5CateModel->addReturnId($saveData);
|
|
55
|
$this->response('success', Code::SUCCESS,$resultData);
|
65
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
56
|
}
|
66
|
}
|
|
57
|
$this->response('success',Code::SUCCESS,$url);
|
67
|
$this->response('success',Code::SUCCESS,$url);
|
|
58
|
}
|
68
|
}
|
|
|
|
69
|
+
|
|
|
|
70
|
+ /**
|
|
|
|
71
|
+ * @remark :新增分类
|
|
|
|
72
|
+ * @name :addProject5Cate
|
|
|
|
73
|
+ * @author :lyh
|
|
|
|
74
|
+ * @method :post
|
|
|
|
75
|
+ * @time :2025/11/8 10:25
|
|
|
|
76
|
+ */
|
|
|
|
77
|
+ public function addProject5Cate()
|
|
|
|
78
|
+ {
|
|
|
|
79
|
+ $this->request->validate([
|
|
|
|
80
|
+ 'post_id'=>'required',
|
|
|
|
81
|
+ 'type'=>'required',
|
|
|
|
82
|
+ 'name'=>'required',
|
|
|
|
83
|
+ 'parent'=>'required',
|
|
|
|
84
|
+ ],[
|
|
|
|
85
|
+ 'post_id.required' => 'post_id不能为空',
|
|
|
|
86
|
+ 'type.required' => '类型不能为空',
|
|
|
|
87
|
+ 'name.required' => '名称不能为空',
|
|
|
|
88
|
+ 'parent.required' => '上级ID不能为空',
|
|
|
|
89
|
+ ]);
|
|
|
|
90
|
+ //获取域名
|
|
|
|
91
|
+ $ticketProjectMdoel = new TicketProject();
|
|
|
|
92
|
+ $projectInfo = $ticketProjectMdoel->read(['post_id' => $this->param['post_id']]);
|
|
|
|
93
|
+ if($projectInfo === false){
|
|
|
|
94
|
+ $this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
|
|
|
95
|
+ }
|
|
|
|
96
|
+ $project5CateModel = new Project5Cate();
|
|
|
|
97
|
+ //todo::目前写死,上线放开
|
|
|
|
98
|
+ $projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
99
|
+ $action = $project5CateModel->saveCateTypeAction($this->param['type']);
|
|
|
|
100
|
+ $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
|
|
101
|
+ if(empty($action)){
|
|
|
|
102
|
+ $this->response('未知请求',Code::SYSTEM_ERROR);
|
|
|
|
103
|
+ }
|
|
|
|
104
|
+ $response = Http::withHeaders([])->asForm()->post($url, [
|
|
|
|
105
|
+ 'name' => $this->param['name'],
|
|
|
|
106
|
+ 'parent' => $this->param['parent'] ?? 0,
|
|
|
|
107
|
+ ]);
|
|
|
|
108
|
+ if ($response->successful()) {
|
|
|
|
109
|
+ $result = $response->json(); // 获取 JSON 响应体
|
|
|
|
110
|
+ if($result && $result['status'] == 200){
|
|
|
|
111
|
+ $this->response('success');
|
|
|
|
112
|
+ }
|
|
|
|
113
|
+ }
|
|
|
|
114
|
+ $this->response('请求失败',Code::SYSTEM_ERROR);
|
|
|
|
115
|
+ }
|
|
59
|
} |
116
|
} |