Skip to content

Commit

Permalink
feat: invitation code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky committed Jul 16, 2024
1 parent cbbefbc commit 18c4767
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/service/user/invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type InvitationGenResponse struct {
InvitationCode string `json:"invitation_code"`
}

type InvitationMeResponse []cache.UserInvitation

// InvitationGen 生成邀请码 (POST /invitation/gen)
func InvitationGen(c *gin.Context) {
userID, _ := resp.GetUserIDFromGinContext(c)
Expand Down Expand Up @@ -50,6 +52,10 @@ func InvitationMe(c *gin.Context) {
return
}

resp.OKWithData(c, codeList)
if len(codeList) == 0 {
resp.OKWithData(c, InvitationMeResponse{})
} else {
resp.OKWithData(c, InvitationMeResponse(codeList))
}
log.Logger.Infof("User %d got invitation code list successfully!", userID)
}

0 comments on commit 18c4767

Please sign in to comment.