From 18c4767aec56940488dd65947ec8faa0cccfb8e3 Mon Sep 17 00:00:00 2001 From: Tohrusky <65994850+Tohrusky@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:29:03 +0800 Subject: [PATCH] feat: invitation code --- internal/service/user/invitation.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/service/user/invitation.go b/internal/service/user/invitation.go index a8c5c94..12dd145 100644 --- a/internal/service/user/invitation.go +++ b/internal/service/user/invitation.go @@ -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) @@ -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) }