diff --git a/app/api/controller/ProjectIndex.php b/app/api/controller/ProjectIndex.php index 0e1cadd..ecd6f64 100644 --- a/app/api/controller/ProjectIndex.php +++ b/app/api/controller/ProjectIndex.php @@ -375,4 +375,69 @@ class ProjectIndex extends ApiController $this->apiError('删除失败'); } } + + //添加附件 + public function add_file() + { + $param = get_params(); + $this->uid = JWT_UID; + if (empty($param['topic_id'])) { + $this->apiError("项目id不能为空"); + } + if (empty($param['file_id'])) { + $this->apiError("文件id不能为空"); + } + if (empty($param['file_name'])) { + $this->apiError("文件名称不能为空"); + } + if (empty($param['module'])) { + // project + $this->apiError("模块不能为空"); + } + $param['create_time'] = time(); + $param['admin_id'] = $this->uid; + $fid = Db::name('ProjectFile')->strict(false)->field(true)->insertGetId($param); + if ($fid) { + $log_data = array( + 'module' => $param['module'], + 'field' => 'file', + 'action' => 'upload', + $param['module'] . '_id' => $param['topic_id'], + 'admin_id' => $this->uid, + 'old_content' => '', + 'new_content' => $param['file_name'], + 'create_time' => time(), + ); + Db::name('ProjectLog')->strict(false)->field(true)->insert($log_data); + $this->apiSuccess('添加附件成功'); + } + $this->apiError('添加附件失败'); + } + + //删除附件 + public function delete_file() + { + $id = get_params("id"); + if (empty($id)) { + $this->apiError("项目文件id不能为空"); + } + $detail = Db::name('ProjectFile')->where('id', $id)->find(); + if ($detail && Db::name('ProjectFile')->where('id', $id)->delete() !== false) { + $file_name = Db::name('File')->where('id', $detail['file_id'])->value('name'); + $log_data = array( + 'module' => $detail['module'], + 'field' => 'file', + 'action' => 'delete', + $detail['module'] . '_id' => $detail['topic_id'], + 'admin_id' => $this->uid, + 'new_content' => $file_name, + 'create_time' => time(), + ); + Db::name('ProjectLog')->strict(false)->field(true)->insert($log_data); + $this->apiSuccess('删除成功');; + } else { + $this->apiError('删除失败'); + } + + } } diff --git a/public/storage/202310/15dd9056315e3ab96ab47b5c75153cee.txt b/public/storage/202310/15dd9056315e3ab96ab47b5c75153cee.txt new file mode 100644 index 0000000..6035523 --- /dev/null +++ b/public/storage/202310/15dd9056315e3ab96ab47b5c75153cee.txt @@ -0,0 +1,10 @@ +php think swoole +php think swoole restart +php think queue:work + +composer require overtrue/pinyin:4.1.0 +composer require jpush/jpush + +git config --global credential.helper store +alias graph="git log --graph --oneline --decorate --all" + diff --git a/public/storage/202310/f4c69ffa648569629a6837796a8196e0.jpg b/public/storage/202310/f4c69ffa648569629a6837796a8196e0.jpg new file mode 100644 index 0000000..db704ed Binary files /dev/null and b/public/storage/202310/f4c69ffa648569629a6837796a8196e0.jpg differ