refactor: debug print 제거 + bcrypt 통일 + 미사용 의존성 정리

- System 3 issues.py: DEBUG print 24곳 제거 (민감정보 노출 방지)
- System 1 API: bcrypt(네이티브) → bcryptjs(순수JS) 통일 (3파일)
- System 1 API: 미사용 bcrypt, sqlite3 의존성 제거
- FastAPI bridge: deprecated datetime.utcnow() 수정
- git: 추적 중이던 로그파일 7개 제거 (.gitignore 적용)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-02-25 08:54:47 +09:00
parent 4581cddbc0
commit 9f35d33f65
13 changed files with 7 additions and 611953 deletions

View File

@@ -7,7 +7,7 @@
* @since 2025-12-11
*/
const bcrypt = require('bcrypt');
const bcrypt = require('bcryptjs');
const { ValidationError, ForbiddenError, NotFoundError, ConflictError, DatabaseError } = require('../utils/errors');
const { asyncHandler } = require('../middlewares/errorHandler');
const logger = require('../utils/logger');

View File

@@ -14,7 +14,7 @@ const logger = require('../utils/logger');
const cache = require('../utils/cache');
const { optimizedQueries } = require('../utils/queryOptimizer');
const { hangulToRoman, generateUniqueUsername } = require('../utils/hangulToRoman');
const bcrypt = require('bcrypt');
const bcrypt = require('bcryptjs');
const { getDb } = require('../dbPool');
/**

View File

@@ -10,7 +10,7 @@
* 5. 현재 연도 연차 잔액 초기화 (workers.annual_leave 사용)
*/
const bcrypt = require('bcrypt');
const bcrypt = require('bcryptjs');
const { generateUniqueUsername } = require('../../utils/hangulToRoman');
exports.up = async function(knex) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,6 @@
"@simplewebauthn/server": "^13.1.1",
"async-retry": "^1.3.3",
"axios": "^1.6.7",
"bcrypt": "^6.0.0",
"bcryptjs": "^2.4.3",
"compression": "^1.8.1",
"cors": "^2.8.5",
@@ -39,7 +38,6 @@
"pm2": "^5.3.0",
"qrcode": "^1.5.4",
"redis": "^5.9.0",
"sqlite3": "^5.1.6",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1"
},

View File

@@ -1,27 +0,0 @@
🚀 Technical Korea Work Management System v2.1.0
📍 서버가 포트 3005에서 실행 중입니다.
🌐 접속 URL: http://localhost:3005
📊 API 문서: http://localhost:3005/api
🔒 보안 기능:
✅ JWT 토큰 인증
✅ 로그인 실패 제한 (5회)
✅ API 속도 제한
✅ 보안 헤더 (Helmet)
✅ CORS 설정 (192.168.0.3:3001 허용)
✅ 활동 로깅
📋 새로운 기능:
🔐 비밀번호 변경 (본인/관리자)
🔄 토큰 갱신 (Refresh Token)
📊 로그인 이력 조회
💪 비밀번호 강도 체크
🟢 Health check 호출됨!
🟢 Health check 호출됨!
🟢 Health check 호출됨!
🟢 Health check 호출됨!
🟢 Health check 호출됨!
🟢 Health check 호출됨!
🟢 Health check 호출됨!

View File

@@ -1,119 +0,0 @@
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:50: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("startup")
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:79: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("shutdown")
INFO: Will watch for changes in these directories: ['/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge']
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started reloader process [73546] using WatchFiles
INFO: Started server process [73613]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
✅ Redis 연결 성공
INFO: 127.0.0.1:61128 - "GET /cache/stats HTTP/1.1" 200 OK
🟡 캐시 미스: health:
INFO: 127.0.0.1:61136 - "GET /health HTTP/1.1" 200 OK
🟢 캐시 히트: health:
INFO: 127.0.0.1:61142 - "GET /health HTTP/1.1" 200 OK
INFO:main:🔗 프록시: GET http://localhost:3005/api/health
INFO:main:✅ 응답: 200 (82 bytes)
INFO:main:💾 캐시 저장: GET http://localhost:3005/api/health
INFO: 127.0.0.1:61154 - "GET /api/health HTTP/1.1" 200 OK
INFO:main:🟢 캐시 히트: GET http://localhost:3005/api/health
INFO: 127.0.0.1:61199 - "GET /api/health HTTP/1.1" 200 OK
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'analytics.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [73613]
INFO: Started server process [74900]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'analytics.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [74900]
✅ Redis 연결 성공
INFO: Started server process [74902]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [74902]
✅ Redis 연결 성공
INFO: Started server process [74920]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [74920]
✅ Redis 연결 성공
INFO: Started server process [74929]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [74929]
✅ Redis 연결 성공
INFO: Started server process [74942]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
INFO:watchfiles.main:1 change detected
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [74942]
✅ Redis 연결 성공
INFO: Stopping reloader process [73546]

View File

@@ -1,16 +0,0 @@
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:50: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("startup")
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:79: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("shutdown")
INFO: Will watch for changes in these directories: ['/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge']
ERROR: [Errno 48] Address already in use

View File

@@ -1,266 +0,0 @@
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:40: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("startup")
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:62: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("shutdown")
INFO: Will watch for changes in these directories: ['/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge']
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started reloader process [59893] using WatchFiles
INFO: Started server process [59960]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO: 127.0.0.1:51845 - "GET / HTTP/1.1" 200 OK
INFO: 127.0.0.1:51858 - "GET /health HTTP/1.1" 200 OK
INFO:main:🔗 프록시: GET http://localhost:3005/api/health
INFO:main:✅ 응답: 200 (82 bytes)
INFO: 127.0.0.1:51876 - "GET /api/health HTTP/1.1" 200 OK
INFO:watchfiles.main:144 changes detected
INFO:watchfiles.main:1 change detected
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [59960]
INFO: Started server process [60804]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [60804]
INFO: Started server process [60813]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [60813]
INFO: Started server process [60819]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [60819]
INFO: Started server process [60828]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [60828]
INFO: Started server process [60837]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
INFO: 127.0.0.1:52227 - "HEAD / HTTP/1.1" 405 Method Not Allowed
INFO: 127.0.0.1:52257 - "GET / HTTP/1.1" 200 OK
INFO:main:🔗 프록시: GET http://localhost:3005/api/health
INFO:main:✅ 응답: 200 (82 bytes)
INFO: 127.0.0.1:52309 - "GET /api/health HTTP/1.1" 200 OK
INFO: 127.0.0.1:52338 - "GET /login.css HTTP/1.1" 200 OK
INFO: 127.0.0.1:52380 - "HEAD /logo.png HTTP/1.1" 200 OK
INFO:watchfiles.main:2 changes detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [60837]
INFO: Started server process [61912]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'cache.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [61912]
INFO: Started server process [62616]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'cache.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [62616]
INFO: Started server process [62618]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'config.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [62618]
INFO: Started server process [64772]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64772]
INFO: Started server process [64848]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64848]
INFO: Started server process [64868]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64868]
✅ Redis 연결 성공
INFO: Started server process [64890]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64890]
✅ Redis 연결 성공
INFO: Started server process [64916]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64916]
✅ Redis 연결 성공
INFO: Started server process [64934]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64934]
✅ Redis 연결 성공
INFO: Started server process [64956]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
WARNING: WatchFiles detected changes in 'main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64956]
✅ Redis 연결 성공
INFO: Started server process [64979]
INFO: Waiting for application startup.
INFO:main:🚀 TK FastAPI Bridge v1.0.0 시작됨
INFO:main:📍 포트: 8000
INFO:main:🔗 Express.js API: http://localhost:3005
INFO:main:💾 캐시: Redis (연결됨)
INFO: Application startup complete.
INFO:watchfiles.main:1 change detected
INFO:watchfiles.main:1 change detected
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO:main:✅ FastAPI 브릿지가 정상적으로 종료되었습니다
INFO: Application shutdown complete.
INFO: Finished server process [64979]
✅ Redis 연결 성공
INFO: Stopping reloader process [59893]

View File

@@ -127,7 +127,7 @@ async def health_check():
"fastapi_bridge": "healthy",
"express_api": express_status,
"express_data": express_data,
"timestamp": datetime.datetime.utcnow().isoformat() + "Z",
"timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat(),
"cached": True
}

View File

@@ -1,16 +0,0 @@
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:54: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("startup")
/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge/main.py:83: DeprecationWarning:
on_event is deprecated, use lifespan event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
@app.on_event("shutdown")
INFO: Will watch for changes in these directories: ['/Users/hyungiahn/Documents/code/TK-FB-Project/fastapi-bridge']
ERROR: [Errno 48] Address already in use

View File

@@ -18,8 +18,7 @@ async def create_issue(
current_user: User = Depends(get_current_user),
db: Session = Depends(get_db)
):
print(f"DEBUG: 받은 issue 데이터: {issue}")
print(f"DEBUG: project_id: {issue.project_id}")
# 이미지 저장 (최대 5장)
photo_paths = {}
for i in range(1, 6):
@@ -194,7 +193,6 @@ async def delete_issue(
# 이 이슈를 중복 대상으로 참조하는 다른 이슈들의 참조 제거
referencing_issues = db.query(Issue).filter(Issue.duplicate_of_issue_id == issue_id).all()
if referencing_issues:
print(f"DEBUG: {len(referencing_issues)}개의 이슈가 이 이슈를 중복 대상으로 참조하고 있습니다. 참조를 제거합니다.")
for ref_issue in referencing_issues:
ref_issue.duplicate_of_issue_id = None
db.flush() # 참조 제거를 먼저 커밋
@@ -317,10 +315,6 @@ async def update_issue_management(
"""
관리함에서 이슈의 관리 관련 필드들을 업데이트합니다.
"""
print(f"DEBUG: Received management update for issue {issue_id}")
print(f"DEBUG: Update data: {management_update}")
print(f"DEBUG: Current user: {current_user.username}")
# 관리함 페이지 권한 확인
if not (current_user.role == UserRole.admin or check_page_access(current_user.id, 'issues_management', db)):
raise HTTPException(status_code=403, detail="관리함 접근 권한이 없습니다.")
@@ -330,12 +324,8 @@ async def update_issue_management(
if not issue:
raise HTTPException(status_code=404, detail="부적합을 찾을 수 없습니다.")
print(f"DEBUG: Found issue: {issue.id}")
# 관리함에서만 수정 가능한 필드들만 업데이트
update_data = management_update.dict(exclude_unset=True)
print(f"DEBUG: Update data dict: {update_data}")
# 완료 사진 처리 (최대 5장)
completion_photo_fields = []
for i in range(1, 6):
@@ -353,28 +343,21 @@ async def update_issue_management(
# 새 사진 저장
new_path = save_base64_image(update_data[photo_field], "completion")
setattr(issue, path_field, new_path)
print(f"DEBUG: Saved {photo_field}: {new_path}")
except Exception as e:
print(f"DEBUG: Photo save error for {photo_field}: {str(e)}")
raise HTTPException(status_code=400, detail=f"완료 사진 저장 실패: {str(e)}")
# 나머지 필드 처리 (완료 사진 제외)
for field, value in update_data.items():
if field not in completion_photo_fields:
print(f"DEBUG: Processing field {field} = {value}")
try:
setattr(issue, field, value)
print(f"DEBUG: Set {field} = {value}")
except Exception as e:
print(f"DEBUG: Field set error for {field}: {str(e)}")
raise HTTPException(status_code=400, detail=f"필드 {field} 설정 실패: {str(e)}")
try:
db.commit()
db.refresh(issue)
print(f"DEBUG: Successfully updated issue {issue.id}")
except Exception as e:
print(f"DEBUG: Database commit error: {str(e)}")
db.rollback()
raise HTTPException(status_code=500, detail=f"데이터베이스 저장 실패: {str(e)}")
@@ -408,8 +391,6 @@ async def request_completion(
raise HTTPException(status_code=400, detail="이미 완료 신청된 부적합입니다.")
try:
print(f"DEBUG: 완료 신청 시작 - Issue ID: {issue_id}, User: {current_user.username}")
# 완료 사진 저장 (최대 5장)
saved_paths = []
for i in range(1, 6):
@@ -418,25 +399,20 @@ async def request_completion(
photo_data = getattr(request, photo_field, None)
if photo_data:
print(f"DEBUG: {photo_field} 저장 시작")
saved_path = save_base64_image(photo_data, "completion")
if saved_path:
setattr(issue, path_field, saved_path)
saved_paths.append(saved_path)
print(f"DEBUG: {photo_field} 저장 완료 - Path: {saved_path}")
else:
raise Exception(f"{photo_field} 저장에 실패했습니다.")
# 완료 신청 정보 업데이트
print(f"DEBUG: DB 업데이트 시작")
issue.completion_requested_at = datetime.now()
issue.completion_requested_by_id = current_user.id
issue.completion_comment = request.completion_comment
db.commit()
db.refresh(issue)
print(f"DEBUG: DB 업데이트 완료")
return {
"message": "완료 신청이 성공적으로 제출되었습니다.",
"issue_id": issue.id,
@@ -480,8 +456,6 @@ async def reject_completion_request(
raise HTTPException(status_code=403, detail="완료 반려 권한이 없습니다.")
try:
print(f"DEBUG: 완료 반려 시작 - Issue ID: {issue_id}, User: {current_user.username}")
# 완료 사진 파일 삭제 (최대 5장)
for i in range(1, 6):
path_field = f"completion_photo_path{i if i > 1 else ''}"
@@ -489,9 +463,8 @@ async def reject_completion_request(
if photo_path:
try:
delete_file(photo_path)
print(f"DEBUG: {path_field} 삭제 완료")
except Exception as e:
print(f"WARNING: {path_field} 삭제 실패 - {str(e)}")
except Exception:
pass
# 완료 신청 정보 초기화
issue.completion_requested_at = None
@@ -511,8 +484,6 @@ async def reject_completion_request(
db.commit()
db.refresh(issue)
print(f"DEBUG: 완료 반려 처리 완료")
return {
"message": "완료 신청이 반려되었습니다.",
"issue_id": issue.id,