Conversation
There was a problem hiding this comment.
Pull request overview
本PRは、スキーマ更新に合わせて「科目(Subject)中心のモデル」へ寄せ、シラバス(Syllabus)参照・科目一覧フィルタ・Upsert 等のAPI実装を追加しつつ、旧来の Course/Faculty/SubjectCategory/DayOfWeekTimetableSlot 関連のドメイン/リポジトリ/サービスを削除する変更です。
Changes:
- Subject のスキーマ/ドメインを更新し、一覧取得にフィルタ条件(ids/q/year/semester/grade/class/courses/requirementType 等)を導入
- Syllabus のドメイン/DBモデル/Repository を新規追加し、
/v1/subjects/{id}/syllabusを実装 POST /v1/subjectsの Upsert を追加(現状 Syllabus→Subject 導出はスタブ)し、旧リソース群を削除
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/service/subject_category.go | 旧 SubjectCategoryService を削除 |
| internal/service/subject.go | SubjectService をフィルタ対応/Upsert/GetSyllabus に更新 |
| internal/service/faculty.go | 旧 FacultyService を削除 |
| internal/service/day_of_week_timetable_slot.go | 旧 DayOfWeekTimetableSlotService を削除 |
| internal/service/course.go | 旧 CourseService を削除 |
| internal/repository/syllabus.go | SyllabusRepository を新規追加 |
| internal/repository/subject_category.go | 旧 SubjectCategoryRepository を削除 |
| internal/repository/subject.go | Subject の preload/フィルタ/Upsert向け取得・関連更新方式を更新 |
| internal/repository/faculty.go | 旧 FacultyRepository を削除 |
| internal/repository/day_of_week_timetable_slot.go | 旧 DayOfWeekTimetableSlotRepository を削除 |
| internal/repository/course.go | 旧 CourseRepository を削除 |
| internal/handler/syllabus_detail.go | Syllabus 詳細取得ハンドラを追加 |
| internal/handler/subject_upsert.go | Subject Upsert ハンドラを追加 |
| internal/handler/subject_list.go | Subject 一覧ハンドラ(フィルタ組み立て)を追加 |
| internal/handler/subject_detail.go | Subject 詳細ハンドラを分割追加 |
| internal/handler/subject_delete.go | Subject 削除ハンドラを分割追加 |
| internal/handler/subject.go | 旧ハンドラ集約ファイルを削除 |
| internal/handler/handler.go | subjectService IF を Upsert/GetSyllabus/フィルタ対応に更新 |
| internal/handler/converter.go | Subject/Syllabus のAPI変換とフィルタビルドを追加 |
| internal/domain/syllabus.go | Syllabus ドメインを新規追加 |
| internal/domain/subject_category.go | 旧 SubjectCategory ドメインを削除 |
| internal/domain/subject.go | Subject を新スキーマ(Faculties/Year/Credit等)+フィルタ型追加 |
| internal/domain/foundation.go | enum 定義を新APIスキーマに合わせて更新(CourseType等) |
| internal/domain/faculty.go | 旧 Faculty ドメインを削除 |
| internal/domain/day_of_week_timetable_slot.go | 旧 DayOfWeekTimetableSlot ドメインを削除 |
| internal/domain/course.go | 旧 Course ドメインを削除 |
| internal/database/syllabus.go | syllabi テーブル用モデル/変換を新規追加 |
| internal/database/subject_category.go | 旧 subject_categories テーブルモデルを削除 |
| internal/database/subject.go | subjects テーブル構造/関連(SubjectFaculty等)を更新 |
| internal/database/migrate.go | AutoMigrate 対象テーブルを更新 |
| internal/database/faculty.go | 旧 faculties テーブルモデルを削除 |
| internal/database/day_of_week_timetable_slot.go | 旧 timetable slots テーブルモデルを削除 |
| internal/database/course.go | 旧 courses テーブルモデルを削除 |
| cmd/server/main.go | SyllabusRepository をDIし SubjectService のコンストラクタ引数を更新 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SubjectID string `gorm:"type:uuid;not null;index"` | ||
| FacultyID string `gorm:"type:uuid;not null"` | ||
| IsPrimary bool `gorm:"not null"` | ||
| } |
There was a problem hiding this comment.
Subject, Faculty, Timetable, Course, Facility くらいまではまとめてもいい気もしてきた
まとめてもいい気がする
There was a problem hiding this comment.
とりあえず、TypeSpec書いてみます
今後のために、境界線の引き方を明確にしたい
There was a problem hiding this comment.
分けないのがデフォルトで分ける際の条件を考えるのがいい気がする
There was a problem hiding this comment.
これが難しいなどういうルールにするか
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # internal/database/course.go # internal/database/day_of_week_timetable_slot.go # internal/database/faculty.go # internal/database/subject_category.go # internal/handler/converter.go # internal/handler/subject.go # internal/repository/course.go # internal/repository/day_of_week_timetable_slot.go # internal/repository/faculty.go # internal/repository/subject_category.go # internal/service/course.go # internal/service/day_of_week_timetable_slot.go # internal/service/faculty.go # internal/service/subject.go # internal/service/subject_category.go
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| if filter.Q != nil { | ||
| // TODO: filter.Q に含まれる LIKE ワイルドカード文字(%, _)をエスケープする。現状ユーザー入力がそのまま LIKE パターンに埋め込まれる。 | ||
| query = query.Where("name ILIKE ?", "%"+*filter.Q+"%") | ||
| } |
| func AutoMigrate(db *gorm.DB) error { | ||
| return db.AutoMigrate( | ||
| &Course{}, | ||
| &Faculty{}, | ||
| &SubjectCategory{}, | ||
| &DayOfWeekTimetableSlot{}, | ||
| &Syllabus{}, | ||
| &Subject{}, | ||
| &SubjectFaculty{}, | ||
| &SubjectEligibleAttribute{}, | ||
| &SubjectRequirement{}, | ||
| ) |
| subject, err := h.subjectSvc.Upsert(ctx, request.Body.SyllabusId) | ||
| if err != nil { | ||
| return nil, err |
| // Upsert はシラバスIDからシラバスを取得し、Subjectを導出して作成または更新する。 | ||
| // TODO: Syllabus -> Subject 導出ロジックの詳細実装。現在はスタブ。 | ||
| func (s *SubjectService) Upsert(ctx context.Context, syllabusID string) (domain.Subject, error) { | ||
| syllabus, err := s.syllabusRepo.GetByID(ctx, syllabusID) | ||
| if err != nil { | ||
| return domain.Subject{}, err | ||
| } | ||
|
|
||
| func (s *SubjectService) Update(ctx context.Context, id string, subject domain.Subject) (domain.Subject, error) { | ||
| subject.ID = id | ||
| return s.repo.Update(ctx, subject) | ||
| subject := deriveSubjectFromSyllabus(syllabus) | ||
| return s.repo.Upsert(ctx, subject) | ||
| } |
| // TODO: Classification フィルタの実装(syllabi テーブルの classifications カラムを JOIN して絞り込む) | ||
| // TODO: CulturalSubjectCategory フィルタの実装 | ||
|
|
| if params.Year != nil { | ||
| filter.Year = params.Year | ||
| } else { | ||
| // デフォルトで今年度を設定 | ||
| // TODO: このデフォルト値設定のロジックは service 層に移すべき。 | ||
| // また、日本の大学の年度は4月始まりのため、1〜3月は前年度を返す必要がある。 | ||
| currentYear := time.Now().Year() | ||
| filter.Year = ¤tYear | ||
| } |
フィルタ周りとUpsertまだ実装できてない(TODOにしてある)けど一旦マージしようかな
↑について検討しましょう