作者 李宇航

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

变更数据



查看合并请求 !3193
@@ -26,12 +26,14 @@ class Project5CateController extends BaseController @@ -26,12 +26,14 @@ class Project5CateController extends BaseController
26 public function getProject5Cate(){ 26 public function getProject5Cate(){
27 $this->request->validate([ 27 $this->request->validate([
28 'post_id'=>'required', 28 'post_id'=>'required',
  29 + 'type'=>'required',
29 ],[ 30 ],[
30 'post_id.required' => 'post_id不能为空', 31 'post_id.required' => 'post_id不能为空',
  32 + 'type.required' => '类型不能为空',
31 ]); 33 ]);
32 //查询是否有值 34 //查询是否有值
33 $project5CateModel = new Project5Cate(); 35 $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'))]]); 36 + $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){ 37 if($cateInfo !== false){
36 $resultData = $cateInfo['text']; 38 $resultData = $cateInfo['text'];
37 $this->response('success', Code::SUCCESS, $resultData); 39 $this->response('success', Code::SUCCESS, $resultData);
@@ -44,6 +46,10 @@ class Project5CateController extends BaseController @@ -44,6 +46,10 @@ class Project5CateController extends BaseController
44 } 46 }
45 //todo::目前写死 47 //todo::目前写死
46 $projectInfo['website'] = 'https://devmark.globalso.com/'; 48 $projectInfo['website'] = 'https://devmark.globalso.com/';
  49 + $action = $project5CateModel->getCateType($this->param['type']);
  50 + if(empty($action)){
  51 + $this->response('未知请求',Code::SYSTEM_ERROR);
  52 + }
47 $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action=get_products_category'; 53 $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action=get_products_category';
48 $data = http_get($url); 54 $data = http_get($url);
49 if($data && $data['status'] == 200){ 55 if($data && $data['status'] == 200){
@@ -52,10 +58,12 @@ class Project5CateController extends BaseController @@ -52,10 +58,12 @@ class Project5CateController extends BaseController
52 'project_id' => $projectInfo['post_id'], 58 'project_id' => $projectInfo['post_id'],
53 'domain' => $projectInfo['website'], 59 'domain' => $projectInfo['website'],
54 'text'=>json_encode($data['data']), 60 'text'=>json_encode($data['data']),
  61 + 'type' => $this->param['type'],
55 ]; 62 ];
56 $project5CateModel->addReturnId($saveData); 63 $project5CateModel->addReturnId($saveData);
57 $this->response('success', Code::SUCCESS,$resultData); 64 $this->response('success', Code::SUCCESS,$resultData);
58 } 65 }
59 $this->response('success',Code::SUCCESS,$url); 66 $this->response('success',Code::SUCCESS,$url);
60 } 67 }
  68 +
61 } 69 }
@@ -29,4 +29,23 @@ class Project5Cate extends Base @@ -29,4 +29,23 @@ class Project5Cate extends Base
29 } 29 }
30 return $value; 30 return $value;
31 } 31 }
  32 +
  33 + /**
  34 + * @remark :请求的方法
  35 + * @name :getCateType
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2025/11/8 10:22
  39 + */
  40 + public function getCateType($type = '')
  41 + {
  42 + $data = [
  43 + 1 => 'get_products_category',
  44 + 3 => 'get_news_category',
  45 + ];
  46 + if(!empty($type)){
  47 + return $data[$type];
  48 + }
  49 + return '';
  50 + }
32 } 51 }