Skip to content

Commit

Permalink
댓글 모델 필드 타입 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
in-jun committed May 21, 2024
1 parent e0f6ed4 commit 41b1c04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ GitHub 프로필에 댓글 기능을 추가하여 사용자들이 프로필에
erDiagram
GITHUBUSER {
uint ID PK
string GitHubID "GitHub OAuth에서 받아온 깃허브ID"
string GitHubLogin "GitHub 사용자 로그인"
float64 GitHubID "GitHub OAuth에서 받아온 깃허브ID"
string GitHubLogin "GitHub 사용자 로그인 아이디"
}

COMMENT {
Expand Down
26 changes: 13 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func init() {
}

type GitHubUser struct {
ID uint `gorm:"primary_key"`
GitHubID int `json:"github_id"`
GitHubLogin string `json:"github_login"`
ID uint `gorm:"primary_key"`
GitHubID float64 `json:"github_id"`
GitHubLogin string `json:"github_login"`
}

type Comment struct {
Expand Down Expand Up @@ -133,7 +133,7 @@ func handleMain(c *gin.Context) {
githubID := session.Get("github_id")
if githubID != nil {
c.JSON(http.StatusOK, gin.H{
"user_id": githubID.(string),
"user_id": githubID.(float64),
"logged_in": true,
})
} else {
Expand Down Expand Up @@ -171,7 +171,7 @@ func createComment(c *gin.Context) {
}

var author GitHubUser
if err := db.Where(&GitHubUser{GitHubLogin: authorID.(string)}).First(&author).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: authorID.(float64)}).First(&author).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -260,7 +260,7 @@ func deleteComment(c *gin.Context) {
}

var author GitHubUser
if err := db.Where(&GitHubUser{GitHubLogin: authorID.(string)}).First(&author).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: authorID.(float64)}).First(&author).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -363,7 +363,7 @@ func handleCallback(c *gin.Context) {
}

githubLogin, ok1 := user["login"].(string)
githubID, ok2 := user["id"].(int)
githubID, ok2 := user["id"].(float64)
if !ok1 || !ok2 {
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to get GitHub user info"))
return
Expand Down Expand Up @@ -440,7 +440,7 @@ func likeComment(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -495,7 +495,7 @@ func removeLike(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -540,7 +540,7 @@ func dislikeComment(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -595,7 +595,7 @@ func removeDislike(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -640,7 +640,7 @@ func ownerLikeComment(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down Expand Up @@ -690,7 +690,7 @@ func ownerRemoveLike(c *gin.Context) {
}

var gitHubUser GitHubUser
if err := db.Where(&GitHubUser{GitHubID: userID.(int)}).First(&gitHubUser).Error; err != nil {
if err := db.Where(&GitHubUser{GitHubID: userID.(float64)}).First(&gitHubUser).Error; err != nil {
c.JSON(401, gin.H{"error": "Unauthorized"})
return
}
Expand Down

0 comments on commit 41b1c04

Please sign in to comment.