feat(tkqc): 관리함 이슈 프로젝트 변경 + cause_person 필드명 버그 수정

- 모바일/데스크톱 관리함에서 이슈 소속 프로젝트 변경 가능
- 프로젝트 변경 시 sequence_no 자동 재계산 (DB 함수 사용)
- in_progress 상태에서만 변경 허용 (프론트+백엔드 이중 제한)
- cause_person → responsible_person_detail 필드명 불일치 수정

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-27 07:56:20 +09:00
parent ea6f7c3013
commit ac2a2e7eed
4 changed files with 71 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from sqlalchemy import text, func
from typing import List, Optional
from datetime import datetime
@@ -140,6 +141,20 @@ async def update_issue(
# 업데이트
update_data = issue_update.dict(exclude_unset=True)
# 프로젝트 변경 시 sequence_no 재계산
if "project_id" in update_data and update_data["project_id"] != issue.project_id:
if issue.review_status and issue.review_status != ReviewStatus.in_progress:
raise HTTPException(status_code=400, detail="진행 중 상태에서만 프로젝트를 변경할 수 있습니다")
try:
new_seq = db.execute(text("SELECT generate_project_sequence_no(:pid)"),
{"pid": update_data["project_id"]}).scalar()
update_data["project_sequence_no"] = new_seq
except Exception:
max_seq = db.query(func.coalesce(func.max(Issue.project_sequence_no), 0)).filter(
Issue.project_id == update_data["project_id"]
).scalar()
update_data["project_sequence_no"] = max_seq + 1
# 사진 업데이트 처리 (최대 5장) - 새 사진 저장 후 기존 사진 삭제 (안전)
old_photos_to_delete = []
for i in range(1, 6):