Skip to content

Commit

Permalink
feat: constraint one course to (code_id, year, semester)
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Jun 23, 2024
1 parent 18743b4 commit 7796dda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion danke/api/course.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ func AddCourseV1(c *fiber.Ctx) (err error) {

// 查找课程
var course *Course
err = DB.First(&course, "code_id = ?", request.CodeID).Error
err = DB.
Where("code_id = ?", request.CodeID).
Where("year = ?", request.Year).
Where("semester = ?", request.Semester).
First(&course).Error
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
Expand Down

0 comments on commit 7796dda

Please sign in to comment.