| | |
| | | } |
| | | |
| | | /** |
| | | * 获取默认数据(分类) |
| | | */ |
| | | 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) |
| | |
| | | |
| | | |
| | | /** |
| | | * 编辑 |
| | | */ |
| | | 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) |