- Add main application files (main.py, models.py, schemas.py, etc.) - Add routers for all features (waiting, attendance, members, etc.) - Add HTML templates for admin and user interfaces - Add migration scripts and utility files - Add Docker configuration - Add documentation files - Add .gitignore to exclude database and cache files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
180 lines
6.5 KiB
Markdown
180 lines
6.5 KiB
Markdown
# 평일/주말 클래스 구분 작업 완료 보고서
|
|
|
|
## 작업 일시
|
|
2025-12-04
|
|
|
|
## 작업 내용
|
|
|
|
### 1. 데이터베이스 구분 확인 및 마이그레이션 ✅
|
|
|
|
#### 데이터베이스 스키마 확인
|
|
- `class_info` 테이블에 `class_type` 컬럼이 이미 존재하며 정상 작동 중
|
|
- `class_type` 가능한 값: 'weekday' (평일), 'weekend' (주말), 'all' (전체)
|
|
- `weekday_schedule` JSON 컬럼으로 각 요일별 운영 여부 저장
|
|
|
|
#### 기존 데이터 변환
|
|
기존에 모든 클래스가 'all' 타입으로 저장되어 있어 평일/주말 구분이 불명확했습니다.
|
|
|
|
**마이그레이션 실행 결과:**
|
|
```
|
|
✅ 5개의 클래스를 'all' → 'weekday'로 변환 완료
|
|
📊 변환 후 클래스 타입별 개수:
|
|
- 평일: 17개
|
|
- 주말: 1개
|
|
```
|
|
|
|
**데이터베이스 확인:**
|
|
```sql
|
|
SELECT id, class_number, class_name, class_type, weekday_schedule
|
|
FROM class_info
|
|
LIMIT 5;
|
|
|
|
-- 결과 예시:
|
|
1|1|1교시|weekday|{"mon": true, "tue": true, "wed": true, "thu": true, "fri": true, "sat": false, "sun": false}
|
|
18|1|1교시|weekend|{"mon": false, "tue": false, "wed": false, "thu": false, "fri": false, "sat": true, "sun": true}
|
|
```
|
|
|
|
### 2. 클래스 관리(routers/class_management.py) 확인 ✅
|
|
|
|
클래스 관리 API는 이미 평일/주말 구분을 완벽하게 지원하고 있습니다:
|
|
|
|
#### 클래스 생성 시 (`POST /api/classes/`)
|
|
- `class_type` 파라미터로 평일/주말/전체 선택
|
|
- 같은 매장 내에서 같은 `class_type`과 `class_number` 조합 중복 불가
|
|
- 예: 평일 1교시와 주말 1교시는 별도로 생성 가능
|
|
|
|
```python
|
|
# 중복 체크 로직 (lines 130-141)
|
|
existing = db.query(ClassInfo).filter(
|
|
ClassInfo.store_id == current_store.id,
|
|
ClassInfo.class_number == class_info.class_number,
|
|
ClassInfo.class_type == class_info.class_type # class_type별로 구분
|
|
).first()
|
|
```
|
|
|
|
#### 클래스 목록 조회 시 (`GET /api/classes/`)
|
|
- `class_type` 필터 파라미터 지원
|
|
- 예: `/api/classes/?class_type=weekday` → 평일 클래스만 조회
|
|
- 예: `/api/classes/?class_type=weekend` → 주말 클래스만 조회
|
|
|
|
```python
|
|
# 필터링 로직 (lines 169-171)
|
|
if class_type:
|
|
query = query.filter(ClassInfo.class_type == class_type)
|
|
```
|
|
|
|
#### 클래스 수정 시 (`PUT /api/classes/{class_id}`)
|
|
- `class_type` 변경 가능
|
|
- 변경 시에도 중복 체크 수행
|
|
|
|
### 3. 대기 등록(routers/waiting.py) 확인 ✅
|
|
|
|
대기 등록 시스템은 요일별로 자동으로 적절한 클래스만 배정합니다:
|
|
|
|
#### 요일별 필터링 (`filter_classes_by_weekday()`)
|
|
```python
|
|
def filter_classes_by_weekday(classes: List[ClassInfo], target_date: date) -> List[ClassInfo]:
|
|
"""특정 날짜의 요일에 맞는 클래스만 필터링"""
|
|
weekday = WEEKDAY_MAP[target_date.weekday()]
|
|
filtered_classes = []
|
|
|
|
for cls in classes:
|
|
schedule = parse_weekday_schedule(cls.weekday_schedule)
|
|
if schedule.get(weekday, True): # 해당 요일이 활성화된 클래스만
|
|
filtered_classes.append(cls)
|
|
|
|
return filtered_classes
|
|
```
|
|
|
|
**동작 방식:**
|
|
- 월요일에 대기 등록 → 월요일이 활성화된 클래스만 표시 (주말 클래스 제외)
|
|
- 토요일에 대기 등록 → 토요일이 활성화된 클래스만 표시 (평일 클래스 제외)
|
|
|
|
### 4. UI 개선 (templates/settings.html) ✅
|
|
|
|
#### 클래스 타입 선택 추가
|
|
매장 설정 화면의 클래스 생성/수정 모달에 클래스 타입 선택 드롭다운 추가:
|
|
|
|
```html
|
|
<select id="classType" class="form-control" required>
|
|
<option value="weekday">평일 클래스</option>
|
|
<option value="weekend">주말 클래스</option>
|
|
<option value="all">전체 요일 클래스</option>
|
|
</select>
|
|
```
|
|
|
|
#### 평일/주말 탭 분리 렌더링
|
|
```javascript
|
|
function renderClasses() {
|
|
// 평일 클래스만 평일 탭에 표시
|
|
const weekdayClasses = classes.filter(cls => cls.class_type === 'weekday');
|
|
|
|
// 주말 클래스만 주말 탭에 표시
|
|
const weekendClasses = classes.filter(cls => cls.class_type === 'weekend');
|
|
|
|
// 전체 요일 클래스는 양쪽 탭에 모두 표시 (회색 배지로 구분)
|
|
const allClasses = classes.filter(cls => cls.class_type === 'all');
|
|
}
|
|
```
|
|
|
|
#### 시각적 구분
|
|
- **평일 클래스**: 보라색 배지 "평일 전용"
|
|
- **주말 클래스**: 보라색 배지 "주말 전용"
|
|
- **전체 요일 클래스**: 회색 배지 "전체 요일" (양쪽 탭에 모두 표시)
|
|
|
|
### 5. 현황대기판(routers/waiting_board.py) 수정 ✅
|
|
|
|
Pydantic 검증 오류 수정:
|
|
```python
|
|
def convert_class_to_dict(cls: ClassInfo) -> dict:
|
|
"""ClassInfo 모델 객체를 dict로 변환"""
|
|
return {
|
|
"id": cls.id,
|
|
"class_number": cls.class_number,
|
|
"class_name": cls.class_name,
|
|
# ... 기타 필드 ...
|
|
"weekday_schedule": parse_weekday_schedule(cls.weekday_schedule), # JSON 문자열 → dict 변환
|
|
"class_type": cls.class_type if hasattr(cls, 'class_type') else 'all'
|
|
}
|
|
```
|
|
|
|
## 검증 결과
|
|
|
|
### 데이터베이스 레벨
|
|
```sql
|
|
sqlite> SELECT class_type, COUNT(*) FROM class_info GROUP BY class_type;
|
|
weekday|17
|
|
weekend|1
|
|
```
|
|
✅ 평일 17개, 주말 1개 클래스가 명확히 구분되어 저장됨
|
|
|
|
### API 레벨
|
|
- ✅ 클래스 생성 시 class_type별 중복 체크 정상 작동
|
|
- ✅ 클래스 목록 조회 시 class_type 필터링 정상 작동
|
|
- ✅ 대기 등록 시 요일별 자동 필터링 정상 작동
|
|
|
|
### UI 레벨
|
|
- ✅ 평일 탭에 평일 클래스만 표시
|
|
- ✅ 주말 탭에 주말 클래스만 표시
|
|
- ✅ 전체 요일 클래스는 양쪽에 모두 표시되며 회색으로 구분됨
|
|
|
|
## 결론
|
|
|
|
**사용자 요청사항:**
|
|
> "평일 클래스와 주말 클래스가 UI 화면상으로만 구분을 해 놓고 데이터베이스는 같은 것 같은데 평일 클래스와 주말 클래스를 구분하여 저장 할 수 있게 수정"
|
|
|
|
**작업 결과:**
|
|
1. ✅ 데이터베이스에 `class_type` 컬럼이 존재하며 정상 작동 중
|
|
2. ✅ 기존 'all' 타입 데이터를 'weekday'로 변환하여 구분 명확화
|
|
3. ✅ 클래스 관리 API가 class_type별 완벽한 CRUD 지원
|
|
4. ✅ 대기 등록 시 요일별 자동 필터링 작동
|
|
5. ✅ UI에서 평일/주말 탭 분리 및 시각적 구분
|
|
|
|
**평일/주말 클래스는 UI뿐만 아니라 데이터베이스 레벨에서도 완전히 분리되어 저장되고 관리됩니다.**
|
|
|
|
## 생성된 파일
|
|
|
|
- `migrate_convert_all_to_weekday.py` - 대화형 마이그레이션 스크립트
|
|
- `migrate_convert_all_to_weekday_auto.py` - 자동 실행 마이그레이션 스크립트 (실행 완료)
|
|
- `평일주말_클래스_구분_완료.md` - 본 보고서
|