作者 李宇航

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

Lyh server



查看合并请求 !3194
@@ -50,7 +50,7 @@ class Project5CateController extends BaseController @@ -50,7 +50,7 @@ class Project5CateController extends BaseController
50 if(empty($action)){ 50 if(empty($action)){
51 $this->response('未知请求',Code::SYSTEM_ERROR); 51 $this->response('未知请求',Code::SYSTEM_ERROR);
52 } 52 }
53 - $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action=get_products_category'; 53 + $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
54 $data = http_get($url); 54 $data = http_get($url);
55 if($data && $data['status'] == 200){ 55 if($data && $data['status'] == 200){
56 $resultData = $data['data']; 56 $resultData = $data['data'];
@@ -66,4 +66,43 @@ class Project5CateController extends BaseController @@ -66,4 +66,43 @@ class Project5CateController extends BaseController
66 $this->response('success',Code::SUCCESS,$url); 66 $this->response('success',Code::SUCCESS,$url);
67 } 67 }
68 68
  69 + /**
  70 + * @remark :新增分类
  71 + * @name :addProject5Cate
  72 + * @author :lyh
  73 + * @method :post
  74 + * @time :2025/11/8 10:25
  75 + */
  76 + public function addProject5Cate()
  77 + {
  78 + $this->request->validate([
  79 + 'post_id'=>'required',
  80 + 'type'=>'required',
  81 + 'name'=>'required',
  82 + 'parent'=>'required',
  83 + ],[
  84 + 'post_id.required' => 'post_id不能为空',
  85 + 'type.required' => '类型不能为空',
  86 + 'name.required' => '名称不能为空',
  87 + 'parent.required' => '上级ID不能为空',
  88 + ]);
  89 + //获取域名
  90 + $ticketProjectMdoel = new TicketProject();
  91 + $projectInfo = $ticketProjectMdoel->read(['post_id' => $this->param['post_id']]);
  92 + if($projectInfo === false){
  93 + $this->response('当前项目不存在或数据未同步',Code::SYSTEM_ERROR);
  94 + }
  95 + $project5CateModel = new Project5Cate();
  96 + $projectInfo['website'] = 'https://devmark.globalso.com/';
  97 + $action = $project5CateModel->saveCateTypeAction($this->param['type']);
  98 + $url = $projectInfo['website'].'wp-admin/admin-ajax.php?action='.$action;
  99 + if(empty($action)){
  100 + $this->response('未知请求',Code::SYSTEM_ERROR);
  101 + }
  102 + $data = http_post($url,json_encode(['name'=>$this->param['name'],'parent'=>$this->param['parent']],true));
  103 + if($data && $data['status'] == 200){
  104 + $this->response('success', );
  105 + }
  106 + $this->response('请求失败',Code::SYSTEM_ERROR);
  107 + }
69 } 108 }
@@ -37,7 +37,7 @@ class Project5Cate extends Base @@ -37,7 +37,7 @@ class Project5Cate extends Base
37 * @method :post 37 * @method :post
38 * @time :2025/11/8 10:22 38 * @time :2025/11/8 10:22
39 */ 39 */
40 - public function getCateType($type = '') 40 + public function getCateTypeAction($type = '')
41 { 41 {
42 $data = [ 42 $data = [
43 1 => 'get_products_category', 43 1 => 'get_products_category',
@@ -48,4 +48,16 @@ class Project5Cate extends Base @@ -48,4 +48,16 @@ class Project5Cate extends Base
48 } 48 }
49 return ''; 49 return '';
50 } 50 }
  51 +
  52 + public function saveCateTypeAction($type = '')
  53 + {
  54 + $data = [
  55 + 1 => 'add_products_category',
  56 + 3 => 'add_news_category',
  57 + ];
  58 + if(!empty($type)){
  59 + return $data[$type];
  60 + }
  61 + return '';
  62 + }
51 } 63 }