- 토큰 저장 키 통일 (access_token으로 일관성 확보) - 일일공수 페이지 API 스크립트 로딩 순서 수정 - 프로젝트 관리 페이지 비활성 프로젝트 표시 문제 해결 - 업로드 카테고리에 '기타' 항목 추가 (백엔드 schemas.py 포함) - 비밀번호 변경 기능 API 연동으로 수정 - 프로젝트 드롭다운 z-index 문제 해결 - CORS 설정 및 Nginx 구성 개선 - 비밀번호 해싱 방식 pbkdf2_sha256으로 변경 (bcrypt 72바이트 제한 해결)
111 lines
4.0 KiB
Python
111 lines
4.0 KiB
Python
from sqlalchemy import Column, Integer, BigInteger, String, DateTime, Float, Boolean, Text, ForeignKey, Enum
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime, timezone, timedelta
|
|
import enum
|
|
|
|
# 한국 시간대 설정
|
|
KST = timezone(timedelta(hours=9))
|
|
|
|
def get_kst_now():
|
|
"""현재 한국 시간 반환"""
|
|
return datetime.now(KST)
|
|
|
|
Base = declarative_base()
|
|
|
|
class UserRole(str, enum.Enum):
|
|
admin = "admin"
|
|
user = "user"
|
|
|
|
class IssueStatus(str, enum.Enum):
|
|
new = "new"
|
|
progress = "progress"
|
|
complete = "complete"
|
|
|
|
class IssueCategory(str, enum.Enum):
|
|
material_missing = "material_missing"
|
|
design_error = "design_error" # 설계미스 (기존 dimension_defect 대체)
|
|
incoming_defect = "incoming_defect"
|
|
inspection_miss = "inspection_miss" # 검사미스 (신규 추가)
|
|
etc = "etc" # 기타
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String)
|
|
role = Column(Enum(UserRole), default=UserRole.user)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
|
|
# Relationships
|
|
issues = relationship("Issue", back_populates="reporter")
|
|
daily_works = relationship("DailyWork", back_populates="created_by")
|
|
projects = relationship("Project", back_populates="created_by")
|
|
|
|
class Issue(Base):
|
|
__tablename__ = "issues"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
photo_path = Column(String)
|
|
photo_path2 = Column(String) # 두 번째 사진 경로
|
|
category = Column(Enum(IssueCategory), nullable=False)
|
|
description = Column(Text, nullable=False)
|
|
status = Column(Enum(IssueStatus), default=IssueStatus.new)
|
|
reporter_id = Column(Integer, ForeignKey("users.id"))
|
|
project_id = Column(BigInteger, ForeignKey("projects.id"))
|
|
report_date = Column(DateTime, default=get_kst_now)
|
|
work_hours = Column(Float, default=0)
|
|
detail_notes = Column(Text)
|
|
|
|
# Relationships
|
|
reporter = relationship("User", back_populates="issues")
|
|
project = relationship("Project", back_populates="issues")
|
|
|
|
class Project(Base):
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(BigInteger, primary_key=True, index=True)
|
|
job_no = Column(String, unique=True, nullable=False, index=True)
|
|
project_name = Column(String, nullable=False)
|
|
created_by_id = Column(Integer, ForeignKey("users.id"))
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# Relationships
|
|
created_by = relationship("User", back_populates="projects")
|
|
issues = relationship("Issue", back_populates="project")
|
|
|
|
class DailyWork(Base):
|
|
__tablename__ = "daily_works"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
date = Column(DateTime, nullable=False, index=True)
|
|
worker_count = Column(Integer, nullable=False)
|
|
regular_hours = Column(Float, nullable=False)
|
|
overtime_workers = Column(Integer, default=0)
|
|
overtime_hours = Column(Float, default=0)
|
|
overtime_total = Column(Float, default=0)
|
|
total_hours = Column(Float, nullable=False)
|
|
created_by_id = Column(Integer, ForeignKey("users.id"))
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
|
|
# Relationships
|
|
created_by = relationship("User", back_populates="daily_works")
|
|
|
|
class ProjectDailyWork(Base):
|
|
__tablename__ = "project_daily_works"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
date = Column(DateTime, nullable=False, index=True)
|
|
project_id = Column(BigInteger, ForeignKey("projects.id"), nullable=False)
|
|
hours = Column(Float, nullable=False)
|
|
created_by_id = Column(Integer, ForeignKey("users.id"))
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
|
|
# Relationships
|
|
project = relationship("Project")
|
|
created_by = relationship("User")
|