remove spew

This commit is contained in:
aichy 2022-09-30 14:43:15 +08:00 committed by mingcheng
parent 638aadbded
commit 11170e63d4
3 changed files with 38 additions and 66 deletions

View File

@ -3,7 +3,6 @@ package middleware
import ( import (
"strings" "strings"
"github.com/davecgh/go-spew/spew"
"github.com/segmentfault/answer/internal/schema" "github.com/segmentfault/answer/internal/schema"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -39,12 +38,6 @@ func (am *AuthUserMiddleware) Auth() gin.HandlerFunc {
ctx.Next() ctx.Next()
return return
} }
if token == "888" {
userInfo := &entity.UserCacheInfo{}
userInfo.UserID = "2"
spew.Dump("开发环境 Auth", userInfo)
ctx.Set(ctxUuidKey, userInfo)
} else {
userInfo, err := am.authService.GetUserCacheInfo(ctx, token) userInfo, err := am.authService.GetUserCacheInfo(ctx, token)
if err != nil { if err != nil {
ctx.Next() ctx.Next()
@ -53,7 +46,6 @@ func (am *AuthUserMiddleware) Auth() gin.HandlerFunc {
if userInfo != nil { if userInfo != nil {
ctx.Set(ctxUuidKey, userInfo) ctx.Set(ctxUuidKey, userInfo)
} }
}
ctx.Next() ctx.Next()
} }
} }
@ -67,14 +59,7 @@ func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc {
ctx.Abort() ctx.Abort()
return return
} }
if token == "888" {
userInfo := &entity.UserCacheInfo{}
userInfo.UserID = "2"
spew.Dump("开发环境 MustAuth", userInfo)
ctx.Set(ctxUuidKey, userInfo)
} else {
userInfo, err := am.authService.GetUserCacheInfo(ctx, token) userInfo, err := am.authService.GetUserCacheInfo(ctx, token)
spew.Dump(userInfo, err)
if err != nil || userInfo == nil { if err != nil || userInfo == nil {
handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil) handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)
ctx.Abort() ctx.Abort()
@ -98,7 +83,6 @@ func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc {
return return
} }
ctx.Set(ctxUuidKey, userInfo) ctx.Set(ctxUuidKey, userInfo)
}
ctx.Next() ctx.Next()
} }
} }
@ -111,12 +95,6 @@ func (am *AuthUserMiddleware) CmsAuth() gin.HandlerFunc {
ctx.Abort() ctx.Abort()
return return
} }
if token == "888" {
userInfo := &entity.UserCacheInfo{}
userInfo.UserID = "2"
spew.Dump("开发环境 CmsAuth", userInfo)
ctx.Set(ctxUuidKey, userInfo)
} else {
userInfo, err := am.authService.GetCmsUserCacheInfo(ctx, token) userInfo, err := am.authService.GetCmsUserCacheInfo(ctx, token)
if err != nil { if err != nil {
handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil) handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)
@ -131,7 +109,6 @@ func (am *AuthUserMiddleware) CmsAuth() gin.HandlerFunc {
} }
ctx.Set(ctxUuidKey, userInfo) ctx.Set(ctxUuidKey, userInfo)
} }
}
ctx.Next() ctx.Next()
} }
} }

View File

@ -218,7 +218,6 @@ func (qr *questionRepo) SearchList(ctx context.Context, search *schema.QuestionS
session = session.Limit(search.PageSize, offset) session = session.Limit(search.PageSize, offset)
session = session.Select("question.id,question.user_id,question.title,question.original_text,question.parsed_text,question.status,question.view_count,question.unique_view_count,question.vote_count,question.answer_count,question.collection_count,question.follow_count,question.accepted_answer_id,question.last_answer_id,question.created_at,question.updated_at,question.post_update_time,question.revision_id") session = session.Select("question.id,question.user_id,question.title,question.original_text,question.parsed_text,question.status,question.view_count,question.unique_view_count,question.vote_count,question.answer_count,question.collection_count,question.follow_count,question.accepted_answer_id,question.last_answer_id,question.created_at,question.updated_at,question.post_update_time,question.revision_id")
count, err = session.FindAndCount(&rows) count, err = session.FindAndCount(&rows)
//spew.Dump("search", err, count, rows)
if err != nil { if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
return rows, count, err return rows, count, err

View File

@ -3,7 +3,6 @@ package schema
import ( import (
"encoding/json" "encoding/json"
"github.com/davecgh/go-spew/spew"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/segmentfault/answer/internal/base/validator" "github.com/segmentfault/answer/internal/base/validator"
"github.com/segmentfault/answer/internal/entity" "github.com/segmentfault/answer/internal/entity"
@ -133,7 +132,6 @@ func (r *GetOtherUserInfoByUsernameResp) GetFromUserEntity(userInfo *entity.User
if ok { if ok {
r.Status = statusShow r.Status = statusShow
} }
spew.Dump(userInfo)
if userInfo.MailStatus == entity.EmailStatusToBeVerified { if userInfo.MailStatus == entity.EmailStatusToBeVerified {
statusMsgShow, ok := UserStatusShowMsg[11] statusMsgShow, ok := UserStatusShowMsg[11]
if ok { if ok {
@ -146,8 +144,6 @@ func (r *GetOtherUserInfoByUsernameResp) GetFromUserEntity(userInfo *entity.User
} }
} }
spew.Dump(r)
} }
const ( const (