Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetAttendanceByIDメソッドの修正: すべての出席データを取得するように変更 #332

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions repositories/attendance_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package repositories
import (
"github.com/YJU-OKURA/project_minori-gin-deployment-repo/models"
"gorm.io/gorm"
"log"
)

// AttendanceRepository インタフェース
Expand Down Expand Up @@ -41,20 +40,17 @@ func (repo *attendanceRepository) GetAttendanceByUIDAndCID(uid uint, cid uint) (
// GetAllAttendancesByCID CIDによって全ての出席情報を取得
func (repo *attendanceRepository) GetAllAttendancesByCID(cid uint) ([]models.Attendance, error) {
var attendances []models.Attendance
log.Printf("GetAllAttendancesByCID: Executing query for cid %d", cid)
err := repo.db.Where("cid = ?", cid).Find(&attendances).Error
if err != nil {
log.Printf("GetAllAttendancesByCID: Query error: %v", err)
return nil, err
}
log.Printf("GetAllAttendancesByCID: Query successful, found %d attendances", len(attendances))
return attendances, err
}

// GetAttendanceByID IDによって出席情報を取得
func (repo *attendanceRepository) GetAttendanceByID(id string) (*models.Attendance, error) {
var attendance models.Attendance
err := repo.db.Where("csid = ?", id).First(&attendance).Error
err := repo.db.Where("csid = ?", id).Find(&attendance).Error
return &attendance, err
}

yuminn-k marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading