作者 李宇航

合并分支 'lyh-server' 到 'master'

变更数据



查看合并请求 !3193
... ... @@ -26,12 +26,14 @@ class Project5CateController extends BaseController
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'],'updated_at'=>['>', date('Y-m-d H:i:s', strtotime('-48 hours'))]]);
$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);
... ... @@ -44,6 +46,10 @@ class Project5CateController extends BaseController
}
//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=get_products_category';
$data = http_get($url);
if($data && $data['status'] == 200){
... ... @@ -52,10 +58,12 @@ class Project5CateController extends BaseController
'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);
}
}
... ...
... ... @@ -29,4 +29,23 @@ class Project5Cate extends Base
}
return $value;
}
/**
* @remark :请求的方法
* @name :getCateType
* @author :lyh
* @method :post
* @time :2025/11/8 10:22
*/
public function getCateType($type = '')
{
$data = [
1 => 'get_products_category',
3 => 'get_news_category',
];
if(!empty($type)){
return $data[$type];
}
return '';
}
}
... ...