Skip to content

スキーマのアップデートに伴う実装#11

Merged
masaya-osuga merged 23 commits intomainfrom
impl/schema-update
Mar 15, 2026
Merged

スキーマのアップデートに伴う実装#11
masaya-osuga merged 23 commits intomainfrom
impl/schema-update

Conversation

@masaya-osuga
Copy link
Member

@masaya-osuga masaya-osuga commented Mar 2, 2026

フィルタ周りとUpsertまだ実装できてない(TODOにしてある)けど一旦マージしようかな
↑について検討しましょう

@masaya-osuga masaya-osuga self-assigned this Mar 2, 2026
@masaya-osuga masaya-osuga changed the title Impl/schema update スキーマのアップデートに伴う実装 Mar 2, 2026
@masaya-osuga masaya-osuga marked this pull request as ready for review March 3, 2026 06:59
@masaya-osuga masaya-osuga requested review from a team, Copilot, hikaru-0602 and kantacky March 3, 2026 06:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"`
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ微妙すぎるよね

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうね
でもまあ仕方ないのかなあ

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ん?どこだ...??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24行目の型

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど?どう微妙?

Copy link
Member Author

@masaya-osuga masaya-osuga Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subject, Faculty, Timetable, Course, Facility くらいまではまとめてもいい気もしてきた

まとめてもいい気がする

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

とりあえず、TypeSpec書いてみます
今後のために、境界線の引き方を明確にしたい

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

分けないのがデフォルトで分ける際の条件を考えるのがいい気がする

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どうなったら分けることを考えるべきか

Copy link
Member Author

@masaya-osuga masaya-osuga Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これが難しいなどういうルールにするか

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 07:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings March 3, 2026 07:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@hikaru-0602 hikaru-0602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そんなおかしなところ無いと思う

# 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
Copilot AI review requested due to automatic review settings March 15, 2026 08:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings March 15, 2026 08:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

masaya-osuga and others added 2 commits March 15, 2026 17:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 15, 2026 08:54
@masaya-osuga masaya-osuga merged commit bfebc85 into main Mar 15, 2026
1 check passed
@masaya-osuga masaya-osuga deleted the impl/schema-update branch March 15, 2026 08:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +35 to +38
if filter.Q != nil {
// TODO: filter.Q に含まれる LIKE ワイルドカード文字(%, _)をエスケープする。現状ユーザー入力がそのまま LIKE パターンに埋め込まれる。
query = query.Where("name ILIKE ?", "%"+*filter.Q+"%")
}
Comment on lines 5 to 12
func AutoMigrate(db *gorm.DB) error {
return db.AutoMigrate(
&Course{},
&Faculty{},
&SubjectCategory{},
&DayOfWeekTimetableSlot{},
&Syllabus{},
&Subject{},
&SubjectFaculty{},
&SubjectEligibleAttribute{},
&SubjectRequirement{},
)
Comment on lines +10 to +12
subject, err := h.subjectSvc.Upsert(ctx, request.Body.SyllabusId)
if err != nil {
return nil, err
Comment on lines +38 to 48
// 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)
}
Comment on lines +65 to +67
// TODO: Classification フィルタの実装(syllabi テーブルの classifications カラムを JOIN して絞り込む)
// TODO: CulturalSubjectCategory フィルタの実装

Comment on lines +114 to +122
if params.Year != nil {
filter.Year = params.Year
} else {
// デフォルトで今年度を設定
// TODO: このデフォルト値設定のロジックは service 層に移すべき。
// また、日本の大学の年度は4月始まりのため、1〜3月は前年度を返す必要がある。
currentYear := time.Now().Year()
filter.Year = &currentYear
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants