|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :Project5CateController.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/8 09:35
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\WorkOrder;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Api\BaseController;
|
|
|
|
use App\Models\Ticket\Project5Cate;
|
|
|
|
use App\Models\WorkOrder\TicketProject;
|
|
|
|
|
|
|
|
class Project5CateController extends BaseController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @remark :获取对应项目的分类
|
|
|
|
* @name :getProject5Cate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/8 09:27
|
|
|
|
*/
|
|
|
|
public function getProject5Cate(){
|
|
|
|
$this->request->validate([
|
|
|
|
'post_id'=>'required',
|
|
|
|
'type'=>'required',
|
|
|
|
],[
|
|
|
|
'post_id.required' => 'post_id不能为空',
|
|
|
|
'type.required' => '类型不能为空',
|
|
|
|
]);
|
|
|
|
//查询是否有值
|
|
|
|
$project5CateModel = new Project5Cate();
|
|
|
|
$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'))]]);
|
|
|
|
if($cateInfo !== false){
|
|
|
|
$resultData = $cateInfo['text'];
|
|
|
|
$this->response('success', Code::SUCCESS, $resultData);
|
|
|
|
}
|
|
|
|
//获取域名
|
|
|
|
$ticketProjectMdoel = new TicketProject();
|
|
|
|
$projectInfo = $ticketProjectMdoel->read(['post_id' => $this->param['post_id']]);
|
|
|
|
if($projectInfo === false){
|
|
|
|
$this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
//todo::目前写死
|
|
|
|
$projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
$action = $project5CateModel->getCateType($this->param['type']);
|
|
|
|
if(empty($action)){
|
|
|
|
$this->response('未知请求',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
|
|
$data = http_get($url);
|
|
|
|
if($data && $data['status'] == 200){
|
|
|
|
$resultData = $data['data'];
|
|
|
|
$saveData = [
|
|
|
|
'project_id' => $projectInfo['post_id'],
|
|
|
|
'domain' => $projectInfo['website'],
|
|
|
|
'text'=>json_encode($data['data']),
|
|
|
|
'type' => $this->param['type'],
|
|
|
|
];
|
|
|
|
$project5CateModel->addReturnId($saveData);
|
|
|
|
$this->response('success', Code::SUCCESS,$resultData);
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增分类
|
|
|
|
* @name :addProject5Cate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/8 10:25
|
|
|
|
*/
|
|
|
|
public function addProject5Cate()
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'post_id'=>'required',
|
|
|
|
'type'=>'required',
|
|
|
|
'name'=>'required',
|
|
|
|
'parent'=>'required',
|
|
|
|
],[
|
|
|
|
'post_id.required' => 'post_id不能为空',
|
|
|
|
'type.required' => '类型不能为空',
|
|
|
|
'name.required' => '名称不能为空',
|
|
|
|
'parent.required' => '上级ID不能为空',
|
|
|
|
]);
|
|
|
|
//获取域名
|
|
|
|
$ticketProjectMdoel = new TicketProject();
|
|
|
|
$projectInfo = $ticketProjectMdoel->read(['post_id' => $this->param['post_id']]);
|
|
|
|
if($projectInfo === false){
|
|
|
|
$this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$project5CateModel = new Project5Cate();
|
|
|
|
$projectInfo['website'] = 'https://devmark.globalso.com/';
|
|
|
|
$action = $project5CateModel->saveCateTypeAction($this->param['type']);
|
|
|
|
$url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
|
|
|
|
if(empty($action)){
|
|
|
|
$this->response('未知请求',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$data = http_post($url,json_encode(['name'=>$this->param['name'],'parent'=>$this->param['parent']],true));
|
|
|
|
if($data && $data['status'] == 200){
|
|
|
|
$this->response('success', );
|
|
|
|
}
|
|
|
|
$this->response('请求失败',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|