Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

refactor(notification): remove duplicated code

LinkinStars262ae9bb18a3
diff --git a/internal/controller/notification_controller.go b/internal/controller/notification_controller.go
index 7206fead..f42e9073 100644
--- a/internal/controller/notification_controller.go
+++ b/internal/controller/notification_controller.go
@@ -37,11 +37,7 @@ func NewNotificationController(
// @Success 200 {object} handler.RespBody
// @Router /answer/api/v1/notification/status [get]
func (nc *NotificationController) GetRedDot(ctx *gin.Context) {
-
req := &schema.GetRedDot{}
-
- userID := middleware.GetLoginUserIDFromContext(ctx)
- req.UserID = userID
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
canList, err := nc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
permission.QuestionAudit,
@@ -56,8 +52,8 @@ func (nc *NotificationController) GetRedDot(ctx *gin.Context) {
req.CanReviewAnswer = canList[1]
req.CanReviewTag = canList[2]
- RedDot, err := nc.notificationService.GetRedDot(ctx, req)
- handler.HandleResponse(ctx, err, RedDot)
+ resp, err := nc.notificationService.GetRedDot(ctx, req)
+ handler.HandleResponse(ctx, err, resp)
}
// ClearRedDot