From ad8477d3ee82a3fffd5de4cd60a237c9ee6b1fb7 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Wed, 04 Mar 2026 14:27:05 +0800
Subject: [PATCH] 后台添加供需求发布

---
 admin/app/shop/controller/plus/release/DemandProject.php |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/admin/app/shop/controller/plus/release/DemandProject.php b/admin/app/shop/controller/plus/release/DemandProject.php
index 788f96e..7d387d4 100644
--- a/admin/app/shop/controller/plus/release/DemandProject.php
+++ b/admin/app/shop/controller/plus/release/DemandProject.php
@@ -21,6 +21,39 @@
     }
 
     /**
+     * 获取默认数据(分类)
+     */
+    public function defaultData()
+    {
+        $model = new ProjectModel;
+        $data = $model->getDefaultData();
+        return $this->renderSuccess('', compact('data'));
+    }
+
+    /**
+     * 后台发布需求
+     */
+    public function add()
+    {
+        $model = new ProjectModel;
+        $data = $this->postData();
+        // 获取表单数据
+        $formData = json_decode($data['formData'], true);
+        // 获取用户ID
+        $user_id = isset($data['user_id']) ? intval($data['user_id']) : 0;
+        if ($user_id <= 0) {
+            return $this->renderError('请选择发布用户');
+        }
+        // 是否支付连盟币(可选)
+        $pay_points = isset($data['pay_points']) ? intval($data['pay_points']) : 0;
+        
+        if ($model->addByAdmin($formData, $user_id, $pay_points)) {
+            return $this->renderSuccess('发布成功');
+        }
+        return $this->renderError($model->getError() ?: '发布失败');
+    }
+
+    /**
      * 审核
      */
     public function submit($project_id)
@@ -34,6 +67,27 @@
 
 
     /**
+     * 编辑
+     */
+    public function edit()
+    {
+        $model = new ProjectModel;
+        $data = $this->postData();
+        // 获取表单数据
+        $formData = json_decode($data['formData'], true);
+        // 获取项目ID
+        $project_id = isset($data['project_id']) ? intval($data['project_id']) : 0;
+        if ($project_id <= 0) {
+            return $this->renderError('项目ID不能为空');
+        }
+
+        if ($model->editByAdmin($project_id, $formData)) {
+            return $this->renderSuccess('编辑成功');
+        }
+        return $this->renderError($model->getError() ?: '编辑失败');
+    }
+
+    /**
      * 删除
      */
     public function delete($project_id)

--
Gitblit v1.9.2