操作
バグ #138
未完了【実装】Redmineドキュメント機能のAPI連携
ステータス:
新規
優先度:
通常
担当者:
-
開始日:
2025-06-02
期日:
進捗率:
0%
予定工数:
説明
実装¶
実施内容¶
- ドキュメントサービス層の実装
- API層の実装
- 設定機能の実装
- ユニットテストの実装
実装詳細¶
ドキュメントサービス (document_service.py)¶
ドキュメント操作の核となるサービス層を実装:
- ファイルアップロード機能
- チケット添付機能
- 独立ドキュメント作成機能(Issue/Wiki)
- ドキュメント検索機能
- カテゴリ管理機能
- コンテンツタイプ管理
class DocumentService:
"""Redmineドキュメント操作サービス"""
def __init__(self, config_path: str = None):
# 設定ファイル読み込み
# ...
def attach_document_to_issue(self, issue_id, file_path, filename, content_type, comment):
# チケットにドキュメントを添付
# ...
def create_standalone_document(self, project_id, title, description, file_path, filename, content_type, keywords):
# 独立したドキュメントを作成
# ...
def search_documents(self, project_id, keyword, limit):
# ドキュメント検索
# ...
API層 (api.py)¶
FastAPIを使用したRESTful API実装:
- エンドポイント定義
- リクエスト/レスポンスモデル
- バリデーション
- エラーハンドリング
- CORS設定
app = FastAPI(title="Redmine Document API")
@app.post("/documents/standalone", response_model=DocumentResponse)
async def create_standalone_document(document: DocumentCreate, file: UploadFile):
# 独立ドキュメント作成API
# ...
@app.post("/documents/attach")
async def attach_document_to_issue(document: DocumentAttach, file: UploadFile):
# チケット添付API
# ...
@app.get("/documents")
async def search_documents(project_id: Optional[int] = None, keyword: Optional[str] = None):
# ドキュメント検索API
# ...
モデル定義 (models.py)¶
データモデルの定義:
- ドキュメントモデル
- 検索フィルタモデル
- API入出力モデル
設定ファイル (document_config.json)¶
可変パラメータの外部設定化:
- Redmine接続情報
- ドキュメント設定
- 許可ファイル設定
テスト実装 (test_document_api.py)¶
単体テスト:
- サービス層のテスト
- API層のテスト
- エラーケースのテスト
実装状況¶
- コアサービス層: 完了
- API層: 完了
- モデル定義: 完了
- 設定機能: 完了
- ユニットテスト: 実装中(基本機能のテストは完了)
操作