Skip to content

Commit

Permalink
🐛 fix: Correctly retrieve user image in GetClassUserInfo
Browse files Browse the repository at this point in the history
Resolved an issue where the user's image was not being fetched correctly by joining the User table in the GetClassUserInfo method. The join ensures that all required user details, including the image, are correctly loaded and returned within the ClassMemberDTO.

Related issue: #212
  • Loading branch information
yuminn-k committed Apr 22, 2024
1 parent cdde34b commit 04988f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion repositories/class_user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewClassUserRepository(db *gorm.DB) ClassUserRepository {
// GetClassUserInfo はユーザーのクラスユーザー情報を取得します。
func (r *classUserRepository) GetClassUserInfo(uid uint, cid uint) (dto.ClassMemberDTO, error) {
var classUser models.ClassUser
err := r.db.Where("uid = ? AND cid = ?", uid, cid).First(&classUser).Error
err := r.db.Joins("User").Where("class_users.uid = ? AND class_users.cid = ?", uid, cid).First(&classUser).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return dto.ClassMemberDTO{}, errors.New(constants.UserNotFound)
Expand Down

0 comments on commit 04988f7

Please sign in to comment.