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.
Running gofumpt against repo (#49)
Tai Groot59e2e1f304f9
diff --git a/cmd/answer/command.go b/cmd/answer/command.goindex fd9d8f3b..d0efb0ab 100644--- a/cmd/answer/command.go+++ b/cmd/answer/command.go@@ -48,7 +48,7 @@ To run answer, use:Use: "run",Short: "Run the application",Long: `Run the application`,- Run: func(cmd *cobra.Command, args []string) {+ Run: func(_ *cobra.Command, _ []string) {runApp()},}@@ -58,7 +58,7 @@ To run answer, use:Use: "init",Short: "init answer application",Long: `init answer application`,- Run: func(cmd *cobra.Command, args []string) {+ Run: func(_ *cobra.Command, _ []string) {cli.InstallAllInitialEnvironment(dataDirPath)c, err := readConfig()if err != nil {@@ -79,7 +79,7 @@ To run answer, use:Use: "upgrade",Short: "upgrade Answer version",Long: `upgrade Answer version`,- Run: func(cmd *cobra.Command, args []string) {+ Run: func(_ *cobra.Command, _ []string) {c, err := readConfig()if err != nil {fmt.Println("read config failed: ", err.Error())@@ -98,7 +98,7 @@ To run answer, use:Use: "dump",Short: "back up data",Long: `back up data`,- Run: func(cmd *cobra.Command, args []string) {+ Run: func(_ *cobra.Command, _ []string) {fmt.Println("Answer is backing up data")c, err := readConfig()if err != nil {@@ -119,7 +119,7 @@ To run answer, use:Use: "check",Short: "checking the required environment",Long: `Check if the current environment meets the startup requirements`,- Run: func(cmd *cobra.Command, args []string) {+ Run: func(_ *cobra.Command, _ []string) {fmt.Println("Start checking the required environment...")if cli.CheckConfigFile(configFilePath) {fmt.Println("config file exists [✔]")diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.goindex cc83240d..0d87b7f0 100644--- a/cmd/answer/wire_gen.go+++ b/cmd/answer/wire_gen.go@@ -67,7 +67,7 @@ import (// Injectors from wire.go:// initApplication init application.-func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, cacheConf *data.CacheConf, i18nConf *translator.I18n, swaggerConf *router.SwaggerConfig, serviceConf *service_config.ServiceConfig, logConf log.Logger) (*pacman.Application, func(), error) {+func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, cacheConf *data.CacheConf, i18nConf *translator.I18n, swaggerConf *router.SwaggerConfig, serviceConf *service_config.ServiceConfig, _ log.Logger) (*pacman.Application, func(), error) {staticRouter := router.NewStaticRouter(serviceConf)i18nTranslator, err := translator.NewTranslator(i18nConf)if err != nil {diff --git a/internal/base/constant/constant.go b/internal/base/constant/constant.goindex 9ccd519a..7722adf8 100644--- a/internal/base/constant/constant.go+++ b/internal/base/constant/constant.go@@ -3,7 +3,7 @@ package constantimport "time"const (- Default_PageSize = 20 //Default number of pages+ DefaultPageSize = 20 // Default number of pagesUserStatusChangedCacheKey = "answer:user:status:"UserStatusChangedCacheTime = 7 * 24 * time.HourUserTokenCacheKey = "answer:user:token:"diff --git a/internal/base/constant/report.go b/internal/base/constant/report.goindex 4bcca92f..28a8548e 100644--- a/internal/base/constant/report.go+++ b/internal/base/constant/report.go@@ -13,7 +13,7 @@ const (ReportNotAnswerDescription = "report.not_answer.description"ReportNotNeedName = "report.not_need.name"ReportNotNeedDescription = "report.not_need.description"- //question close+ // question closeQuestionCloseDuplicateName = "question.close.duplicate.name"QuestionCloseDuplicateDescription = "question.close.duplicate.description"QuestionCloseGuidelineName = "question.close.guideline.name"@@ -27,8 +27,8 @@ const (const (// TODO put this in database// TODO need reason controller to resolve- QuestionCloseJson = `[{"name":"question.close.duplicate.name","description":"question.close.duplicate.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"question.close.guideline.name","description":"question.close.guideline.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"question.close.multiple.name","description":"question.close.multiple.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"question.close.other.name","description":"question.close.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`- QuestionReportJson = `[{"name":"report.spam.name","description":"report.spam.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"report.duplicate.name","description":"report.duplicate.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`- AnswerReportJson = `[{"name":"report.spam.name","description":"report.spam.description","source":"answer","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"answer","type":2,"have_content":false,"content_type":""},{"name":"report.not_answer.name","description":"report.not_answer.description","source":"answer","type":3,"have_content":false,"content_type":""},{"name":"report.other.name","description":"report.other.description","source":"answer","type":4,"have_content":true,"content_type":"textarea"}]`- CommentReportJson = `[{"name":"report.spam.name","description":"report.spam.description","source":"comment","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"comment","type":2,"have_content":false,"content_type":""},{"name":"report.not_need.name","description":"report.not_need.description","source":"comment","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"comment","type":4,"have_content":true,"content_type":"textarea"}]`+ QuestionCloseJSON = `[{"name":"question.close.duplicate.name","description":"question.close.duplicate.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"question.close.guideline.name","description":"question.close.guideline.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"question.close.multiple.name","description":"question.close.multiple.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"question.close.other.name","description":"question.close.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`+ QuestionReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"question","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"question","type":2,"have_content":false,"content_type":""},{"name":"report.duplicate.name","description":"report.duplicate.description","source":"question","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"question","type":4,"have_content":true,"content_type":"textarea"}]`+ AnswerReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"answer","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"answer","type":2,"have_content":false,"content_type":""},{"name":"report.not_answer.name","description":"report.not_answer.description","source":"answer","type":3,"have_content":false,"content_type":""},{"name":"report.other.name","description":"report.other.description","source":"answer","type":4,"have_content":true,"content_type":"textarea"}]`+ CommentReportJSON = `[{"name":"report.spam.name","description":"report.spam.description","source":"comment","type":1,"have_content":false,"content_type":""},{"name":"report.rude.name","description":"report.rude.description","source":"comment","type":2,"have_content":false,"content_type":""},{"name":"report.not_need.name","description":"report.not_need.description","source":"comment","type":3,"have_content":true,"content_type":"text"},{"name":"report.other.name","description":"report.other.description","source":"comment","type":4,"have_content":true,"content_type":"textarea"}]`)diff --git a/internal/base/handler/handler.go b/internal/base/handler/handler.goindex 2fde62de..3b4a5b65 100644--- a/internal/base/handler/handler.go+++ b/internal/base/handler/handler.go@@ -40,7 +40,6 @@ func HandleResponse(ctx *gin.Context, err error, data interface{}) {respBody.Data = data}ctx.JSON(myErr.Code, respBody)- return}// BindAndCheck bind request and checkdiff --git a/internal/base/middleware/auth.go b/internal/base/middleware/auth.goindex cf9c8730..813effe3 100644--- a/internal/base/middleware/auth.go+++ b/internal/base/middleware/auth.go@@ -14,9 +14,7 @@ import ("github.com/segmentfault/pacman/errors")-var (- ctxUuidKey = "ctxUuidKey"-)+var ctxUUIDKey = "ctxUuidKey"// AuthUserMiddleware auth user middlewaretype AuthUserMiddleware struct {@@ -44,7 +42,7 @@ func (am *AuthUserMiddleware) Auth() gin.HandlerFunc {return}if userInfo != nil {- ctx.Set(ctxUuidKey, userInfo)+ ctx.Set(ctxUUIDKey, userInfo)}ctx.Next()}@@ -82,7 +80,7 @@ func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc {ctx.Abort()return}- ctx.Set(ctxUuidKey, userInfo)+ ctx.Set(ctxUUIDKey, userInfo)ctx.Next()}}@@ -107,7 +105,7 @@ func (am *AuthUserMiddleware) CmsAuth() gin.HandlerFunc {ctx.Abort()return}- ctx.Set(ctxUuidKey, userInfo)+ ctx.Set(ctxUUIDKey, userInfo)}ctx.Next()}@@ -115,7 +113,7 @@ func (am *AuthUserMiddleware) CmsAuth() gin.HandlerFunc {// GetLoginUserIDFromContext get user id from contextfunc GetLoginUserIDFromContext(ctx *gin.Context) (userID string) {- userInfo, exist := ctx.Get(ctxUuidKey)+ userInfo, exist := ctx.Get(ctxUUIDKey)if !exist {return ""}@@ -128,7 +126,7 @@ func GetLoginUserIDFromContext(ctx *gin.Context) (userID string) {// GetUserInfoFromContext get user info from contextfunc GetUserInfoFromContext(ctx *gin.Context) (u *entity.UserCacheInfo) {- userInfo, exist := ctx.Get(ctxUuidKey)+ userInfo, exist := ctx.Get(ctxUUIDKey)if !exist {return nil}diff --git a/internal/base/reason/reason.go b/internal/base/reason/reason.goindex fb64cd78..284bb0b3 100644--- a/internal/base/reason/reason.go+++ b/internal/base/reason/reason.go@@ -27,7 +27,7 @@ const (UsernameInvalid = "error.user.username_invalid"UsernameDuplicate = "error.user.username_duplicate"EmailDuplicate = "error.email.duplicate"- EmailVerifyUrlExpired = "error.email.verify_url_expired"+ EmailVerifyURLExpired = "error.email.verify_url_expired"EmailNeedToBeVerified = "error.email.need_to_be_verified"UserSuspended = "error.user.suspended"ObjectNotFound = "error.object.not_found"diff --git a/internal/base/validator/validator.go b/internal/base/validator/validator.goindex 9695af17..4a0f22b1 100644--- a/internal/base/validator/validator.go+++ b/internal/base/validator/validator.go@@ -9,7 +9,7 @@ import ("github.com/go-playground/locales"english "github.com/go-playground/locales/en"zhongwen "github.com/go-playground/locales/zh"- "github.com/go-playground/universal-translator"+ ut "github.com/go-playground/universal-translator""github.com/go-playground/validator/v10""github.com/go-playground/validator/v10/translations/en""github.com/go-playground/validator/v10/translations/zh"@@ -31,10 +31,8 @@ type ErrorField struct {Value string `json:"value"`}-var (- // GlobalValidatorMapping is a mapping from validator to translator used- GlobalValidatorMapping = make(map[string]*MyValidator, 0)-)+// GlobalValidatorMapping is a mapping from validator to translator used+var GlobalValidatorMapping = make(map[string]*MyValidator, 0)func init() {zhTran, zhVal := getTran(zhongwen.New(), i18n.LanguageChinese.Abbr()), createDefaultValidator(i18n.LanguageChinese)diff --git a/internal/cli/install.go b/internal/cli/install.goindex 34da2e5a..8c8ee64f 100644--- a/internal/cli/install.go+++ b/internal/cli/install.go@@ -31,7 +31,6 @@ func InstallAllInitialEnvironment(dataDirPath string) {installUploadDir()installI18nBundle()fmt.Println("install all initial environment done")- return}func installConfigFile() {@@ -96,7 +95,7 @@ func installI18nBundle() {}func writerFile(filePath, content string) error {- file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0666)+ file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0o666)if err != nil {return err}diff --git a/internal/controller/answer_controller.go b/internal/controller/answer_controller.goindex 1223b037..43ea51a5 100644--- a/internal/controller/answer_controller.go+++ b/internal/controller/answer_controller.go@@ -62,9 +62,9 @@ func (ac *AnswerController) RemoveAnswer(ctx *gin.Context) {// @Success 200 {string} string ""func (ac *AnswerController) Get(ctx *gin.Context) {id := ctx.Query("id")- userId := middleware.GetLoginUserIDFromContext(ctx)+ userID := middleware.GetLoginUserIDFromContext(ctx)- info, questionInfo, has, err := ac.answerService.Get(ctx, id, userId)+ info, questionInfo, has, err := ac.answerService.Get(ctx, id, userID)if err != nil {handler.HandleResponse(ctx, err, gin.H{})return@@ -101,18 +101,18 @@ func (ac *AnswerController) Add(ctx *gin.Context) {return}- answerId, err := ac.answerService.Insert(ctx, req)+ answerID, err := ac.answerService.Insert(ctx, req)if err != nil {handler.HandleResponse(ctx, err, nil)return}- info, questionInfo, has, err := ac.answerService.Get(ctx, answerId, req.UserID)+ info, questionInfo, has, err := ac.answerService.Get(ctx, answerID, req.UserID)if err != nil {handler.HandleResponse(ctx, err, nil)return}if !has {- //todo !has+ // todo !hashandler.HandleResponse(ctx, nil, nil)return}@@ -120,7 +120,6 @@ func (ac *AnswerController) Add(ctx *gin.Context) {"info": info,"question": questionInfo,})-}// Update godoc@@ -156,7 +155,7 @@ func (ac *AnswerController) Update(ctx *gin.Context) {return}if !has {- //todo !has+ // todo !hashandler.HandleResponse(ctx, nil, nil)return}diff --git a/internal/controller/question_controller.go b/internal/controller/question_controller.goindex 620f1e41..399f323d 100644--- a/internal/controller/question_controller.go+++ b/internal/controller/question_controller.go@@ -66,7 +66,7 @@ func (qc *QuestionController) CloseQuestion(ctx *gin.Context) {if handler.BindAndCheck(ctx, req) {return}- req.UserId = middleware.GetLoginUserIDFromContext(ctx)+ req.UserID = middleware.GetLoginUserIDFromContext(ctx)err := qc.questionService.CloseQuestion(ctx, req)handler.HandleResponse(ctx, err, nil)}@@ -114,7 +114,6 @@ func (qc *QuestionController) SimilarQuestion(ctx *gin.Context) {"list": list,"count": count,})-}// Index godocdiff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.goindex 390b72ce..086dccdc 100644--- a/internal/controller/user_controller.go+++ b/internal/controller/user_controller.go@@ -35,7 +35,8 @@ func NewUserController(userService *service.UserService,actionService *action.CaptchaService,emailService *export.EmailService,- uploaderService *uploader.UploaderService) *UserController {+ uploaderService *uploader.UploaderService,+) *UserController {return &UserController{authService: authService,userService: userService,@@ -112,7 +113,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {return}- captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecord_Type_Login, ctx.ClientIP(), req.CaptchaID, req.CaptchaCode)+ captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecordTypeLogin, ctx.ClientIP(), req.CaptchaID, req.CaptchaCode)if !captchaPass {resp := schema.UserVerifyEmailErrorResponse{Key: "captcha_code",@@ -125,7 +126,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {resp, err := uc.userService.EmailLogin(ctx, req)if err != nil {- _, _ = uc.actionService.ActionRecordAdd(ctx, schema.ActionRecord_Type_Login, ctx.ClientIP())+ _, _ = uc.actionService.ActionRecordAdd(ctx, schema.ActionRecordTypeLogin, ctx.ClientIP())resp := schema.UserVerifyEmailErrorResponse{Key: "e_mail",Value: "error.object.email_or_password_incorrect",@@ -134,7 +135,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {handler.HandleResponse(ctx, errors.BadRequest(reason.CaptchaVerificationFailed), resp)return}- uc.actionService.ActionRecordDel(ctx, schema.ActionRecord_Type_Login, ctx.ClientIP())+ uc.actionService.ActionRecordDel(ctx, schema.ActionRecordTypeLogin, ctx.ClientIP())handler.HandleResponse(ctx, nil, resp)}@@ -152,7 +153,7 @@ func (uc *UserController) RetrievePassWord(ctx *gin.Context) {if handler.BindAndCheck(ctx, req) {return}- captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecord_Type_Find_Pass, ctx.ClientIP(), req.CaptchaID, req.CaptchaCode)+ captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecordTypeFindPass, ctx.ClientIP(), req.CaptchaID, req.CaptchaCode)if !captchaPass {resp := schema.UserVerifyEmailErrorResponse{Key: "captcha_code",@@ -162,7 +163,7 @@ func (uc *UserController) RetrievePassWord(ctx *gin.Context) {handler.HandleResponse(ctx, errors.BadRequest(reason.CaptchaVerificationFailed), resp)return}- _, _ = uc.actionService.ActionRecordAdd(ctx, schema.ActionRecord_Type_Find_Pass, ctx.ClientIP())+ _, _ = uc.actionService.ActionRecordAdd(ctx, schema.ActionRecordTypeFindPass, ctx.ClientIP())code, err := uc.userService.RetrievePassWord(ctx, req)handler.HandleResponse(ctx, err, code)}@@ -184,13 +185,13 @@ func (uc *UserController) UseRePassWord(ctx *gin.Context) {req.Content = uc.emailService.VerifyUrlExpired(ctx, req.Code)if len(req.Content) == 0 {- handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyUrlExpired),- &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeUrlExpired})+ handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyURLExpired),+ &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeURLExpired})return}resp, err := uc.userService.UseRePassWord(ctx, req)- uc.actionService.ActionRecordDel(ctx, schema.ActionRecord_Type_Find_Pass, ctx.ClientIP())+ uc.actionService.ActionRecordDel(ctx, schema.ActionRecordTypeFindPass, ctx.ClientIP())handler.HandleResponse(ctx, err, resp)}@@ -245,8 +246,8 @@ func (uc *UserController) UserVerifyEmail(ctx *gin.Context) {req.Content = uc.emailService.VerifyUrlExpired(ctx, req.Code)if len(req.Content) == 0 {- handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyUrlExpired),- &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeUrlExpired})+ handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyURLExpired),+ &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeURLExpired})return}@@ -256,7 +257,7 @@ func (uc *UserController) UserVerifyEmail(ctx *gin.Context) {return}- uc.actionService.ActionRecordDel(ctx, schema.ActionRecord_Type_Email, ctx.ClientIP())+ uc.actionService.ActionRecordDel(ctx, schema.ActionRecordTypeEmail, ctx.ClientIP())handler.HandleResponse(ctx, err, resp)}@@ -282,7 +283,7 @@ func (uc *UserController) UserVerifyEmailSend(ctx *gin.Context) {return}- captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecord_Type_Email, ctx.ClientIP(),+ captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecordTypeEmail, ctx.ClientIP(),req.CaptchaID, req.CaptchaCode)if !captchaPass {resp := schema.UserVerifyEmailErrorResponse{@@ -294,7 +295,7 @@ func (uc *UserController) UserVerifyEmailSend(ctx *gin.Context) {return}- uc.actionService.ActionRecordAdd(ctx, schema.ActionRecord_Type_Email, ctx.ClientIP())+ uc.actionService.ActionRecordAdd(ctx, schema.ActionRecordTypeEmail, ctx.ClientIP())err := uc.userService.UserVerifyEmailSend(ctx, userInfo.UserID)handler.HandleResponse(ctx, err, nil)}@@ -314,7 +315,7 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {if handler.BindAndCheck(ctx, req) {return}- req.UserId = middleware.GetLoginUserIDFromContext(ctx)+ req.UserID = middleware.GetLoginUserIDFromContext(ctx)oldPassVerification, err := uc.userService.UserModifyPassWordVerification(ctx, req)if err != nil {@@ -360,7 +361,7 @@ func (uc *UserController) UserUpdateInfo(ctx *gin.Context) {if handler.BindAndCheck(ctx, req) {return}- req.UserId = middleware.GetLoginUserIDFromContext(ctx)+ req.UserID = middleware.GetLoginUserIDFromContext(ctx)err := uc.userService.UpdateInfo(ctx, req)handler.HandleResponse(ctx, err, nil)}@@ -436,7 +437,7 @@ func (uc *UserController) ActionRecord(ctx *gin.Context) {if handler.BindAndCheck(ctx, req) {return}- req.Ip = ctx.ClientIP()+ req.IP = ctx.ClientIP()resp, err := uc.actionService.ActionRecord(ctx, req)handler.HandleResponse(ctx, err, resp)@@ -458,8 +459,8 @@ func (uc *UserController) UserNoticeSet(ctx *gin.Context) {return}- req.UserId = middleware.GetLoginUserIDFromContext(ctx)- resp, err := uc.userService.UserNoticeSet(ctx, req.UserId, req.NoticeSwitch)+ req.UserID = middleware.GetLoginUserIDFromContext(ctx)+ resp, err := uc.userService.UserNoticeSet(ctx, req.UserID, req.NoticeSwitch)handler.HandleResponse(ctx, err, resp)}@@ -500,8 +501,8 @@ func (uc *UserController) UserChangeEmailVerify(ctx *gin.Context) {}req.Content = uc.emailService.VerifyUrlExpired(ctx, req.Code)if len(req.Content) == 0 {- handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyUrlExpired),- &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeUrlExpired})+ handler.HandleResponse(ctx, errors.Forbidden(reason.EmailVerifyURLExpired),+ &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeURLExpired})return}diff --git a/internal/entity/answer_entity.go b/internal/entity/answer_entity.goindex 3666f106..86172ff7 100644--- a/internal/entity/answer_entity.go+++ b/internal/entity/answer_entity.go@@ -3,9 +3,9 @@ package entityimport "time"const (- Answer_Search_OrderBy_Default = "default"- Answer_Search_OrderBy_Time = "updated"- Answer_Search_OrderBy_Vote = "vote"+ AnswerSearchOrderByDefault = "default"+ AnswerSearchOrderByTime = "updated"+ AnswerSearchOrderByVote = "vote"AnswerStatusAvailable = 1AnswerStatusDeleted = 10@@ -35,15 +35,15 @@ type Answer struct {type AnswerSearch struct {AnswerOrder string `json:"order_by" ` // default or updated- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page size}type CmsAnswerSearch struct {- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page sizeStatus int `json:"-" form:"-"`- StatusStr string `json:"status" form:"status"` //Status 1 Available 2 closed 10 Deleted+ StatusStr string `json:"status" form:"status"` // Status 1 Available 2 closed 10 Deleted}type AdminSetAnswerStatusRequest struct {diff --git a/internal/entity/user_entity.go b/internal/entity/user_entity.goindex f87e651e..7ab239a7 100644--- a/internal/entity/user_entity.go+++ b/internal/entity/user_entity.go@@ -40,7 +40,7 @@ type User struct {Avatar string `xorm:"not null default '' VARCHAR(255) avatar"`Mobile string `xorm:"not null VARCHAR(20) mobile"`Bio string `xorm:"not null TEXT bio"`- BioHtml string `xorm:"not null TEXT bio_html"`+ BioHTML string `xorm:"not null TEXT bio_html"`Website string `xorm:"not null default '' VARCHAR(255) website"`Location string `xorm:"not null default '' VARCHAR(100) location"`IPInfo string `xorm:"not null default '' VARCHAR(255) ip_info"`@@ -54,6 +54,6 @@ func (User) TableName() string {type UserSearch struct {User- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page size}diff --git a/internal/migrations/init.go b/internal/migrations/init.goindex 0601ffdd..b44a225f 100644--- a/internal/migrations/init.go+++ b/internal/migrations/init.go@@ -8,27 +8,25 @@ import ("xorm.io/xorm")-var (- tables = []interface{}{- &entity.Activity{},- &entity.Answer{},- &entity.Collection{},- &entity.CollectionGroup{},- &entity.Comment{},- &entity.Config{},- &entity.Meta{},- &entity.Notification{},- &entity.Question{},- &entity.Report{},- &entity.Revision{},- &entity.SiteInfo{},- &entity.Tag{},- &entity.TagRel{},- &entity.Uniqid{},- &entity.User{},- &entity.Version{},- }-)+var tables = []interface{}{+ &entity.Activity{},+ &entity.Answer{},+ &entity.Collection{},+ &entity.CollectionGroup{},+ &entity.Comment{},+ &entity.Config{},+ &entity.Meta{},+ &entity.Notification{},+ &entity.Question{},+ &entity.Report{},+ &entity.Revision{},+ &entity.SiteInfo{},+ &entity.Tag{},+ &entity.TagRel{},+ &entity.Uniqid{},+ &entity.User{},+ &entity.Version{},+}// InitDB init dbfunc InitDB(dataConf *data.Database) (err error) {@@ -94,91 +92,91 @@ func initSiteInfo(engine *xorm.Engine) error {func initConfigTable(engine *xorm.Engine) error {defaultConfigTable := []*entity.Config{- {1, "answer.accepted", `15`},- {2, "answer.voted_up", `10`},- {3, "question.voted_up", `10`},- {4, "tag.edit_accepted", `2`},- {5, "answer.accept", `2`},- {6, "answer.voted_down_cancel", `2`},- {7, "question.voted_down_cancel", `2`},- {8, "answer.vote_down_cancel", `1`},- {9, "question.vote_down_cancel", `1`},- {10, "user.activated", `1`},- {11, "edit.accepted", `2`},- {12, "answer.vote_down", `-1`},- {13, "question.voted_down", `-2`},- {14, "answer.voted_down", `-2`},- {15, "answer.accept_cancel", `-2`},- {16, "answer.deleted", `-5`},- {17, "question.voted_up_cancel", `-10`},- {18, "answer.voted_up_cancel", `-10`},- {19, "answer.accepted_cancel", `-15`},- {20, "object.reported", `-100`},- {21, "edit.rejected", `-2`},- {22, "daily_rank_limit", `200`},- {23, "daily_rank_limit.exclude", `["answer.accepted"]`},- {24, "user.follow", `0`},- {25, "comment.vote_up", `0`},- {26, "comment.vote_up_cancel", `0`},- {27, "question.vote_down", `0`},- {28, "question.vote_up", `0`},- {29, "question.vote_up_cancel", `0`},- {30, "answer.vote_up", `0`},- {31, "answer.vote_up_cancel", `0`},- {32, "question.follow", `0`},- {33, "email.config", `{"from_name":"answer","from_email":"[email protected]","smtp_host":"smtp.answer.org","smtp_port":465,"smtp_password":"answer","smtp_username":"[email protected]","smtp_authentication":true,"encryption":"","register_title":"[{{.SiteName}}] Confirm your new account","register_body":"Welcome to {{.SiteName}}<br><br>\n\nClick the following link to confirm and activate your new account:<br>\n<a href='{{.RegisterUrl}}' target='_blank'>{{.RegisterUrl}}</a><br><br>\n\nIf the above link is not clickable, try copying and pasting it into the address bar of your web browser.\n","pass_reset_title":"[{{.SiteName }}] Password reset","pass_reset_body":"Somebody asked to reset your password on [{{.SiteName}}].<br><br>\n\nIf it was not you, you can safely ignore this email.<br><br>\n\nClick the following link to choose a new password:<br>\n<a href='{{.PassResetUrl}}' target='_blank'>{{.PassResetUrl}}</a>\n","change_title":"[{{.SiteName}}] Confirm your new email address","change_body":"Confirm your new email address for {{.SiteName}} by clicking on the following link:<br><br>\n\n<a href='{{.ChangeEmailUrl}}' target='_blank'>{{.ChangeEmailUrl}}</a><br><br>\n\nIf you did not request this change, please ignore this email.\n","test_title":"[{{.SiteName}}] Test Email","test_body":"This is a test email."}`},- {35, "tag.follow", `0`},- {36, "rank.question.add", `0`},- {37, "rank.question.edit", `0`},- {38, "rank.question.delete", `0`},- {39, "rank.question.vote_up", `0`},- {40, "rank.question.vote_down", `0`},- {41, "rank.answer.add", `0`},- {42, "rank.answer.edit", `0`},- {43, "rank.answer.delete", `0`},- {44, "rank.answer.accept", `0`},- {45, "rank.answer.vote_up", `0`},- {46, "rank.answer.vote_down", `0`},- {47, "rank.comment.add", `0`},- {48, "rank.comment.edit", `0`},- {49, "rank.comment.delete", `0`},- {50, "rank.report.add", `0`},- {51, "rank.tag.add", `0`},- {52, "rank.tag.edit", `0`},- {53, "rank.tag.delete", `0`},- {54, "rank.tag.synonym", `0`},- {55, "rank.link.url_limit", `0`},- {56, "rank.vote.detail", `0`},- {57, "reason.spam", `{"name":"spam","description":"This post is an advertisement, or vandalism. It is not useful or relevant to the current topic."}`},- {58, "reason.rude_or_abusive", `{"name":"rude or abusive","description":"A reasonable person would find this content inappropriate for respectful discourse."}`},- {59, "reason.something", `{"name":"something else","description":"This post requires staff attention for another reason not listed above.","content_type":"textarea"}`},- {60, "reason.a_duplicate", `{"name":"a duplicate","description":"This question has been asked before and already has an answer.","content_type":"text"}`},- {61, "reason.not_a_answer", `{"name":"not a answer","description":"This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether.","content_type":""}`},- {62, "reason.no_longer_needed", `{"name":"no longer needed","description":"This comment is outdated, conversational or not relevant to this post."}`},- {63, "reason.community_specific", `{"name":"a community-specific reason","description":"This question doesn’t meet a community guideline."}`},- {64, "reason.not_clarity", `{"name":"needs details or clarity","description":"This question currently includes multiple questions in one. It should focus on one problem only.","content_type":"text"}`},- {65, "reason.normal", `{"name":"normal","description":"A normal post available to everyone."}`},- {66, "reason.normal.user", `{"name":"normal","description":"A normal user can ask and answer questions."}`},- {67, "reason.closed", `{"name":"closed","description":"A closed question can’t answer, but still can edit, vote and comment."}`},- {68, "reason.deleted", `{"name":"deleted","description":"All reputation gained and lost will be restored."}`},- {69, "reason.deleted.user", `{"name":"deleted","description":"Delete profile, authentication associations."}`},- {70, "reason.suspended", `{"name":"suspended","description":"A suspended user can’t log in."}`},- {71, "reason.inactive", `{"name":"inactive","description":"An inactive user must re-validate their email."}`},- {72, "reason.looks_ok", `{"name":"looks ok","description":"This post is good as-is and not low quality."}`},- {73, "reason.needs_edit", `{"name":"needs edit, and I did it","description":"Improve and correct problems with this post yourself."}`},- {74, "reason.needs_close", `{"name":"needs close","description":"A closed question can’t answer, but still can edit, vote and comment."}`},- {75, "reason.needs_delete", `{"name":"needs delete","description":"All reputation gained and lost will be restored."}`},- {76, "question.flag.reasons", `["reason.spam","reason.rude_or_abusive","reason.something","reason.a_duplicate"]`},- {77, "answer.flag.reasons", `["reason.spam","reason.rude_or_abusive","reason.something","reason.not_a_answer"]`},- {78, "comment.flag.reasons", `["reason.spam","reason.rude_or_abusive","reason.something","reason.no_longer_needed"]`},- {79, "question.close.reasons", `["reason.a_duplicate","reason.community_specific","reason.not_clarity","reason.something"]`},- {80, "question.status.reasons", `["reason.normal","reason.closed","reason.deleted"]`},- {81, "answer.status.reasons", `["reason.normal","reason.deleted"]`},- {82, "comment.status.reasons", `["reason.normal","reason.deleted"]`},- {83, "user.status.reasons", `["reason.normal.user","reason.suspended","reason.deleted.user","reason.inactive"]`},- {84, "question.review.reasons", `["reason.looks_ok","reason.needs_edit","reason.needs_close","reason.needs_delete"]`},- {85, "answer.review.reasons", `["reason.looks_ok","reason.needs_edit","reason.needs_delete"]`},- {86, "comment.review.reasons", `["reason.looks_ok","reason.needs_edit","reason.needs_delete"]`},+ {ID: 1, Key: "answer.accepted", Value: `15`},+ {ID: 2, Key: "answer.voted_up", Value: `10`},+ {ID: 3, Key: "question.voted_up", Value: `10`},+ {ID: 4, Key: "tag.edit_accepted", Value: `2`},+ {ID: 5, Key: "answer.accept", Value: `2`},+ {ID: 6, Key: "answer.voted_down_cancel", Value: `2`},+ {ID: 7, Key: "question.voted_down_cancel", Value: `2`},+ {ID: 8, Key: "answer.vote_down_cancel", Value: `1`},+ {ID: 9, Key: "question.vote_down_cancel", Value: `1`},+ {ID: 10, Key: "user.activated", Value: `1`},+ {ID: 11, Key: "edit.accepted", Value: `2`},+ {ID: 12, Key: "answer.vote_down", Value: `-1`},+ {ID: 13, Key: "question.voted_down", Value: `-2`},+ {ID: 14, Key: "answer.voted_down", Value: `-2`},+ {ID: 15, Key: "answer.accept_cancel", Value: `-2`},+ {ID: 16, Key: "answer.deleted", Value: `-5`},+ {ID: 17, Key: "question.voted_up_cancel", Value: `-10`},+ {ID: 18, Key: "answer.voted_up_cancel", Value: `-10`},+ {ID: 19, Key: "answer.accepted_cancel", Value: `-15`},+ {ID: 20, Key: "object.reported", Value: `-100`},+ {ID: 21, Key: "edit.rejected", Value: `-2`},+ {ID: 22, Key: "daily_rank_limit", Value: `200`},+ {ID: 23, Key: "daily_rank_limit.exclude", Value: `["answer.accepted"]`},+ {ID: 24, Key: "user.follow", Value: `0`},+ {ID: 25, Key: "comment.vote_up", Value: `0`},+ {ID: 26, Key: "comment.vote_up_cancel", Value: `0`},+ {ID: 27, Key: "question.vote_down", Value: `0`},+ {ID: 28, Key: "question.vote_up", Value: `0`},+ {ID: 29, Key: "question.vote_up_cancel", Value: `0`},+ {ID: 30, Key: "answer.vote_up", Value: `0`},+ {ID: 31, Key: "answer.vote_up_cancel", Value: `0`},+ {ID: 32, Key: "question.follow", Value: `0`},+ {ID: 33, Key: "email.config", Value: `{"from_name":"answer","from_email":"[email protected]","smtp_host":"smtp.answer.org","smtp_port":465,"smtp_password":"answer","smtp_username":"[email protected]","smtp_authentication":true,"encryption":"","register_title":"[{{.SiteName}}] Confirm your new account","register_body":"Welcome to {{.SiteName}}<br><br>\n\nClick the following link to confirm and activate your new account:<br>\n<a href='{{.RegisterUrl}}' target='_blank'>{{.RegisterUrl}}</a><br><br>\n\nIf the above link is not clickable, try copying and pasting it into the address bar of your web browser.\n","pass_reset_title":"[{{.SiteName }}] Password reset","pass_reset_body":"Somebody asked to reset your password on [{{.SiteName}}].<br><br>\n\nIf it was not you, you can safely ignore this email.<br><br>\n\nClick the following link to choose a new password:<br>\n<a href='{{.PassResetUrl}}' target='_blank'>{{.PassResetUrl}}</a>\n","change_title":"[{{.SiteName}}] Confirm your new email address","change_body":"Confirm your new email address for {{.SiteName}} by clicking on the following link:<br><br>\n\n<a href='{{.ChangeEmailUrl}}' target='_blank'>{{.ChangeEmailUrl}}</a><br><br>\n\nIf you did not request this change, please ignore this email.\n","test_title":"[{{.SiteName}}] Test Email","test_body":"This is a test email."}`},+ {ID: 35, Key: "tag.follow", Value: `0`},+ {ID: 36, Key: "rank.question.add", Value: `0`},+ {ID: 37, Key: "rank.question.edit", Value: `0`},+ {ID: 38, Key: "rank.question.delete", Value: `0`},+ {ID: 39, Key: "rank.question.vote_up", Value: `0`},+ {ID: 40, Key: "rank.question.vote_down", Value: `0`},+ {ID: 41, Key: "rank.answer.add", Value: `0`},+ {ID: 42, Key: "rank.answer.edit", Value: `0`},+ {ID: 43, Key: "rank.answer.delete", Value: `0`},+ {ID: 44, Key: "rank.answer.accept", Value: `0`},+ {ID: 45, Key: "rank.answer.vote_up", Value: `0`},+ {ID: 46, Key: "rank.answer.vote_down", Value: `0`},+ {ID: 47, Key: "rank.comment.add", Value: `0`},+ {ID: 48, Key: "rank.comment.edit", Value: `0`},+ {ID: 49, Key: "rank.comment.delete", Value: `0`},+ {ID: 50, Key: "rank.report.add", Value: `0`},+ {ID: 51, Key: "rank.tag.add", Value: `0`},+ {ID: 52, Key: "rank.tag.edit", Value: `0`},+ {ID: 53, Key: "rank.tag.delete", Value: `0`},+ {ID: 54, Key: "rank.tag.synonym", Value: `0`},+ {ID: 55, Key: "rank.link.url_limit", Value: `0`},+ {ID: 56, Key: "rank.vote.detail", Value: `0`},+ {ID: 57, Key: "reason.spam", Value: `{"name":"spam","description":"This post is an advertisement, or vandalism. It is not useful or relevant to the current topic."}`},+ {ID: 58, Key: "reason.rude_or_abusive", Value: `{"name":"rude or abusive","description":"A reasonable person would find this content inappropriate for respectful discourse."}`},+ {ID: 59, Key: "reason.something", Value: `{"name":"something else","description":"This post requires staff attention for another reason not listed above.","content_type":"textarea"}`},+ {ID: 60, Key: "reason.a_duplicate", Value: `{"name":"a duplicate","description":"This question has been asked before and already has an answer.","content_type":"text"}`},+ {ID: 61, Key: "reason.not_a_answer", Value: `{"name":"not a answer","description":"This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether.","content_type":""}`},+ {ID: 62, Key: "reason.no_longer_needed", Value: `{"name":"no longer needed","description":"This comment is outdated, conversational or not relevant to this post."}`},+ {ID: 63, Key: "reason.community_specific", Value: `{"name":"a community-specific reason","description":"This question doesn’t meet a community guideline."}`},+ {ID: 64, Key: "reason.not_clarity", Value: `{"name":"needs details or clarity","description":"This question currently includes multiple questions in one. It should focus on one problem only.","content_type":"text"}`},+ {ID: 65, Key: "reason.normal", Value: `{"name":"normal","description":"A normal post available to everyone."}`},+ {ID: 66, Key: "reason.normal.user", Value: `{"name":"normal","description":"A normal user can ask and answer questions."}`},+ {ID: 67, Key: "reason.closed", Value: `{"name":"closed","description":"A closed question can’t answer, but still can edit, vote and comment."}`},+ {ID: 68, Key: "reason.deleted", Value: `{"name":"deleted","description":"All reputation gained and lost will be restored."}`},+ {ID: 69, Key: "reason.deleted.user", Value: `{"name":"deleted","description":"Delete profile, authentication associations."}`},+ {ID: 70, Key: "reason.suspended", Value: `{"name":"suspended","description":"A suspended user can’t log in."}`},+ {ID: 71, Key: "reason.inactive", Value: `{"name":"inactive","description":"An inactive user must re-validate their email."}`},+ {ID: 72, Key: "reason.looks_ok", Value: `{"name":"looks ok","description":"This post is good as-is and not low quality."}`},+ {ID: 73, Key: "reason.needs_edit", Value: `{"name":"needs edit, and I did it","description":"Improve and correct problems with this post yourself."}`},+ {ID: 74, Key: "reason.needs_close", Value: `{"name":"needs close","description":"A closed question can’t answer, but still can edit, vote and comment."}`},+ {ID: 75, Key: "reason.needs_delete", Value: `{"name":"needs delete","description":"All reputation gained and lost will be restored."}`},+ {ID: 76, Key: "question.flag.reasons", Value: `["reason.spam","reason.rude_or_abusive","reason.something","reason.a_duplicate"]`},+ {ID: 77, Key: "answer.flag.reasons", Value: `["reason.spam","reason.rude_or_abusive","reason.something","reason.not_a_answer"]`},+ {ID: 78, Key: "comment.flag.reasons", Value: `["reason.spam","reason.rude_or_abusive","reason.something","reason.no_longer_needed"]`},+ {ID: 79, Key: "question.close.reasons", Value: `["reason.a_duplicate","reason.community_specific","reason.not_clarity","reason.something"]`},+ {ID: 80, Key: "question.status.reasons", Value: `["reason.normal","reason.closed","reason.deleted"]`},+ {ID: 81, Key: "answer.status.reasons", Value: `["reason.normal","reason.deleted"]`},+ {ID: 82, Key: "comment.status.reasons", Value: `["reason.normal","reason.deleted"]`},+ {ID: 83, Key: "user.status.reasons", Value: `["reason.normal.user","reason.suspended","reason.deleted.user","reason.inactive"]`},+ {ID: 84, Key: "question.review.reasons", Value: `["reason.looks_ok","reason.needs_edit","reason.needs_close","reason.needs_delete"]`},+ {ID: 85, Key: "answer.review.reasons", Value: `["reason.looks_ok","reason.needs_edit","reason.needs_delete"]`},+ {ID: 86, Key: "comment.review.reasons", Value: `["reason.looks_ok","reason.needs_edit","reason.needs_delete"]`},}_, err := engine.Insert(defaultConfigTable)return errdiff --git a/internal/repo/activity/answer_repo.go b/internal/repo/activity/answer_repo.goindex 74ab0db6..01602b1e 100644--- a/internal/repo/activity/answer_repo.go+++ b/internal/repo/activity/answer_repo.go@@ -44,7 +44,6 @@ func NewAnswerActivityRepo(userRankRepo rank.UserRankRepo,) activity.AnswerActivityRepo {return &AnswerActivityRepo{-data: data,activityRepo: activityRepo,userRankRepo: userRankRepo,@@ -125,7 +124,8 @@ func (ar *AnswerActivityRepo) DeleteQuestion(ctx context.Context, questionID str// AcceptAnswer accept other answerfunc (ar *AnswerActivityRepo) AcceptAnswer(ctx context.Context,- answerObjID, questionUserID, answerUserID string, isSelf bool) (err error) {+ answerObjID, questionUserID, answerUserID string, isSelf bool,+) (err error) {addActivityList := make([]*entity.Activity, 0)for _, action := range acceptActionList {// get accept answer need add rank amount@@ -173,7 +173,7 @@ func (ar *AnswerActivityRepo) AcceptAnswer(ctx context.Context,}if exists {- if _, e := session.Where("id = ?", existsActivity.ID).Cols("`cancelled`").+ if _, e = session.Where("id = ?", existsActivity.ID).Cols("`cancelled`").Update(&entity.Activity{Cancelled: entity.ActivityAvailable}); e != nil {return nil, errors.InternalServer(reason.DatabaseError).WithError(e).WithStack()}@@ -222,7 +222,8 @@ func (ar *AnswerActivityRepo) AcceptAnswer(ctx context.Context,// CancelAcceptAnswer accept other answerfunc (ar *AnswerActivityRepo) CancelAcceptAnswer(ctx context.Context,- answerObjID, questionUserID, answerUserID string) (err error) {+ answerObjID, questionUserID, answerUserID string,+) (err error) {addActivityList := make([]*entity.Activity, 0)for _, action := range acceptActionList {// get accept answer need add rank amountdiff --git a/internal/repo/activity/follow_repo.go b/internal/repo/activity/follow_repo.goindex 916459a2..14238718 100644--- a/internal/repo/activity/follow_repo.go+++ b/internal/repo/activity/follow_repo.go@@ -37,8 +37,8 @@ func NewFollowRepo(}}-func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) error {- activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectId, "follow")+func (ar *FollowRepo) Follow(ctx context.Context, objectID, userID string) error {+ activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectID, "follow")if err != nil {return err}@@ -51,8 +51,8 @@ func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) errorresult = nilhas, err = session.Where(builder.Eq{"activity_type": activityType}).- And(builder.Eq{"user_id": userId}).- And(builder.Eq{"object_id": objectId}).+ And(builder.Eq{"user_id": userID}).+ And(builder.Eq{"object_id": objectID}).Get(&existsActivity)if err != nil {@@ -72,8 +72,8 @@ func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) error} else {// update existing activity with new user id and u object id_, err = session.Insert(&entity.Activity{- UserID: userId,- ObjectID: objectId,+ UserID: userID,+ ObjectID: objectID,ActivityType: activityType,Cancelled: 0,Rank: 0,@@ -87,7 +87,7 @@ func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) error}// start update followers when everything is fine- err = ar.updateFollows(ctx, session, objectId, 1)+ err = ar.updateFollows(ctx, session, objectID, 1)if err != nil {log.Error(err)}@@ -98,8 +98,8 @@ func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) errorreturn err}-func (ar *FollowRepo) FollowCancel(ctx context.Context, objectId, userId string) error {- activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectId, "follow")+func (ar *FollowRepo) FollowCancel(ctx context.Context, objectID, userID string) error {+ activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectID, "follow")if err != nil {return err}@@ -112,8 +112,8 @@ func (ar *FollowRepo) FollowCancel(ctx context.Context, objectId, userId string)result = nilhas, err = session.Where(builder.Eq{"activity_type": activityType}).- And(builder.Eq{"user_id": userId}).- And(builder.Eq{"object_id": objectId}).+ And(builder.Eq{"user_id": userID}).+ And(builder.Eq{"object_id": objectID}).Get(&existsActivity)if err != nil || !has {@@ -130,24 +130,24 @@ func (ar *FollowRepo) FollowCancel(ctx context.Context, objectId, userId string)}); err != nil {return}- err = ar.updateFollows(ctx, session, objectId, -1)+ err = ar.updateFollows(ctx, session, objectID, -1)return})return err}-func (ar *FollowRepo) updateFollows(ctx context.Context, session *xorm.Session, objectId string, follows int) error {- objectType, err := obj.GetObjectTypeStrByObjectID(objectId)+func (ar *FollowRepo) updateFollows(ctx context.Context, session *xorm.Session, objectID string, follows int) error {+ objectType, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {return err}switch objectType {case "question":- _, err = session.Where("id = ?", objectId).Incr("follow_count", follows).Update(&entity.Question{})+ _, err = session.Where("id = ?", objectID).Incr("follow_count", follows).Update(&entity.Question{})case "user":- _, err = session.Where("id = ?", objectId).Incr("follow_count", follows).Update(&entity.User{})+ _, err = session.Where("id = ?", objectID).Incr("follow_count", follows).Update(&entity.User{})case "tag":- _, err = session.Where("id = ?", objectId).Incr("follow_count", follows).Update(&entity.Tag{})+ _, err = session.Where("id = ?", objectID).Incr("follow_count", follows).Update(&entity.Tag{})default:err = errors.InternalServer(reason.DisallowFollow).WithMsg("this object can't be followed")}diff --git a/internal/repo/activity/vote_repo.go b/internal/repo/activity/vote_repo.goindex bcc95f93..00ccd04b 100644--- a/internal/repo/activity/vote_repo.go+++ b/internal/repo/activity/vote_repo.go@@ -2,9 +2,10 @@ package activityimport ("context"- "github.com/answerdev/answer/pkg/converter""strings"+ "github.com/answerdev/answer/pkg/converter"+"github.com/answerdev/answer/internal/base/pager""github.com/answerdev/answer/internal/service/config""github.com/answerdev/answer/internal/service/notice_queue"@@ -42,7 +43,8 @@ func NewVoteRepo(configRepo config.ConfigRepo,activityRepo activity_common.ActivityRepo,userRankRepo rank.UserRankRepo,- voteCommon activity_common.VoteRepo) service.VoteRepo {+ voteCommon activity_common.VoteRepo,+) service.VoteRepo {return &VoteRepo{data: data,uniqueIDRepo: uniqueIDRepo,@@ -65,7 +67,7 @@ var LimitDownActions = map[string][]string{"comment": {"vote_down"},}-func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUserId string, actions []string) (resp *schema.VoteResp, err error) {+func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUserID string, actions []string) (resp *schema.VoteResp, err error) {resp = &schema.VoteResp{}_, err = vr.data.DB.Transaction(func(session *xorm.Session) (result any, err error) {result = nil@@ -75,24 +77,24 @@ func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUseinsertActivity entity.Activityhas booltriggerUserID,- activityUserId string+ activityUserID stringactivityType, deltaRank, hasRank int)- activityUserId, activityType, deltaRank, hasRank, err = vr.CheckRank(ctx, objectID, objectUserId, userID, action)+ activityUserID, activityType, deltaRank, hasRank, err = vr.CheckRank(ctx, objectID, objectUserID, userID, action)if err != nil {return}triggerUserID = userID- if userID == activityUserId {+ if userID == activityUserID {triggerUserID = "0"}// check is voted uphas, _ = session.Where(builder.Eq{"object_id": objectID}).- And(builder.Eq{"user_id": activityUserId}).+ And(builder.Eq{"user_id": activityUserID}).And(builder.Eq{"trigger_user_id": triggerUserID}).And(builder.Eq{"activity_type": activityType}).Get(&existsActivity)@@ -104,7 +106,7 @@ func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUseinsertActivity = entity.Activity{ObjectID: objectID,- UserID: activityUserId,+ UserID: activityUserID,TriggerUserID: converter.StringToInt64(triggerUserID),ActivityType: activityType,Rank: deltaRank,@@ -114,7 +116,8 @@ func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUse// trigger user rank and send notificationif hasRank != 0 {- isReachStandard, err := vr.userRankRepo.TriggerUserRank(ctx, session, activityUserId, deltaRank, activityType)+ var isReachStandard bool+ isReachStandard, err = vr.userRankRepo.TriggerUserRank(ctx, session, activityUserID, deltaRank, activityType)if err != nil {return nil, err}@@ -122,7 +125,7 @@ func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUseinsertActivity.Rank = 0}- vr.sendNotification(ctx, activityUserId, objectUserId, objectID)+ vr.sendNotification(ctx, activityUserID, objectUserID, objectID)}if has {@@ -163,7 +166,7 @@ func (vr *VoteRepo) vote(ctx context.Context, objectID string, userID, objectUsereturn}-func (vr *VoteRepo) voteCancel(ctx context.Context, objectID string, userID, objectUserId string, actions []string) (resp *schema.VoteResp, err error) {+func (vr *VoteRepo) voteCancel(ctx context.Context, objectID string, userID, objectUserID string, actions []string) (resp *schema.VoteResp, err error) {resp = &schema.VoteResp{}_, err = vr.data.DB.Transaction(func(session *xorm.Session) (result any, err error) {for _, action := range actions {@@ -171,24 +174,24 @@ func (vr *VoteRepo) voteCancel(ctx context.Context, objectID string, userID, objexistsActivity entity.Activityhas booltriggerUserID,- activityUserId string+ activityUserID stringactivityType,deltaRank, hasRank int)result = nil- activityUserId, activityType, deltaRank, hasRank, err = vr.CheckRank(ctx, objectID, objectUserId, userID, action)+ activityUserID, activityType, deltaRank, hasRank, err = vr.CheckRank(ctx, objectID, objectUserID, userID, action)if err != nil {return}triggerUserID = userID- if userID == activityUserId {+ if userID == activityUserID {triggerUserID = "0"}has, err = session.- Where(builder.Eq{"user_id": activityUserId}).+ Where(builder.Eq{"user_id": activityUserID}).And(builder.Eq{"trigger_user_id": triggerUserID}).And(builder.Eq{"activity_type": activityType}).And(builder.Eq{"object_id": objectID}).@@ -211,12 +214,12 @@ func (vr *VoteRepo) voteCancel(ctx context.Context, objectID string, userID, obj// trigger user rank and send notificationif hasRank != 0 {- _, err = vr.userRankRepo.TriggerUserRank(ctx, session, activityUserId, -deltaRank, activityType)+ _, err = vr.userRankRepo.TriggerUserRank(ctx, session, activityUserID, -deltaRank, activityType)if err != nil {return}- vr.sendNotification(ctx, activityUserId, objectUserId, objectID)+ vr.sendNotification(ctx, activityUserID, objectUserID, objectID)}// update votes@@ -242,7 +245,7 @@ func (vr *VoteRepo) voteCancel(ctx context.Context, objectID string, userID, objreturn}-func (vr *VoteRepo) VoteUp(ctx context.Context, objectID string, userID, objectUserId string) (resp *schema.VoteResp, err error) {+func (vr *VoteRepo) VoteUp(ctx context.Context, objectID string, userID, objectUserID string) (resp *schema.VoteResp, err error) {resp = &schema.VoteResp{}objectType, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {@@ -256,11 +259,11 @@ func (vr *VoteRepo) VoteUp(ctx context.Context, objectID string, userID, objectUreturn}- _, _ = vr.VoteDownCancel(ctx, objectID, userID, objectUserId)- return vr.vote(ctx, objectID, userID, objectUserId, actions)+ _, _ = vr.VoteDownCancel(ctx, objectID, userID, objectUserID)+ return vr.vote(ctx, objectID, userID, objectUserID, actions)}-func (vr *VoteRepo) VoteDown(ctx context.Context, objectID string, userID, objectUserId string) (resp *schema.VoteResp, err error) {+func (vr *VoteRepo) VoteDown(ctx context.Context, objectID string, userID, objectUserID string) (resp *schema.VoteResp, err error) {resp = &schema.VoteResp{}objectType, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {@@ -273,14 +276,12 @@ func (vr *VoteRepo) VoteDown(ctx context.Context, objectID string, userID, objecreturn}- _, _ = vr.VoteUpCancel(ctx, objectID, userID, objectUserId)- return vr.vote(ctx, objectID, userID, objectUserId, actions)+ _, _ = vr.VoteUpCancel(ctx, objectID, userID, objectUserID)+ return vr.vote(ctx, objectID, userID, objectUserID, actions)}-func (vr *VoteRepo) VoteUpCancel(ctx context.Context, objectID string, userID, objectUserId string) (resp *schema.VoteResp, err error) {- var (- objectType string- )+func (vr *VoteRepo) VoteUpCancel(ctx context.Context, objectID string, userID, objectUserID string) (resp *schema.VoteResp, err error) {+ var objectType stringresp = &schema.VoteResp{}objectType, err = obj.GetObjectTypeStrByObjectID(objectID)@@ -294,13 +295,11 @@ func (vr *VoteRepo) VoteUpCancel(ctx context.Context, objectID string, userID, oreturn}- return vr.voteCancel(ctx, objectID, userID, objectUserId, actions)+ return vr.voteCancel(ctx, objectID, userID, objectUserID, actions)}-func (vr *VoteRepo) VoteDownCancel(ctx context.Context, objectID string, userID, objectUserId string) (resp *schema.VoteResp, err error) {- var (- objectType string- )+func (vr *VoteRepo) VoteDownCancel(ctx context.Context, objectID string, userID, objectUserID string) (resp *schema.VoteResp, err error) {+ var objectType stringresp = &schema.VoteResp{}objectType, err = obj.GetObjectTypeStrByObjectID(objectID)@@ -314,22 +313,22 @@ func (vr *VoteRepo) VoteDownCancel(ctx context.Context, objectID string, userID,return}- return vr.voteCancel(ctx, objectID, userID, objectUserId, actions)+ return vr.voteCancel(ctx, objectID, userID, objectUserID, actions)}-func (vr *VoteRepo) CheckRank(ctx context.Context, objectID, objectUserId, userID string, action string) (activityUserId string, activityType, rank, hasRank int, err error) {+func (vr *VoteRepo) CheckRank(ctx context.Context, objectID, objectUserID, userID string, action string) (activityUserID string, activityType, rank, hasRank int, err error) {activityType, rank, hasRank, err = vr.activityRepo.GetActivityTypeByObjID(ctx, objectID, action)if err != nil {return}- activityUserId = userID+ activityUserID = userIDif strings.Contains(action, "voted") {- activityUserId = objectUserId+ activityUserID = objectUserID}- return activityUserId, activityType, rank, hasRank, nil+ return activityUserID, activityType, rank, hasRank, nil}func (vr *VoteRepo) GetVoteResultByObjectId(ctx context.Context, objectID string) (resp *schema.VoteResp, err error) {@@ -341,7 +340,7 @@ func (vr *VoteRepo) GetVoteResultByObjectId(ctx context.Context, objectID stringactivityType int)- activityType, _, _, err = vr.activityRepo.GetActivityTypeByObjID(ctx, objectID, action)+ activityType, _, _, _ = vr.activityRepo.GetActivityTypeByObjID(ctx, objectID, action)votes, err = vr.data.DB.Where(builder.Eq{"object_id": objectID}).And(builder.Eq{"activity_type": activityType}).@@ -417,15 +416,15 @@ func (vr *VoteRepo) updateVotes(ctx context.Context, session *xorm.Session, obje}// sendNotification send rank triggered notification-func (vr *VoteRepo) sendNotification(ctx context.Context, activityUserId, objectUserId, objectID string) {+func (vr *VoteRepo) sendNotification(ctx context.Context, activityUserID, objectUserID, objectID string) {objectType, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {return}msg := &schema.NotificationMsg{- ReceiverUserID: activityUserId,- TriggerUserID: objectUserId,+ ReceiverUserID: activityUserID,+ TriggerUserID: objectUserID,Type: schema.NotificationTypeAchievement,ObjectID: objectID,ObjectType: objectType,diff --git a/internal/repo/activity_common/follow.go b/internal/repo/activity_common/follow.goindex a61ddcdb..aee42454 100644--- a/internal/repo/activity_common/follow.go+++ b/internal/repo/activity_common/follow.go@@ -33,27 +33,27 @@ func NewFollowRepo(}// GetFollowAmount get object id's follows-func (ar *FollowRepo) GetFollowAmount(ctx context.Context, objectId string) (follows int, err error) {- objectType, err := obj.GetObjectTypeStrByObjectID(objectId)+func (ar *FollowRepo) GetFollowAmount(ctx context.Context, objectID string) (follows int, err error) {+ objectType, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {return 0, err}switch objectType {case "question":model := &entity.Question{}- _, err = ar.data.DB.Where("id = ?", objectId).Cols("`follow_count`").Get(model)+ _, err = ar.data.DB.Where("id = ?", objectID).Cols("`follow_count`").Get(model)if err == nil {follows = int(model.FollowCount)}case "user":model := &entity.User{}- _, err = ar.data.DB.Where("id = ?", objectId).Cols("`follow_count`").Get(model)+ _, err = ar.data.DB.Where("id = ?", objectID).Cols("`follow_count`").Get(model)if err == nil {follows = int(model.FollowCount)}case "tag":model := &entity.Tag{}- _, err = ar.data.DB.Where("id = ?", objectId).Cols("`follow_count`").Get(model)+ _, err = ar.data.DB.Where("id = ?", objectID).Cols("`follow_count`").Get(model)if err == nil {follows = int(model.FollowCount)}@@ -110,14 +110,14 @@ func (ar *FollowRepo) GetFollowIDs(ctx context.Context, userID, objectKey string}// IsFollowed check user if follow object or not-func (ar *FollowRepo) IsFollowed(userId, objectId string) (bool, error) {- activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(context.TODO(), objectId, "follow")+func (ar *FollowRepo) IsFollowed(userID, objectID string) (bool, error) {+ activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(context.TODO(), objectID, "follow")if err != nil {return false, err}at := &entity.Activity{}- has, err := ar.data.DB.Where("user_id = ? AND object_id = ? AND activity_type = ?", userId, objectId, activityType).Get(at)+ has, err := ar.data.DB.Where("user_id = ? AND object_id = ? AND activity_type = ?", userID, objectID, activityType).Get(at)if err != nil {return false, err}diff --git a/internal/repo/activity_common/vote.go b/internal/repo/activity_common/vote.goindex 86db8f39..2c40305a 100644--- a/internal/repo/activity_common/vote.go+++ b/internal/repo/activity_common/vote.go@@ -22,7 +22,7 @@ func NewVoteRepo(data *data.Data, activityRepo activity_common.ActivityRepo) act}}-func (vr *VoteRepo) GetVoteStatus(ctx context.Context, objectId, userId string) (status string) {+func (vr *VoteRepo) GetVoteStatus(ctx context.Context, objectID, userID string) (status string) {for _, action := range []string{"vote_up", "vote_down"} {at := &entity.Activity{}activityType, _, _, err := vr.activityRepo.GetActivityTypeByObjID(ctx, objectId, action)diff --git a/internal/repo/activity_repo.go b/internal/repo/activity_repo.goindex df14ae01..ed10c537 100644--- a/internal/repo/activity_repo.go+++ b/internal/repo/activity_repo.go@@ -37,14 +37,14 @@ func NewActivityRepo(}}-func (ar *ActivityRepo) GetActivityTypeByObjID(ctx context.Context, objectId string, action string) (activityType, rank, hasRank int, err error) {- objectKey, err := obj.GetObjectTypeStrByObjectID(objectId)+func (ar *ActivityRepo) GetActivityTypeByObjID(ctx context.Context, objectID string, action string) (activityType, rank, hasRank int, err error) {+ objectKey, err := obj.GetObjectTypeStrByObjectID(objectID)if err != nil {return}confKey := fmt.Sprintf("%s.%s", objectKey, action)- activityType, err = ar.configRepo.GetConfigType(confKey)+ activityType, _ = ar.configRepo.GetConfigType(confKey)rank, err = ar.configRepo.GetInt(confKey)hasRank = 0@@ -64,7 +64,8 @@ func (ar *ActivityRepo) GetActivityTypeByObjKey(ctx context.Context, objectKey,}func (ar *ActivityRepo) GetActivity(ctx context.Context, session *xorm.Session,- objectID, userID string, activityType int) (existsActivity *entity.Activity, exist bool, err error) {+ objectID, userID string, activityType int,+) (existsActivity *entity.Activity, exist bool, err error) {existsActivity = &entity.Activity{}exist, err = session.Where(builder.Eq{"object_id": objectID}).diff --git a/internal/repo/answer_repo.go b/internal/repo/answer_repo.goindex dd4753e8..72b68d67 100644--- a/internal/repo/answer_repo.go+++ b/internal/repo/answer_repo.go@@ -89,7 +89,8 @@ func (ar *answerRepo) UpdateAnswerStatus(ctx context.Context, answer *entity.Ans// GetAnswer get answer onefunc (ar *answerRepo) GetAnswer(ctx context.Context, id string) (- answer *entity.Answer, exist bool, err error) {+ answer *entity.Answer, exist bool, err error,+) {answer = &entity.Answer{}exist, err = ar.data.DB.ID(id).Get(answer)if err != nil {@@ -120,20 +121,20 @@ func (ar *answerRepo) GetAnswerPage(ctx context.Context, page, pageSize int, ans// UpdateAdopted// If no answer is selected, the answer id can be 0-func (ar *answerRepo) UpdateAdopted(ctx context.Context, id string, questionId string) error {- if questionId == "" {+func (ar *answerRepo) UpdateAdopted(ctx context.Context, id string, questionID string) error {+ if questionID == "" {return nil}var data entity.Answerdata.ID = id- data.Adopted = schema.Answer_Adopted_Failed- _, err := ar.data.DB.Where("question_id =?", questionId).Cols("adopted").Update(&data)+ data.Adopted = schema.AnswerAdoptedFailed+ _, err := ar.data.DB.Where("question_id =?", questionID).Cols("adopted").Update(&data)if err != nil {return err}if id != "0" {- data.Adopted = schema.Answer_Adopted_Enable+ data.Adopted = schema.AnswerAdoptedEnable_, err = ar.data.DB.Where("id = ?", id).Cols("adopted").Update(&data)if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -152,9 +153,9 @@ func (ar *answerRepo) GetByID(ctx context.Context, id string) (*entity.Answer, breturn &resp, has, nil}-func (ar *answerRepo) GetByUserIdQuestionId(ctx context.Context, userId string, questionId string) (*entity.Answer, bool, error) {+func (ar *answerRepo) GetByUserIDQuestionID(ctx context.Context, userID string, questionID string) (*entity.Answer, bool, error) {var resp entity.Answer- has, err := ar.data.DB.Where("question_id =? and user_id = ?", questionId, userId).Get(&resp)+ has, err := ar.data.DB.Where("question_id =? and user_id = ?", questionID, userID).Get(&resp)if err != nil {return &resp, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -172,7 +173,7 @@ func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearcsearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := ar.data.DB.Where("")@@ -183,14 +184,14 @@ func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearcif len(search.UserID) > 0 {session = session.And("user_id = ?", search.UserID)}- if search.Order == entity.Answer_Search_OrderBy_Time {+ switch search.Order {+ case entity.AnswerSearchOrderByTime:session = session.OrderBy("created_at desc")- } else if search.Order == entity.Answer_Search_OrderBy_Vote {+ case entity.AnswerSearchOrderByVote:session = session.OrderBy("vote_count desc")- } else {+ default:session = session.OrderBy("adopted desc,vote_count desc")}-session = session.And("status = ?", entity.AnswerStatusAvailable)session = session.Limit(search.PageSize, offset)@@ -214,7 +215,7 @@ func (ar *answerRepo) CmsSearchList(ctx context.Context, search *entity.CmsAnswesearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := ar.data.DB.Where("")diff --git a/internal/repo/collection/collection_group_repo.go b/internal/repo/collection/collection_group_repo.goindex cac96cfc..8f915bb6 100644--- a/internal/repo/collection/collection_group_repo.go+++ b/internal/repo/collection/collection_group_repo.go@@ -37,7 +37,7 @@ func (cr *collectionGroupRepo) AddCollectionGroup(ctx context.Context, collectiofunc (cr *collectionGroupRepo) AddCollectionDefaultGroup(ctx context.Context, userID string) (collectionGroup *entity.CollectionGroup, err error) {defaultGroup := &entity.CollectionGroup{Name: "default",- DefaultGroup: schema.CG_DEFAULT,+ DefaultGroup: schema.CGDefault,UserID: userID,}_, err = cr.data.DB.Insert(defaultGroup)@@ -60,7 +60,8 @@ func (cr *collectionGroupRepo) UpdateCollectionGroup(ctx context.Context, collec// GetCollectionGroup get collection group onefunc (cr *collectionGroupRepo) GetCollectionGroup(ctx context.Context, id string) (- collectionGroup *entity.CollectionGroup, exist bool, err error) {+ collectionGroup *entity.CollectionGroup, exist bool, err error,+) {collectionGroup = &entity.CollectionGroup{}exist, err = cr.data.DB.ID(id).Get(collectionGroup)if err != nil {@@ -84,9 +85,9 @@ func (cr *collectionGroupRepo) GetCollectionGroupPage(ctx context.Context, page,return}-func (cr *collectionGroupRepo) GetDefaultID(ctx context.Context, userId string) (collectionGroup *entity.CollectionGroup, has bool, err error) {+func (cr *collectionGroupRepo) GetDefaultID(ctx context.Context, userID string) (collectionGroup *entity.CollectionGroup, has bool, err error) {collectionGroup = &entity.CollectionGroup{}- has, err = cr.data.DB.Where("user_id =? and default_group = ?", userId, schema.CG_DEFAULT).Get(collectionGroup)+ has, err = cr.data.DB.Where("user_id =? and default_group = ?", userID, schema.CGDefault).Get(collectionGroup)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()returndiff --git a/internal/repo/collection/collection_repo.go b/internal/repo/collection/collection_repo.goindex 2fb4d92c..f73c74b7 100644--- a/internal/repo/collection/collection_repo.go+++ b/internal/repo/collection/collection_repo.go@@ -74,9 +74,9 @@ func (cr *collectionRepo) GetCollectionList(ctx context.Context, collection *ent}// GetOneByObjectIDAndUser get one by object TagID and user-func (cr *collectionRepo) GetOneByObjectIDAndUser(ctx context.Context, userId string, objectId string) (collection *entity.Collection, exist bool, err error) {+func (cr *collectionRepo) GetOneByObjectIDAndUser(ctx context.Context, userID string, objectID string) (collection *entity.Collection, exist bool, err error) {collection = &entity.Collection{}- exist, err = cr.data.DB.Where("user_id = ? and object_id = ?", userId, objectId).Get(collection)+ exist, err = cr.data.DB.Where("user_id = ? and object_id = ?", userID, objectID).Get(collection)if err != nil {return nil, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -84,9 +84,9 @@ func (cr *collectionRepo) GetOneByObjectIDAndUser(ctx context.Context, userId st}// SearchByObjectIDsAndUser search by object IDs and user-func (cr *collectionRepo) SearchByObjectIDsAndUser(ctx context.Context, userId string, objectIds []string) ([]*entity.Collection, error) {+func (cr *collectionRepo) SearchByObjectIDsAndUser(ctx context.Context, userID string, objectIDs []string) ([]*entity.Collection, error) {collectionList := make([]*entity.Collection, 0)- err := cr.data.DB.Where("user_id = ?", userId).In("object_id", objectIds).Find(&collectionList)+ err := cr.data.DB.Where("user_id = ?", userID).In("object_id", objectIDs).Find(&collectionList)if err != nil {return collectionList, err}@@ -94,9 +94,9 @@ func (cr *collectionRepo) SearchByObjectIDsAndUser(ctx context.Context, userId s}// CountByObjectID count by object TagID-func (cr *collectionRepo) CountByObjectID(ctx context.Context, objectId string) (total int64, err error) {+func (cr *collectionRepo) CountByObjectID(ctx context.Context, objectID string) (total int64, err error) {collection := &entity.Collection{}- total, err = cr.data.DB.Where("object_id = ?", objectId).Count(collection)+ total, err = cr.data.DB.Where("object_id = ?", objectID).Count(collection)if err != nil {return 0, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -105,7 +105,6 @@ func (cr *collectionRepo) CountByObjectID(ctx context.Context, objectId string)// GetCollectionPage get collection pagefunc (cr *collectionRepo) GetCollectionPage(ctx context.Context, page, pageSize int, collection *entity.Collection) (collectionList []*entity.Collection, total int64, err error) {-collectionList = make([]*entity.Collection, 0)session := cr.data.DB.NewSession()@@ -124,9 +123,9 @@ func (cr *collectionRepo) GetCollectionPage(ctx context.Context, page, pageSize}// SearchObjectCollected check object is collected or not-func (cr *collectionRepo) SearchObjectCollected(ctx context.Context, userId string, objectIds []string) (map[string]bool, error) {+func (cr *collectionRepo) SearchObjectCollected(ctx context.Context, userID string, objectIds []string) (map[string]bool, error) {collectedMap := make(map[string]bool)- list, err := cr.SearchByObjectIDsAndUser(ctx, userId, objectIds)+ list, err := cr.SearchByObjectIDsAndUser(ctx, userID, objectIds)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()return collectedMap, err@@ -148,7 +147,7 @@ func (cr *collectionRepo) SearchList(ctx context.Context, search *entity.Collectsearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := cr.data.DB.Where("")diff --git a/internal/repo/comment/comment_repo.go b/internal/repo/comment/comment_repo.goindex f2da8db5..a1a7ab90 100644--- a/internal/repo/comment/comment_repo.go+++ b/internal/repo/comment/comment_repo.go@@ -69,7 +69,8 @@ func (cr *commentRepo) UpdateComment(ctx context.Context, comment *entity.Commen// GetComment get comment onefunc (cr *commentRepo) GetComment(ctx context.Context, commentID string) (- comment *entity.Comment, exist bool, err error) {+ comment *entity.Comment, exist bool, err error,+) {comment = &entity.Comment{}exist, err = cr.data.DB.ID(commentID).Get(comment)if err != nil {@@ -80,7 +81,8 @@ func (cr *commentRepo) GetComment(ctx context.Context, commentID string) (// GetCommentPage get comment pagefunc (cr *commentRepo) GetCommentPage(ctx context.Context, commentQuery *comment.CommentQuery) (- commentList []*entity.Comment, total int64, err error) {+ commentList []*entity.Comment, total int64, err error,+) {commentList = make([]*entity.Comment, 0)session := cr.data.DB.NewSession()diff --git a/internal/repo/common/common.go b/internal/repo/common/common.goindex 89b15453..59d1f304 100644--- a/internal/repo/common/common.go+++ b/internal/repo/common/common.go@@ -37,15 +37,13 @@ func (cr *CommonRepo) GetRootObjectID(objectID string) (rootObjectID string, errexist, err = cr.data.DB.ID(objectID).Get(&answer)if !exist {err = errors.BadRequest(reason.ObjectNotFound)- } else {- objectID = answer.QuestionID}case "comment":- exist, err = cr.data.DB.ID(objectID).Get(&comment)+ exist, _ = cr.data.DB.ID(objectID).Get(&comment)if !exist {err = errors.BadRequest(reason.ObjectNotFound)} else {- objectID, err = cr.GetRootObjectID(comment.ObjectID)+ _, err = cr.GetRootObjectID(comment.ObjectID)}default:rootObjectID = objectID@@ -72,7 +70,7 @@ func (cr *CommonRepo) GetObjectIDMap(objectID string) (objectIDMap map[string]st}switch objectType {case "answer":- exist, err = cr.data.DB.ID(objectID).Get(&answer)+ exist, _ = cr.data.DB.ID(objectID).Get(&answer)if !exist {err = errors.BadRequest(reason.ObjectNotFound)} else {@@ -80,7 +78,7 @@ func (cr *CommonRepo) GetObjectIDMap(objectID string) (objectIDMap map[string]stID = answer.ID}case "comment":- exist, err = cr.data.DB.ID(objectID).Get(&comment)+ exist, _ = cr.data.DB.ID(objectID).Get(&comment)if !exist {err = errors.BadRequest(reason.ObjectNotFound)} else {diff --git a/internal/repo/notification/notification_repo.go b/internal/repo/notification/notification_repo.goindex deaf431a..9df46422 100644--- a/internal/repo/notification/notification_repo.go+++ b/internal/repo/notification/notification_repo.go@@ -102,7 +102,7 @@ func (nr *notificationRepo) SearchList(ctx context.Context, search *schema.Notifsearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := nr.data.DB.Where("")diff --git a/internal/repo/question_repo.go b/internal/repo/question_repo.goindex f6f4e40b..d7b9ff8b 100644--- a/internal/repo/question_repo.go+++ b/internal/repo/question_repo.go@@ -64,27 +64,27 @@ func (qr *questionRepo) UpdateQuestion(ctx context.Context, question *entity.Quereturn}-func (qr *questionRepo) UpdatePvCount(ctx context.Context, questionId string) (err error) {+func (qr *questionRepo) UpdatePvCount(ctx context.Context, questionID string) (err error) {question := &entity.Question{}- _, err = qr.data.DB.Where("id =?", questionId).Incr("view_count", 1).Update(question)+ _, err = qr.data.DB.Where("id =?", questionID).Incr("view_count", 1).Update(question)if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}return nil}-func (qr *questionRepo) UpdateAnswerCount(ctx context.Context, questionId string, num int) (err error) {+func (qr *questionRepo) UpdateAnswerCount(ctx context.Context, questionID string, num int) (err error) {question := &entity.Question{}- _, err = qr.data.DB.Where("id =?", questionId).Incr("answer_count", num).Update(question)+ _, err = qr.data.DB.Where("id =?", questionID).Incr("answer_count", num).Update(question)if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}return nil}-func (qr *questionRepo) UpdateCollectionCount(ctx context.Context, questionId string, num int) (err error) {+func (qr *questionRepo) UpdateCollectionCount(ctx context.Context, questionID string, num int) (err error) {question := &entity.Question{}- _, err = qr.data.DB.Where("id =?", questionId).Incr("collection_count", num).Update(question)+ _, err = qr.data.DB.Where("id =?", questionID).Incr("collection_count", num).Update(question)if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -119,7 +119,8 @@ func (qr *questionRepo) UpdateLastAnswer(ctx context.Context, question *entity.Q// GetQuestion get question onefunc (qr *questionRepo) GetQuestion(ctx context.Context, id string) (- question *entity.Question, exist bool, err error) {+ question *entity.Question, exist bool, err error,+) {question = &entity.Question{}question.ID = idexist, err = qr.data.DB.Where("id = ?", id).Get(question)@@ -179,7 +180,7 @@ func (qr *questionRepo) SearchList(ctx context.Context, search *schema.QuestionSsearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := qr.data.DB.Table("question")@@ -187,7 +188,7 @@ func (qr *questionRepo) SearchList(ctx context.Context, search *schema.QuestionSif len(search.TagIDs) > 0 {session = session.Join("LEFT", "tag_rel", "question.id = tag_rel.object_id")session = session.And("tag_rel.tag_id =?", search.TagIDs[0])- //session = session.In("tag_rel.tag_id ", search.TagIDs)+ // session = session.In("tag_rel.tag_id ", search.TagIDs)session = session.And("tag_rel.status =?", entity.TagRelStatusAvailable)}@@ -199,8 +200,8 @@ func (qr *questionRepo) SearchList(ctx context.Context, search *schema.QuestionS// if search.Status > 0 {// session = session.And("question.status = ?", search.Status)// }- //switch- //newest, active,frequent,score,unanswered+ // switch+ // newest, active,frequent,score,unansweredswitch search.Order {case "newest":session = session.OrderBy("question.created_at desc")@@ -234,7 +235,7 @@ func (qr *questionRepo) CmsSearchList(ctx context.Context, search *schema.CmsQuesearch.Page = 0}if search.PageSize == 0 {- search.PageSize = constant.Default_PageSize+ search.PageSize = constant.DefaultPageSize}offset := search.Page * search.PageSizesession := qr.data.DB.Table("question")diff --git a/internal/repo/rank/user_rank_repo.go b/internal/repo/rank/user_rank_repo.goindex 8f473e53..13996817 100644--- a/internal/repo/rank/user_rank_repo.go+++ b/internal/repo/rank/user_rank_repo.go@@ -34,26 +34,28 @@ func NewUserRankRepo(data *data.Data, configRepo config.ConfigRepo) rank.UserRan// session is need provider, it means this action must be success or failure// if outer action is failed then this action is need rollbackfunc (ur *UserRankRepo) TriggerUserRank(ctx context.Context,- session *xorm.Session, userId string, deltaRank int, activityType int) (isReachStandard bool, err error) {+ session *xorm.Session, userID string, deltaRank int, activityType int,+) (isReachStandard bool, err error) {if deltaRank == 0 {return false, nil}if deltaRank < 0 {// if user rank is lower than 1 after this action, then user rank will be set to 1 only.- isReachMin, err := ur.checkUserMinRank(ctx, session, userId, activityType)+ var isReachMin bool+ isReachMin, err = ur.checkUserMinRank(ctx, session, userID, activityType)if err != nil {return false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}if isReachMin {- _, err = session.Where(builder.Eq{"id": userId}).Update(&entity.User{Rank: 1})+ _, err = session.Where(builder.Eq{"id": userID}).Update(&entity.User{Rank: 1})if err != nil {return false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}return false, nil}} else {- isReachStandard, err = ur.checkUserTodayRank(ctx, session, userId, activityType)+ isReachStandard, err = ur.checkUserTodayRank(ctx, session, userID, activityType)if err != nil {return false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -61,7 +63,7 @@ func (ur *UserRankRepo) TriggerUserRank(ctx context.Context,return isReachStandard, nil}}- _, err = session.Where(builder.Eq{"id": userId}).Incr("`rank`", deltaRank).Update(&entity.User{})+ _, err = session.Where(builder.Eq{"id": userID}).Incr("`rank`", deltaRank).Update(&entity.User{})if err != nil {return false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -69,7 +71,8 @@ func (ur *UserRankRepo) TriggerUserRank(ctx context.Context,}func (ur *UserRankRepo) checkUserMinRank(ctx context.Context, session *xorm.Session, userID string, deltaRank int) (- isReachStandard bool, err error) {+ isReachStandard bool, err error,+) {bean := &entity.User{ID: userID}_, err = session.Select("rank").Get(bean)if err != nil {@@ -83,11 +86,13 @@ func (ur *UserRankRepo) checkUserMinRank(ctx context.Context, session *xorm.Sess}func (ur *UserRankRepo) checkUserTodayRank(ctx context.Context,- session *xorm.Session, userID string, activityType int) (isReachStandard bool, err error) {+ session *xorm.Session, userID string, activityType int,+) (isReachStandard bool, err error) {// exclude daily rank- exclude, err := ur.configRepo.GetArrayString("daily_rank_limit.exclude")+ exclude, _ := ur.configRepo.GetArrayString("daily_rank_limit.exclude")for _, item := range exclude {- excludeActivityType, err := ur.configRepo.GetInt(item)+ var excludeActivityType int+ excludeActivityType, err = ur.configRepo.GetInt(item)if err != nil {return false, err}@@ -123,14 +128,15 @@ func (ur *UserRankRepo) checkUserTodayRank(ctx context.Context,return true, nil}-func (ur *UserRankRepo) UserRankPage(ctx context.Context, userId string, page, pageSize int) (- rankPage []*entity.Activity, total int64, err error) {+func (ur *UserRankRepo) UserRankPage(ctx context.Context, userID string, page, pageSize int) (+ rankPage []*entity.Activity, total int64, err error,+) {rankPage = make([]*entity.Activity, 0)session := ur.data.DB.Where(builder.Eq{"has_rank": 1}.And(builder.Eq{"cancelled": 0}))session.Desc("created_at")- cond := &entity.Activity{UserID: userId}+ cond := &entity.Activity{UserID: userID}total, err = pager.Help(page, pageSize, &rankPage, cond, session)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()diff --git a/internal/repo/report/report_repo.go b/internal/repo/report/report_repo.goindex bb8246a9..1ebf820e 100644--- a/internal/repo/report/report_repo.go+++ b/internal/repo/report/report_repo.go@@ -86,7 +86,8 @@ func (ar *reportRepo) GetByID(ctx context.Context, id string) (report entity.Repfunc (ar *reportRepo) UpdateByID(ctx context.Context,id string,- handleData entity.Report) (err error) {+ handleData entity.Report,+) (err error) {_, err = ar.data.DB.ID(id).Update(&handleData)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()diff --git a/internal/repo/revision/revision_repo.go b/internal/repo/revision/revision_repo.goindex 4529caed..9cb547fb 100644--- a/internal/repo/revision/revision_repo.go+++ b/internal/repo/revision/revision_repo.go@@ -81,7 +81,8 @@ func (rr *revisionRepo) UpdateObjectRevisionId(ctx context.Context, revision *en// GetRevision get revision onefunc (rr *revisionRepo) GetRevision(ctx context.Context, id string) (- revision *entity.Revision, exist bool, err error) {+ revision *entity.Revision, exist bool, err error,+) {revision = &entity.Revision{}exist, err = rr.data.DB.ID(id).Get(revision)if err != nil {@@ -92,7 +93,8 @@ func (rr *revisionRepo) GetRevision(ctx context.Context, id string) (// GetLastRevisionByObjectID get object's last revision by object TagIDfunc (rr *revisionRepo) GetLastRevisionByObjectID(ctx context.Context, objectID string) (- revision *entity.Revision, exist bool, err error) {+ revision *entity.Revision, exist bool, err error,+) {revision = &entity.Revision{}exist, err = rr.data.DB.Where("object_id = ?", objectID).OrderBy("create_time DESC").Get(revision)if err != nil {diff --git a/internal/repo/search_repo.go b/internal/repo/search_repo.goindex abf53360..6ced77e6 100644--- a/internal/repo/search_repo.go+++ b/internal/repo/search_repo.go@@ -21,7 +21,7 @@ import ()var (- q_fields = []string{+ qFields = []string{"`question`.`id`","`question`.`id` as `question_id`","`title`",@@ -34,7 +34,7 @@ var ("`question`.`status` as `status`","`post_update_time`",}- a_fields = []string{+ aFields = []string{"`answer`.`id` as `id`","`question_id`","`question`.`title` as `title`",@@ -70,8 +70,8 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,var (b *builder.Builderub *builder.Builder- qfs = q_fields- afs = a_fields+ qfs = qFields+ afs = aFieldsargsQ = []interface{}{}argsA = []interface{}{})@@ -141,11 +141,11 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,b = b.Union("all", ub)- querySql, _, err := builder.MySQL().Select("*").From(b, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()+ querySQL, _, err := builder.MySQL().Select("*").From(b, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()if err != nil {return}- countSql, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()+ countSQL, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()if err != nil {return}@@ -153,11 +153,11 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,queryArgs := []interface{}{}countArgs := []interface{}{}- queryArgs = append(queryArgs, querySql)+ queryArgs = append(queryArgs, querySQL)queryArgs = append(queryArgs, argsQ...)queryArgs = append(queryArgs, argsA...)- countArgs = append(countArgs, countSql)+ countArgs = append(countArgs, countSQL)countArgs = append(countArgs, argsQ...)countArgs = append(countArgs, argsA...)@@ -182,7 +182,7 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,// SearchQuestions search question datafunc (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limitNoAccepted bool, answers, page, size int, order string) (resp []schema.SearchResp, total int64, err error) {var (- qfs = q_fields+ qfs = qFieldsargs = []interface{}{})if order == "relevance" {@@ -223,18 +223,18 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limitqueryArgs := []interface{}{}countArgs := []interface{}{}- querySql, _, err := b.OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()+ querySQL, _, err := b.OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()if err != nil {return}- countSql, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()+ countSQL, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()if err != nil {return}- queryArgs = append(queryArgs, querySql)+ queryArgs = append(queryArgs, querySQL)queryArgs = append(queryArgs, args...)- countArgs = append(countArgs, countSql)+ countArgs = append(countArgs, countSQL)countArgs = append(countArgs, args...)res, err := sr.data.DB.Query(queryArgs...)@@ -250,10 +250,6 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limitif len(tr) != 0 {total = converter.StringToInt64(string(tr[0]["total"]))}- if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- return- }resp, err = sr.parseResult(ctx, res)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -264,7 +260,7 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limit// SearchAnswers search answer datafunc (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAccepted bool, questionID string, page, size int, order string) (resp []schema.SearchResp, total int64, err error) {var (- afs = a_fields+ afs = aFieldsargs = []interface{}{})if order == "relevance" {@@ -289,8 +285,8 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAc}if limitAccepted {- b.Where(builder.Eq{"adopted": schema.Answer_Adopted_Enable})- args = append(args, schema.Answer_Adopted_Enable)+ b.Where(builder.Eq{"adopted": schema.AnswerAdoptedEnable})+ args = append(args, schema.AnswerAdoptedEnable)}if questionID != "" {@@ -301,18 +297,18 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAcqueryArgs := []interface{}{}countArgs := []interface{}{}- querySql, _, err := b.OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()+ querySQL, _, err := b.OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()if err != nil {return}- countSql, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()+ countSQL, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()if err != nil {return}- queryArgs = append(queryArgs, querySql)+ queryArgs = append(queryArgs, querySQL)queryArgs = append(queryArgs, args...)- countArgs = append(countArgs, countSql)+ countArgs = append(countArgs, countSQL)countArgs = append(countArgs, args...)res, err := sr.data.DB.Query(queryArgs...)@@ -326,10 +322,6 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAc}total = converter.StringToInt64(string(tr[0]["total"]))- if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- return- }resp, err = sr.parseResult(ctx, res)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -438,7 +430,7 @@ func (sr *searchRepo) userBasicInfoFormat(ctx context.Context, dbinfo *entity.UsAvatar: dbinfo.Avatar,Website: dbinfo.Website,Location: dbinfo.Location,- IpInfo: dbinfo.IPInfo,+ IPInfo: dbinfo.IPInfo,}}@@ -451,24 +443,24 @@ func cutOutParsedText(parsedText string) string {return parsedText}-func addRelevanceField(search_fields, words, fields []string) (res []string, args []interface{}) {- var relevanceRes = []string{}+func addRelevanceField(searchFields, words, fields []string) (res []string, args []interface{}) {+ relevanceRes := []string{}args = []interface{}{}- for _, search_field := range search_fields {+ for _, searchField := range searchFields {var (- relevance = "(LENGTH(" + search_field + ") - LENGTH(%s))"- replacement = "REPLACE(%s, ?, '')"- replace_field = search_field- replaced string- argsField = []interface{}{}+ relevance = "(LENGTH(" + searchField + ") - LENGTH(%s))"+ replacement = "REPLACE(%s, ?, '')"+ replaceField = searchField+ replaced string+ argsField = []interface{}{})res = fieldsfor i, word := range words {if i == 0 {argsField = append(argsField, word)- replaced = fmt.Sprintf(replacement, replace_field)+ replaced = fmt.Sprintf(replacement, replaceField)} else {argsField = append(argsField, word)replaced = fmt.Sprintf(replacement, replaced)diff --git a/internal/repo/siteinfo_repo.go b/internal/repo/siteinfo_repo.goindex 579d9bb1..4e6ad8a6 100644--- a/internal/repo/siteinfo_repo.go+++ b/internal/repo/siteinfo_repo.go@@ -27,7 +27,7 @@ func (sr *siteInfoRepo) SaveByType(ctx context.Context, siteType string, data *eold = &entity.SiteInfo{}exist bool)- exist, err = sr.data.DB.Where(builder.Eq{"type": siteType}).Get(old)+ exist, _ = sr.data.DB.Where(builder.Eq{"type": siteType}).Get(old)if exist {_, err = sr.data.DB.ID(old.ID).Update(data)if err != nil {diff --git a/internal/repo/tag/tag_rel_repo.go b/internal/repo/tag/tag_rel_repo.goindex c54bf8c0..c3926ba2 100644--- a/internal/repo/tag/tag_rel_repo.go+++ b/internal/repo/tag/tag_rel_repo.go@@ -32,8 +32,8 @@ func (tr *tagListRepo) AddTagRelList(ctx context.Context, tagList []*entity.TagR}// RemoveTagRelListByObjectID delete tag list-func (tr *tagListRepo) RemoveTagRelListByObjectID(ctx context.Context, objectId string) (err error) {- _, err = tr.data.DB.Where("object_id = ?", objectId).Update(&entity.TagRel{Status: entity.TagRelStatusDeleted})+func (tr *tagListRepo) RemoveTagRelListByObjectID(ctx context.Context, objectID string) (err error) {+ _, err = tr.data.DB.Where("object_id = ?", objectID).Update(&entity.TagRel{Status: entity.TagRelStatusDeleted})if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -50,10 +50,11 @@ func (tr *tagListRepo) RemoveTagRelListByIDs(ctx context.Context, ids []int64) (}// GetObjectTagRelWithoutStatus get object tag relation no matter status-func (tr *tagListRepo) GetObjectTagRelWithoutStatus(ctx context.Context, objectId, tagID string) (- tagRel *entity.TagRel, exist bool, err error) {+func (tr *tagListRepo) GetObjectTagRelWithoutStatus(ctx context.Context, objectID, tagID string) (+ tagRel *entity.TagRel, exist bool, err error,+) {tagRel = &entity.TagRel{}- session := tr.data.DB.Where("object_id = ?", objectId).And("tag_id = ?", tagID)+ session := tr.data.DB.Where("object_id = ?", objectID).And("tag_id = ?", tagID)exist, err = session.Get(tagRel)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -71,9 +72,9 @@ func (tr *tagListRepo) EnableTagRelByIDs(ctx context.Context, ids []int64) (err}// GetObjectTagRelList get object tag relation list all-func (tr *tagListRepo) GetObjectTagRelList(ctx context.Context, objectId string) (tagListList []*entity.TagRel, err error) {+func (tr *tagListRepo) GetObjectTagRelList(ctx context.Context, objectID string) (tagListList []*entity.TagRel, err error) {tagListList = make([]*entity.TagRel, 0)- session := tr.data.DB.Where("object_id = ?", objectId)+ session := tr.data.DB.Where("object_id = ?", objectID)session.Where("status = ?", entity.TagRelStatusAvailable)err = session.Find(&tagListList)if err != nil {diff --git a/internal/repo/tag/tag_repo.go b/internal/repo/tag/tag_repo.goindex 5243402e..e5a5b835 100644--- a/internal/repo/tag/tag_repo.go+++ b/internal/repo/tag/tag_repo.go@@ -34,7 +34,8 @@ func NewTagRepo(// AddTagList add tagfunc (tr *tagRepo) AddTagList(ctx context.Context, tagList []*entity.Tag) (err error) {for _, item := range tagList {- ID, err := tr.uniqueIDRepo.GenUniqueID(ctx, item.TableName())+ var ID int64+ ID, err = tr.uniqueIDRepo.GenUniqueID(ctx, item.TableName())if err != nil {return err}@@ -128,7 +129,8 @@ func (tr *tagRepo) UpdateTagQuestionCount(ctx context.Context, tagID string, que// UpdateTagSynonym update synonym tagfunc (tr *tagRepo) UpdateTagSynonym(ctx context.Context, tagSlugNameList []string, mainTagID int64,- mainTagSlugName string) (err error) {+ mainTagSlugName string,+) (err error) {bean := &entity.Tag{MainTagID: mainTagID, MainTagSlugName: mainTagSlugName}session := tr.data.DB.In("slug_name", tagSlugNameList).MustCols("main_tag_id", "main_tag_slug_name")_, err = session.Update(bean)@@ -140,7 +142,8 @@ func (tr *tagRepo) UpdateTagSynonym(ctx context.Context, tagSlugNameList []strin// GetTagByID get tag onefunc (tr *tagRepo) GetTagByID(ctx context.Context, tagID string) (- tag *entity.Tag, exist bool, err error) {+ tag *entity.Tag, exist bool, err error,+) {tag = &entity.Tag{}session := tr.data.DB.Where(builder.Eq{"id": tagID})session.Where(builder.Eq{"status": entity.TagStatusAvailable})@@ -164,7 +167,8 @@ func (tr *tagRepo) GetTagList(ctx context.Context, tag *entity.Tag) (tagList []*// GetTagPage get tag pagefunc (tr *tagRepo) GetTagPage(ctx context.Context, page, pageSize int, tag *entity.Tag, queryCond string) (- tagList []*entity.Tag, total int64, err error) {+ tagList []*entity.Tag, total int64, err error,+) {tagList = make([]*entity.Tag, 0)session := tr.data.DB.NewSession()diff --git a/internal/repo/user/user_backyard_repo.go b/internal/repo/user/user_backyard_repo.goindex 06ce7d2f..367a646c 100644--- a/internal/repo/user/user_backyard_repo.go+++ b/internal/repo/user/user_backyard_repo.go@@ -29,7 +29,8 @@ func NewUserBackyardRepo(data *data.Data) user_backyard.UserBackyardRepo {// UpdateUserStatus update user statusfunc (ur *userBackyardRepo) UpdateUserStatus(ctx context.Context, userID string, userStatus, mailStatus int,- email string) (err error) {+ email string,+) (err error) {cond := &entity.User{Status: userStatus, MailStatus: mailStatus, EMail: email}switch userStatus {case entity.UserStatusSuspended:@@ -71,11 +72,12 @@ func (ur *userBackyardRepo) GetUserInfo(ctx context.Context, userID string) (usefunc (ur *userBackyardRepo) GetUserPage(ctx context.Context, page, pageSize int, user *entity.User) (users []*entity.User, total int64, err error) {users = make([]*entity.User, 0)session := ur.data.DB.NewSession()- if user.Status == entity.UserStatusDeleted {+ switch user.Status {+ case entity.UserStatusDeleted:session.Desc("deleted_at")- } else if user.Status == entity.UserStatusSuspended {+ case entity.UserStatusSuspended:session.Desc("suspended_at")- } else {+ default:session.Desc("created_at")}total, err = pager.Help(page, pageSize, &users, user, session)diff --git a/internal/schema/answer_schema.go b/internal/schema/answer_schema.goindex fde11165..0c396865 100644--- a/internal/schema/answer_schema.go+++ b/internal/schema/answer_schema.go@@ -9,44 +9,44 @@ type RemoveAnswerReq struct {}const (- Answer_Adopted_Failed = 1- Answer_Adopted_Enable = 2+ AnswerAdoptedFailed = 1+ AnswerAdoptedEnable = 2)type AnswerAddReq struct {- QuestionId string `json:"question_id" ` // question_id+ QuestionID string `json:"question_id" ` // question_idContent string `json:"content" ` // content- Html string `json:"html" ` // html+ HTML string `json:"html" ` // htmlUserID string `json:"-" ` // user_id}type AnswerUpdateReq struct {ID string `json:"id"` // id- QuestionId string `json:"question_id" ` // question_id+ QuestionID string `json:"question_id" ` // question_idUserID string `json:"-" ` // user_idTitle string `json:"title" ` // titleContent string `json:"content"` // content- Html string `json:"html" ` // html- EditSummary string `validate:"omitempty" json:"edit_summary"` //edit_summary+ HTML string `json:"html" ` // html+ EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary}type AnswerList struct {- QuestionId string `json:"question_id" form:"question_id"` // question_id+ QuestionID string `json:"question_id" form:"question_id"` // question_idOrder string `json:"order" form:"order"` // 1 Default 2 time- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page sizeLoginUserID string `json:"-" `}type AnswerInfo struct {ID string `json:"id" xorm:"id"` // id- QuestionId string `json:"question_id" xorm:"question_id"` // question_id+ QuestionID string `json:"question_id" xorm:"question_id"` // question_idContent string `json:"content" xorm:"content"` // content- Html string `json:"html" xorm:"html"` // html+ HTML string `json:"html" xorm:"html"` // htmlCreateTime int64 `json:"create_time" xorm:"created"` // create_timeUpdateTime int64 `json:"update_time" xorm:"updated"` // update_timeAdopted int `json:"adopted"` // 1 Failed 2 Adopted- UserId string `json:"-" `+ UserID string `json:"-" `UserInfo *UserBasicInfo `json:"user_info,omitempty"`UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`Collected bool `json:"collected"`@@ -60,12 +60,12 @@ type AnswerInfo struct {type AdminAnswerInfo struct {ID string `json:"id"`- QuestionId string `json:"question_id"`+ QuestionID string `json:"question_id"`Description string `json:"description"`CreateTime int64 `json:"create_time"`UpdateTime int64 `json:"update_time"`Adopted int `json:"adopted"`- UserId string `json:"-" `+ UserID string `json:"-" `UserInfo *UserBasicInfo `json:"user_info"`VoteCount int `json:"vote_count"`QuestionInfo struct {diff --git a/internal/schema/collection_group_schema.go b/internal/schema/collection_group_schema.goindex 19d6f4d5..96658213 100644--- a/internal/schema/collection_group_schema.go+++ b/internal/schema/collection_group_schema.go@@ -3,8 +3,8 @@ package schemaimport "time"const (- CG_DEFAULT = 1- CG_DIY = 2+ CGDefault = 1+ CGDIY = 2)// CollectionSwitchReq switch collection requestdiff --git a/internal/schema/forbidden_schema.go b/internal/schema/forbidden_schema.goindex 7ac7c565..e8ae7a06 100644--- a/internal/schema/forbidden_schema.go+++ b/internal/schema/forbidden_schema.go@@ -2,7 +2,7 @@ package schemaconst (ForbiddenReasonTypeInactive = "inactive"- ForbiddenReasonTypeUrlExpired = "url_expired"+ ForbiddenReasonTypeURLExpired = "url_expired"ForbiddenReasonTypeUserSuspended = "suspended")diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.goindex a619c454..24508fb2 100644--- a/internal/schema/question_schema.go+++ b/internal/schema/question_schema.go@@ -5,12 +5,11 @@ type RemoveQuestionReq struct {// question idID string `validate:"required" comment:"question id" json:"id"`UserID string `json:"-" ` // user_id-}type CloseQuestionReq struct {ID string `validate:"required" comment:"question id" json:"id"`- UserId string `json:"-" ` // user_id+ UserID string `json:"-" ` // user_idCloseType int `json:"close_type" ` // close_typeCloseMsg string `json:"close_msg" ` // close_type}@@ -26,7 +25,7 @@ type QuestionAdd struct {// contentContent string `validate:"required,gte=6,lte=65535" json:"content"`// html- Html string `validate:"required,gte=6,lte=65535" json:"html"`+ HTML string `validate:"required,gte=6,lte=65535" json:"html"`// tagsTags []*TagItem `validate:"required,dive" json:"tags"`// user id@@ -41,7 +40,7 @@ type QuestionUpdate struct {// contentContent string `validate:"required,gte=6,lte=65535" json:"content"`// html- Html string `validate:"required,gte=6,lte=65535" json:"html"`+ HTML string `validate:"required,gte=6,lte=65535" json:"html"`// tagsTags []*TagItem `validate:"required,dive" json:"tags"`// edit summary@@ -65,7 +64,7 @@ type QuestionInfo struct {ID string `json:"id" `Title string `json:"title" xorm:"title"` // titleContent string `json:"content" xorm:"content"` // content- Html string `json:"html" xorm:"html"` // html+ HTML string `json:"html" xorm:"html"` // htmlTags []*TagResp `json:"tags" ` // tagsViewCount int `json:"view_count" xorm:"view_count"` // view_countUniqueViewCount int `json:"unique_view_count" xorm:"unique_view_count"` // unique_view_count@@ -73,15 +72,15 @@ type QuestionInfo struct {AnswerCount int `json:"answer_count" xorm:"answer_count"` // answer countCollectionCount int `json:"collection_count" xorm:"collection_count"` // collection countFollowCount int `json:"follow_count" xorm:"follow_count"` // follow count- AcceptedAnswerId string `json:"accepted_answer_id" ` // accepted_answer_id- LastAnswerId string `json:"last_answer_id" ` // last_answer_id+ AcceptedAnswerID string `json:"accepted_answer_id" ` // accepted_answer_id+ LastAnswerID string `json:"last_answer_id" ` // last_answer_idCreateTime int64 `json:"create_time" ` // create_timeUpdateTime int64 `json:"-"` // update_timePostUpdateTime int64 `json:"update_time"`QuestionUpdateTime int64 `json:"edit_time"`Status int `json:"status"`Operation *Operation `json:"operation,omitempty"`- UserId string `json:"-" `+ UserID string `json:"-" `UserInfo *UserBasicInfo `json:"user_info"`UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`LastAnsweredUserInfo *UserBasicInfo `json:"last_answered_user_info,omitempty"`@@ -108,10 +107,10 @@ type AdminQuestionInfo struct {}type Operation struct {- Operation_Type string `json:"operation_type"`- Operation_Description string `json:"operation_description"`- Operation_Msg string `json:"operation_msg"`- Operation_Time int64 `json:"operation_time"`+ OperationType string `json:"operation_type"`+ OperationDescription string `json:"operation_description"`+ OperationMsg string `json:"operation_msg"`+ OperationTime int64 `json:"operation_time"`}type GetCloseTypeResp struct {@@ -151,25 +150,25 @@ type UserQuestionInfo struct {AnswerCount int `json:"answer_count"`CollectionCount int `json:"collection_count"`CreateTime int `json:"create_time"`- AcceptedAnswerId string `json:"accepted_answer_id"`+ AcceptedAnswerID string `json:"accepted_answer_id"`Status string `json:"status"`}type QuestionSearch struct {- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size- Order string `json:"order" form:"order"` //Search order by- Tags []string `json:"tags" form:"tags"` //Search tag- TagIDs []string `json:"-" form:"-"` //Search tag- UserName string `json:"username" form:"username"` //Search username+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page size+ Order string `json:"order" form:"order"` // Search order by+ Tags []string `json:"tags" form:"tags"` // Search tag+ TagIDs []string `json:"-" form:"-"` // Search tag+ UserName string `json:"username" form:"username"` // Search usernameUserID string `json:"-" form:"-"`}type CmsQuestionSearch struct {- Page int `json:"page" form:"page"` //Query number of pages- PageSize int `json:"page_size" form:"page_size"` //Search page size+ Page int `json:"page" form:"page"` // Query number of pages+ PageSize int `json:"page_size" form:"page_size"` // Search page sizeStatus int `json:"-" form:"-"`- StatusStr string `json:"status" form:"status"` //Status 1 Available 2 closed 10 UserDeleted+ StatusStr string `json:"status" form:"status"` // Status 1 Available 2 closed 10 UserDeleted}type AdminSetQuestionStatusRequest struct {diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.goindex 7680c5db..d6b70c39 100644--- a/internal/schema/tag_schema.go+++ b/internal/schema/tag_schema.go@@ -107,7 +107,7 @@ func (tr *GetTagPageResp) GetExcerpt() {}type TagChange struct {- ObjectId string `json:"object_id"` // object_id+ ObjectID string `json:"object_id"` // object_idTags []*TagItem `json:"tags"` // tags name// user idUserID string `json:"-"`diff --git a/internal/schema/user_schema.go b/internal/schema/user_schema.goindex 757926c7..2910a065 100644--- a/internal/schema/user_schema.go+++ b/internal/schema/user_schema.go@@ -55,7 +55,7 @@ type GetUserResp struct {// bio markdownBio string `json:"bio"`// bio html- BioHtml string `json:"bio_html"`+ BioHTML string `json:"bio_html"`// websiteWebsite string `json:"website"`// location@@ -114,7 +114,7 @@ type GetOtherUserInfoByUsernameResp struct {// bio markdownBio string `json:"bio"`// bio html- BioHtml string `json:"bio_html"`+ BioHTML string `json:"bio_html"`// websiteWebsite string `json:"website"`// location@@ -146,20 +146,19 @@ func (r *GetOtherUserInfoByUsernameResp) GetFromUserEntity(userInfo *entity.Userr.StatusMsg = statusMsgShow}}-}const (- Mail_State_Pass = 1- Mail_State_Verifi = 2+ MailStatePass = 1+ MailStateVerifi = 2- Notice_Status_On = 1- Notice_Status_Off = 2+ NoticeStatusOn = 1+ NoticeStatusOff = 2- //ActionRecord ReportType- ActionRecord_Type_Login = "login"- ActionRecord_Type_Email = "e_mail"- ActionRecord_Type_Find_Pass = "find_pass"+ // ActionRecord ReportType+ ActionRecordTypeLogin = "login"+ ActionRecordTypeEmail = "e_mail"+ ActionRecordTypeFindPass = "find_pass")var UserStatusShow = map[int]string{@@ -167,6 +166,7 @@ var UserStatusShow = map[int]string{9: "forbidden",10: "deleted",}+var UserStatusShowMsg = map[int]string{1: "",9: "<strong>This user was suspended forever.</strong> This user doesn’t meet a community guideline.",@@ -207,7 +207,7 @@ func (u *UserRegisterReq) Check() (errField *validator.ErrorField, err error) {// UserModifyPassWordRequesttype UserModifyPassWordRequest struct {- UserId string `json:"-" ` // user_id+ UserID string `json:"-" ` // user_idOldPass string `json:"old_pass" ` // old passwordPass string `json:"pass" ` // password}@@ -234,13 +234,13 @@ type UpdateInfoRequest struct {// bioBio string `validate:"omitempty,gt=0,lte=4096" json:"bio"`// bio- BioHtml string `validate:"omitempty,gt=0,lte=4096" json:"bio_html"`+ BioHTML string `validate:"omitempty,gt=0,lte=4096" json:"bio_html"`// websiteWebsite string `validate:"omitempty,gt=0,lte=500" json:"website"`// locationLocation string `validate:"omitempty,gt=0,lte=100" json:"location"`// user id- UserId string `json:"-" `+ UserID string `json:"-" `}func (u *UpdateInfoRequest) Check() (errField *validator.ErrorField, err error) {@@ -283,7 +283,7 @@ func (u *UserRePassWordRequest) Check() (errField *validator.ErrorField, err err}type UserNoticeSetRequest struct {- UserId string `json:"-" ` // user_id+ UserID string `json:"-" ` // user_idNoticeSwitch bool `json:"notice_switch" `}@@ -294,7 +294,7 @@ type UserNoticeSetResp struct {type ActionRecordReq struct {// actionAction string `validate:"required,oneof=login e_mail find_pass" form:"action"`- Ip string `json:"-"`+ IP string `json:"-"`}type ActionRecordResp struct {@@ -311,7 +311,7 @@ type UserBasicInfo struct {Avatar string `json:"avatar" ` // avatarWebsite string `json:"website" ` // websiteLocation string `json:"location" ` // location- IpInfo string `json:"ip_info"` // ip info+ IPInfo string `json:"ip_info"` // ip infoStatus string `json:"status"` // status}diff --git a/internal/service/action/captcha_service.go b/internal/service/action/captcha_service.goindex 380e2a8c..9d79c0fe 100644--- a/internal/service/action/captcha_service.go+++ b/internal/service/action/captcha_service.go@@ -36,7 +36,7 @@ func NewCaptchaService(captchaRepo CaptchaRepo) *CaptchaService {// ActionRecord action recordfunc (cs *CaptchaService) ActionRecord(ctx context.Context, req *schema.ActionRecordReq) (resp *schema.ActionRecordResp, err error) {resp = &schema.ActionRecordResp{}- num, err := cs.captchaRepo.GetActionType(ctx, req.Ip, req.Action)+ num, err := cs.captchaRepo.GetActionType(ctx, req.IP, req.Action)if err != nil {num = 0}@@ -51,7 +51,8 @@ func (cs *CaptchaService) ActionRecord(ctx context.Context, req *schema.ActionRe// ActionRecordVerifyCaptcha// Verify that you need to enter a CAPTCHA, and that the CAPTCHA is correctfunc (cs *CaptchaService) ActionRecordVerifyCaptcha(- ctx context.Context, actionType string, ip string, id string, VerifyValue string) bool {+ ctx context.Context, actionType string, ip string, id string, VerifyValue string,+) bool {num, cahceErr := cs.captchaRepo.GetActionType(ctx, ip, actionType)if cahceErr != nil {return truediff --git a/internal/service/answer_common/answer.go b/internal/service/answer_common/answer.goindex 7fc65a6f..2e262b8e 100644--- a/internal/service/answer_common/answer.go+++ b/internal/service/answer_common/answer.go@@ -14,9 +14,9 @@ type AnswerRepo interface {GetAnswer(ctx context.Context, id string) (answer *entity.Answer, exist bool, err error)GetAnswerList(ctx context.Context, answer *entity.Answer) (answerList []*entity.Answer, err error)GetAnswerPage(ctx context.Context, page, pageSize int, answer *entity.Answer) (answerList []*entity.Answer, total int64, err error)- UpdateAdopted(ctx context.Context, id string, questionId string) error+ UpdateAdopted(ctx context.Context, id string, questionID string) errorGetByID(ctx context.Context, id string) (*entity.Answer, bool, error)- GetByUserIdQuestionId(ctx context.Context, userId string, questionId string) (*entity.Answer, bool, error)+ GetByUserIDQuestionID(ctx context.Context, userID string, questionID string) (*entity.Answer, bool, error)SearchList(ctx context.Context, search *entity.AnswerSearch) ([]*entity.Answer, int64, error)CmsSearchList(ctx context.Context, search *entity.CmsAnswerSearch) ([]*entity.Answer, int64, error)UpdateAnswerStatus(ctx context.Context, answer *entity.Answer) (err error)@@ -33,8 +33,8 @@ func NewAnswerCommon(answerRepo AnswerRepo) *AnswerCommon {}}-func (as *AnswerCommon) SearchAnswered(ctx context.Context, userId, questionId string) (bool, error) {- _, has, err := as.answerRepo.GetByUserIdQuestionId(ctx, userId, questionId)+func (as *AnswerCommon) SearchAnswered(ctx context.Context, userID, questionID string) (bool, error) {+ _, has, err := as.answerRepo.GetByUserIDQuestionID(ctx, userID, questionID)if err != nil {return has, err}@@ -56,26 +56,26 @@ func (as *AnswerCommon) Search(ctx context.Context, search *entity.AnswerSearch)func (as *AnswerCommon) ShowFormat(ctx context.Context, data *entity.Answer) *schema.AnswerInfo {info := schema.AnswerInfo{}info.ID = data.ID- info.QuestionId = data.QuestionID+ info.QuestionID = data.QuestionIDinfo.Content = data.OriginalText- info.Html = data.ParsedText+ info.HTML = data.ParsedTextinfo.Adopted = data.Adoptedinfo.VoteCount = data.VoteCountinfo.CreateTime = data.CreatedAt.Unix()info.UpdateTime = data.UpdatedAt.Unix()- info.UserId = data.UserID+ info.UserID = data.UserIDreturn &info}func (as *AnswerCommon) AdminShowFormat(ctx context.Context, data *entity.Answer) *schema.AdminAnswerInfo {info := schema.AdminAnswerInfo{}info.ID = data.ID- info.QuestionId = data.QuestionID+ info.QuestionID = data.QuestionIDinfo.Description = data.ParsedTextinfo.Adopted = data.Adoptedinfo.VoteCount = data.VoteCountinfo.CreateTime = data.CreatedAt.Unix()info.UpdateTime = data.UpdatedAt.Unix()- info.UserId = data.UserID+ info.UserID = data.UserIDreturn &info}diff --git a/internal/service/answer_service.go b/internal/service/answer_service.goindex 11e72964..5d0ba33d 100644--- a/internal/service/answer_service.go+++ b/internal/service/answer_service.go@@ -74,7 +74,7 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, id string) (err errorreturn nil}- //user add question count+ // user add question counterr = as.questionCommon.UpdateAnswerCount(ctx, answerInfo.QuestionID, -1)if err != nil {log.Error("IncreaseAnswerCount error", err.Error())@@ -97,7 +97,7 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, id string) (err error}func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (string, error) {- questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, req.QuestionId)+ questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, req.QuestionID)if err != nil {return "", err}@@ -108,24 +108,24 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (insertData := new(entity.Answer)insertData.UserID = req.UserIDinsertData.OriginalText = req.Content- insertData.ParsedText = req.Html- insertData.Adopted = schema.Answer_Adopted_Failed- insertData.QuestionID = req.QuestionId+ insertData.ParsedText = req.HTML+ insertData.Adopted = schema.AnswerAdoptedFailed+ insertData.QuestionID = req.QuestionIDinsertData.RevisionID = "0"insertData.Status = entity.AnswerStatusAvailableinsertData.UpdatedAt = now- if err := as.answerRepo.AddAnswer(ctx, insertData); err != nil {+ if err = as.answerRepo.AddAnswer(ctx, insertData); err != nil {return "", err}- err = as.questionCommon.UpdateAnswerCount(ctx, req.QuestionId, 1)+ err = as.questionCommon.UpdateAnswerCount(ctx, req.QuestionID, 1)if err != nil {log.Error("IncreaseAnswerCount error", err.Error())}- err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionId, insertData.ID)+ err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionID, insertData.ID)if err != nil {log.Error("UpdateLastAnswer error", err.Error())}- err = as.questionCommon.UpdataPostTime(ctx, req.QuestionId)+ err = as.questionCommon.UpdataPostTime(ctx, req.QuestionID)if err != nil {return insertData.ID, err}@@ -140,8 +140,8 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (ObjectID: insertData.ID,Title: "",}- InfoJson, _ := json.Marshal(insertData)- revisionDTO.Content = string(InfoJson)+ infoJSON, _ := json.Marshal(insertData)+ revisionDTO.Content = string(infoJSON)err = as.revisionService.AddRevision(ctx, revisionDTO, true)if err != nil {return insertData.ID, err@@ -151,7 +151,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (}func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq) (string, error) {- questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, req.QuestionId)+ questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, req.QuestionID)if err != nil {return "", err}@@ -161,15 +161,15 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReqnow := time.Now()insertData := new(entity.Answer)insertData.ID = req.ID- insertData.QuestionID = req.QuestionId+ insertData.QuestionID = req.QuestionIDinsertData.UserID = req.UserIDinsertData.OriginalText = req.Content- insertData.ParsedText = req.Html+ insertData.ParsedText = req.HTMLinsertData.UpdatedAt = now- if err := as.answerRepo.UpdateAnswer(ctx, insertData, []string{"original_text", "parsed_text", "update_time"}); err != nil {+ if err = as.answerRepo.UpdateAnswer(ctx, insertData, []string{"original_text", "parsed_text", "update_time"}); err != nil {return "", err}- err = as.questionCommon.UpdataPostTime(ctx, req.QuestionId)+ err = as.questionCommon.UpdataPostTime(ctx, req.QuestionID)if err != nil {return insertData.ID, err}@@ -179,8 +179,8 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReqTitle: "",Log: req.EditSummary,}- InfoJson, _ := json.Marshal(insertData)- revisionDTO.Content = string(InfoJson)+ infoJSON, _ := json.Marshal(insertData)+ revisionDTO.Content = string(infoJSON)err = as.revisionService.AddRevision(ctx, revisionDTO, true)if err != nil {return insertData.ID, err@@ -228,7 +228,7 @@ func (as *AnswerService) UpdateAdopted(ctx context.Context, req *schema.AnswerAdvar oldAnswerInfo *entity.Answerif len(questionInfo.AcceptedAnswerID) > 0 && questionInfo.AcceptedAnswerID != "0" {- oldAnswerInfo, exist, err = as.answerRepo.GetByID(ctx, questionInfo.AcceptedAnswerID)+ oldAnswerInfo, _, err = as.answerRepo.GetByID(ctx, questionInfo.AcceptedAnswerID)if err != nil {return err}@@ -249,8 +249,8 @@ func (as *AnswerService) UpdateAdopted(ctx context.Context, req *schema.AnswerAd}func (as *AnswerService) updateAnswerRank(ctx context.Context, userID string,- questionInfo *entity.Question, newAnswerInfo *entity.Answer, oldAnswerInfo *entity.Answer) {-+ questionInfo *entity.Question, newAnswerInfo *entity.Answer, oldAnswerInfo *entity.Answer,+) {// if this question is already been answered, should cancel old answer rankif oldAnswerInfo != nil {err := as.answerActivityService.CancelAcceptAnswer(@@ -266,21 +266,20 @@ func (as *AnswerService) updateAnswerRank(ctx context.Context, userID string,log.Error(err)}}-}-func (as *AnswerService) Get(ctx context.Context, answerID, loginUserId string) (*schema.AnswerInfo, *schema.QuestionInfo, bool, error) {+func (as *AnswerService) Get(ctx context.Context, answerID, loginUserID string) (*schema.AnswerInfo, *schema.QuestionInfo, bool, error) {answerInfo, has, err := as.answerRepo.GetByID(ctx, answerID)if err != nil {return nil, nil, has, err}info := as.ShowFormat(ctx, answerInfo)- //todo questionFunc- questionInfo, err := as.questionCommon.Info(ctx, answerInfo.QuestionID, loginUserId)+ // todo questionFunc+ questionInfo, err := as.questionCommon.Info(ctx, answerInfo.QuestionID, loginUserID)if err != nil {return nil, nil, has, err}- //todo UserFunc+ // todo UserFuncuserinfo, has, err := as.userCommon.GetUserBasicInfoByID(ctx, answerInfo.UserID)if err != nil {return nil, nil, has, err@@ -290,13 +289,13 @@ func (as *AnswerService) Get(ctx context.Context, answerID, loginUserId string)info.UpdateUserInfo = userinfo}- if loginUserId == "" {+ if loginUserID == "" {return info, questionInfo, has, nil}- info.VoteStatus = as.voteRepo.GetVoteStatus(ctx, answerID, loginUserId)+ info.VoteStatus = as.voteRepo.GetVoteStatus(ctx, answerID, loginUserID)- CollectedMap, err := as.collectionCommon.SearchObjectCollected(ctx, loginUserId, []string{answerInfo.ID})+ CollectedMap, err := as.collectionCommon.SearchObjectCollected(ctx, loginUserID, []string{answerInfo.ID})if err != nil {log.Error("CollectionFunc.SearchObjectCollected error", err)}@@ -348,7 +347,7 @@ func (as *AnswerService) AdminSetAnswerStatus(ctx context.Context, answerID strifunc (as *AnswerService) SearchList(ctx context.Context, search *schema.AnswerList) ([]*schema.AnswerInfo, int64, error) {list := make([]*schema.AnswerInfo, 0)dbSearch := entity.AnswerSearch{}- dbSearch.QuestionID = search.QuestionId+ dbSearch.QuestionID = search.QuestionIDdbSearch.Page = search.PagedbSearch.PageSize = search.PageSizedbSearch.Order = search.Order@@ -363,7 +362,7 @@ func (as *AnswerService) SearchList(ctx context.Context, search *schema.AnswerLireturn AnswerList, count, nil}-func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.Answer, loginUserId string) ([]*schema.AnswerInfo, error) {+func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.Answer, loginUserID string) ([]*schema.AnswerInfo, error) {list := make([]*schema.AnswerInfo, 0)objectIds := make([]string, 0)userIds := make([]string, 0)@@ -372,9 +371,9 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.list = append(list, item)objectIds = append(objectIds, dbitem.ID)userIds = append(userIds, dbitem.UserID)- if loginUserId != "" {- //item.VoteStatus = as.activityFunc.GetVoteStatus(ctx, item.TagID, loginUserId)- item.VoteStatus = as.voteRepo.GetVoteStatus(ctx, item.ID, loginUserId)+ if loginUserID != "" {+ // item.VoteStatus = as.activityFunc.GetVoteStatus(ctx, item.TagID, loginUserId)+ item.VoteStatus = as.voteRepo.GetVoteStatus(ctx, item.ID, loginUserID)}}userInfoMap, err := as.userCommon.BatchUserBasicInfoByID(ctx, userIds)@@ -382,18 +381,18 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.return list, err}for _, item := range list {- _, ok := userInfoMap[item.UserId]+ _, ok := userInfoMap[item.UserID]if ok {- item.UserInfo = userInfoMap[item.UserId]- item.UpdateUserInfo = userInfoMap[item.UserId]+ item.UserInfo = userInfoMap[item.UserID]+ item.UpdateUserInfo = userInfoMap[item.UserID]}}- if loginUserId == "" {+ if loginUserID == "" {return list, nil}- CollectedMap, err := as.collectionCommon.SearchObjectCollected(ctx, loginUserId, objectIds)+ CollectedMap, err := as.collectionCommon.SearchObjectCollected(ctx, loginUserID, objectIds)if err != nil {log.Error("CollectionFunc.SearchObjectCollected error", err)}@@ -406,7 +405,7 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.}for _, item := range list {- item.MemberActions = permission.GetAnswerPermission(loginUserId, item.UserId)+ item.MemberActions = permission.GetAnswerPermission(loginUserID, item.UserID)}return list, nildiff --git a/internal/service/collection_group_service.go b/internal/service/collection_group_service.goindex 3c6a3a2b..82a59bd4 100644--- a/internal/service/collection_group_service.go+++ b/internal/service/collection_group_service.go@@ -17,7 +17,7 @@ type CollectionGroupRepo interface {UpdateCollectionGroup(ctx context.Context, collectionGroup *entity.CollectionGroup, cols []string) (err error)GetCollectionGroup(ctx context.Context, id string) (collectionGroup *entity.CollectionGroup, exist bool, err error)GetCollectionGroupPage(ctx context.Context, page, pageSize int, collectionGroup *entity.CollectionGroup) (collectionGroupList []*entity.CollectionGroup, total int64, err error)- GetDefaultID(ctx context.Context, userId string) (collectionGroup *entity.CollectionGroup, has bool, err error)+ GetDefaultID(ctx context.Context, userID string) (collectionGroup *entity.CollectionGroup, has bool, err error)}// CollectionGroupService user servicediff --git a/internal/service/collection_service.go b/internal/service/collection_service.goindex d2234289..7ea28092 100644--- a/internal/service/collection_service.go+++ b/internal/service/collection_service.go@@ -23,7 +23,6 @@ func NewCollectionService(collectionRepo collectioncommon.CollectionRepo,collectionGroupRepo CollectionGroupRepo,questionCommon *questioncommon.QuestionCommon,-) *CollectionService {return &CollectionService{collectionRepo: collectionRepo,@@ -31,6 +30,7 @@ func NewCollectionService(questionCommon: questionCommon,}}+func (cs *CollectionService) CollectionSwitch(ctx context.Context, dto *schema.CollectionSwitchDTO) (resp *schema.CollectionSwitchResp, err error) {resp = &schema.CollectionSwitchResp{}dbData, has, err := cs.collectionRepo.GetOneByObjectIDAndUser(ctx, dto.UserID, dto.ObjectID)@@ -46,7 +46,8 @@ func (cs *CollectionService) CollectionSwitch(ctx context.Context, dto *schema.Cif err != nil {log.Error("UpdateCollectionCount", err.Error())}- count, err := cs.objectCollectionCount(ctx, dto.ObjectID)+ var count int64+ count, err = cs.objectCollectionCount(ctx, dto.ObjectID)if err != nil {return resp, err}@@ -56,12 +57,17 @@ func (cs *CollectionService) CollectionSwitch(ctx context.Context, dto *schema.C}if dto.GroupID == "" || dto.GroupID == "0" {- defaultGroup, has, err := cs.collectionGroupRepo.GetDefaultID(ctx, dto.UserID)+ var (+ defaultGroup *entity.CollectionGroup+ has bool+ )+ defaultGroup, has, err = cs.collectionGroupRepo.GetDefaultID(ctx, dto.UserID)if err != nil {return nil, err}if !has {- dbdefaultGroup, err := cs.collectionGroupRepo.AddCollectionDefaultGroup(ctx, dto.UserID)+ var dbdefaultGroup *entity.CollectionGroup+ dbdefaultGroup, err = cs.collectionGroupRepo.AddCollectionDefaultGroup(ctx, dto.UserID)if err != nil {return nil, err}@@ -93,8 +99,8 @@ func (cs *CollectionService) CollectionSwitch(ctx context.Context, dto *schema.Creturn}-func (cs *CollectionService) objectCollectionCount(ctx context.Context, objectId string) (int64, error) {- count, err := cs.collectionRepo.CountByObjectID(ctx, objectId)+func (cs *CollectionService) objectCollectionCount(ctx context.Context, objectID string) (int64, error) {+ count, err := cs.collectionRepo.CountByObjectID(ctx, objectID)return count, err}@@ -108,12 +114,16 @@ func (cs *CollectionService) add(ctx context.Context, collection *entity.Collect}if collection.UserCollectionGroupID == "" || collection.UserCollectionGroupID == "0" {- defaultGroup, has, err := cs.collectionGroupRepo.GetDefaultID(ctx, collection.UserID)+ var (+ defaultGroup *entity.CollectionGroup+ has bool+ )+ defaultGroup, has, err = cs.collectionGroupRepo.GetDefaultID(ctx, collection.UserID)if err != nil {return err}if !has {- defaultGroup, err := cs.collectionGroupRepo.AddCollectionDefaultGroup(ctx, collection.UserID)+ defaultGroup, err = cs.collectionGroupRepo.AddCollectionDefaultGroup(ctx, collection.UserID)if err != nil {return err}diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.goindex c9c105c8..0e550d43 100644--- a/internal/service/question_common/question.go+++ b/internal/service/question_common/question.go@@ -31,9 +31,9 @@ type QuestionRepo interface {SearchList(ctx context.Context, search *schema.QuestionSearch) ([]*entity.QuestionTag, int64, error)UpdateQuestionStatus(ctx context.Context, question *entity.Question) (err error)SearchByTitleLike(ctx context.Context, title string) (questionList []*entity.Question, err error)- UpdatePvCount(ctx context.Context, questionId string) (err error)- UpdateAnswerCount(ctx context.Context, questionId string, num int) (err error)- UpdateCollectionCount(ctx context.Context, questionId string, num int) (err error)+ UpdatePvCount(ctx context.Context, questionID string) (err error)+ UpdateAnswerCount(ctx context.Context, questionID string, num int) (err error)+ UpdateCollectionCount(ctx context.Context, questionID string, num int) (err error)UpdateAccepted(ctx context.Context, question *entity.Question) (err error)UpdateLastAnswer(ctx context.Context, question *entity.Question) (err error)FindByID(ctx context.Context, id []string) (questionList []*entity.Question, err error)@@ -64,7 +64,6 @@ func NewQuestionCommon(questionRepo QuestionRepo,answerCommon *answercommon.AnswerCommon,metaService *meta.MetaService,configRepo config.ConfigRepo,-) *QuestionCommon {return &QuestionCommon{questionRepo: questionRepo,@@ -80,42 +79,44 @@ func NewQuestionCommon(questionRepo QuestionRepo,}}-func (qs *QuestionCommon) UpdataPv(ctx context.Context, questionId string) error {- return qs.questionRepo.UpdatePvCount(ctx, questionId)+func (qs *QuestionCommon) UpdataPv(ctx context.Context, questionID string) error {+ return qs.questionRepo.UpdatePvCount(ctx, questionID)}-func (qs *QuestionCommon) UpdateAnswerCount(ctx context.Context, questionId string, num int) error {- return qs.questionRepo.UpdateAnswerCount(ctx, questionId, num)++func (qs *QuestionCommon) UpdateAnswerCount(ctx context.Context, questionID string, num int) error {+ return qs.questionRepo.UpdateAnswerCount(ctx, questionID, num)}-func (qs *QuestionCommon) UpdateCollectionCount(ctx context.Context, questionId string, num int) error {- return qs.questionRepo.UpdateCollectionCount(ctx, questionId, num)++func (qs *QuestionCommon) UpdateCollectionCount(ctx context.Context, questionID string, num int) error {+ return qs.questionRepo.UpdateCollectionCount(ctx, questionID, num)}-func (qs *QuestionCommon) UpdateAccepted(ctx context.Context, questionId, AnswerId string) error {+func (qs *QuestionCommon) UpdateAccepted(ctx context.Context, questionID, AnswerID string) error {question := &entity.Question{}- question.ID = questionId- question.AcceptedAnswerID = AnswerId+ question.ID = questionID+ question.AcceptedAnswerID = AnswerIDreturn qs.questionRepo.UpdateAccepted(ctx, question)}-func (qs *QuestionCommon) UpdateLastAnswer(ctx context.Context, questionId, AnswerId string) error {+func (qs *QuestionCommon) UpdateLastAnswer(ctx context.Context, questionID, AnswerID string) error {question := &entity.Question{}- question.ID = questionId- question.LastAnswerID = AnswerId+ question.ID = questionID+ question.LastAnswerID = AnswerIDreturn qs.questionRepo.UpdateLastAnswer(ctx, question)}-func (qs *QuestionCommon) UpdataPostTime(ctx context.Context, questionId string) error {+func (qs *QuestionCommon) UpdataPostTime(ctx context.Context, questionID string) error {questioninfo := &entity.Question{}now := time.Now()- questioninfo.ID = questionId+ questioninfo.ID = questionIDquestioninfo.PostUpdateTime = nowreturn qs.questionRepo.UpdateQuestion(ctx, questioninfo, []string{"post_update_time"})}-func (qs *QuestionCommon) FindInfoByID(ctx context.Context, questionIds []string, loginUserID string) (map[string]*schema.QuestionInfo, error) {+func (qs *QuestionCommon) FindInfoByID(ctx context.Context, questionIDs []string, loginUserID string) (map[string]*schema.QuestionInfo, error) {list := make(map[string]*schema.QuestionInfo)listAddTag := make([]*entity.QuestionTag, 0)- questionList, err := qs.questionRepo.FindByID(ctx, questionIds)+ questionList, err := qs.questionRepo.FindByID(ctx, questionIDs)if err != nil {return list, err}@@ -134,8 +135,8 @@ func (qs *QuestionCommon) FindInfoByID(ctx context.Context, questionIds []stringreturn list, nil}-func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUserID string) (showinfo *schema.QuestionInfo, err error) {- dbinfo, has, err := qs.questionRepo.GetQuestion(ctx, questionId)+func (qs *QuestionCommon) Info(ctx context.Context, questionID string, loginUserID string) (showinfo *schema.QuestionInfo, err error) {+ dbinfo, has, err := qs.questionRepo.GetQuestion(ctx, questionID)if err != nil {return showinfo, err}@@ -145,13 +146,14 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUsershowinfo = qs.ShowFormat(ctx, dbinfo)if showinfo.Status == 2 {- metainfo, err := qs.metaService.GetMetaByObjectIdAndKey(ctx, dbinfo.ID, entity.QuestionCloseReasonKey)+ var metainfo *entity.Meta+ metainfo, err = qs.metaService.GetMetaByObjectIdAndKey(ctx, dbinfo.ID, entity.QuestionCloseReasonKey)if err != nil {log.Error(err)} else {- //metainfo.Value+ // metainfo.Valueclosemsg := &schema.CloseQuestionMeta{}- err := json.Unmarshal([]byte(metainfo.Value), closemsg)+ err = json.Unmarshal([]byte(metainfo.Value), closemsg)if err != nil {log.Error("json.Unmarshal CloseQuestionMeta error", err.Error())} else {@@ -161,10 +163,10 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUserlog.Error("json.Unmarshal QuestionCloseJson error", err.Error())} else {operation := &schema.Operation{}- operation.Operation_Type = closeinfo.Name- operation.Operation_Description = closeinfo.Description- operation.Operation_Msg = closemsg.CloseMsg- operation.Operation_Time = metainfo.CreatedAt.Unix()+ operation.OperationType = closeinfo.Name+ operation.OperationDescription = closeinfo.Description+ operation.OperationMsg = closemsg.CloseMsg+ operation.OperationTime = metainfo.CreatedAt.Unix()showinfo.Operation = operation}@@ -173,7 +175,7 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUser}}- tagmap, err := qs.tagCommon.GetObjectTag(ctx, questionId)+ tagmap, err := qs.tagCommon.GetObjectTag(ctx, questionID)if err != nil {return showinfo, err}@@ -193,10 +195,10 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUserreturn showinfo, nil}- showinfo.VoteStatus = qs.voteRepo.GetVoteStatus(ctx, questionId, loginUserID)+ showinfo.VoteStatus = qs.voteRepo.GetVoteStatus(ctx, questionID, loginUserID)// // check is followed- isFollowed, _ := qs.followCommon.IsFollowed(loginUserID, questionId)+ isFollowed, _ := qs.followCommon.IsFollowed(loginUserID, questionID)showinfo.IsFollowed = isFollowedhas, err = qs.AnswerCommon.SearchAnswered(ctx, loginUserID, dbinfo.ID)@@ -205,7 +207,7 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUser}showinfo.Answered = has- //login user Collected information+ // login user Collected informationCollectedMap, err := qs.collectionCommon.SearchObjectCollected(ctx, loginUserID, []string{dbinfo.ID})if err != nil {@@ -245,11 +247,11 @@ func (qs *QuestionCommon) ListFormat(ctx context.Context, questionList []*entityif ok {item.Tags = tagsMap[item.ID]}- _, ok = userInfoMap[item.UserId]+ _, ok = userInfoMap[item.UserID]if ok {- item.UserInfo = userInfoMap[item.UserId]- item.UpdateUserInfo = userInfoMap[item.UserId]- item.LastAnsweredUserInfo = userInfoMap[item.UserId]+ item.UserInfo = userInfoMap[item.UserID]+ item.UpdateUserInfo = userInfoMap[item.UserID]+ item.LastAnsweredUserInfo = userInfoMap[item.UserID]}}@@ -286,7 +288,7 @@ func (qs *QuestionCommon) RemoveQuestion(ctx context.Context, req *schema.Removereturn err}- //user add question count+ // user add question counterr = qs.userCommon.UpdateQuestionCount(ctx, questionInfo.UserID, -1)if err != nil {log.Error("user UpdateQuestionCount error", err.Error())@@ -332,7 +334,7 @@ func (as *QuestionCommon) RemoveAnswer(ctx context.Context, id string) (err erroreturn nil}- //user add question count+ // user add question counterr = as.UpdateAnswerCount(ctx, answerinfo.QuestionID, -1)if err != nil {@@ -356,21 +358,21 @@ func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question)info.ID = data.IDinfo.Title = data.Titleinfo.Content = data.OriginalText- info.Html = data.ParsedText+ info.HTML = data.ParsedTextinfo.ViewCount = data.ViewCountinfo.UniqueViewCount = data.UniqueViewCountinfo.VoteCount = data.VoteCountinfo.AnswerCount = data.AnswerCountinfo.CollectionCount = data.CollectionCountinfo.FollowCount = data.FollowCount- info.AcceptedAnswerId = data.AcceptedAnswerID- info.LastAnswerId = data.LastAnswerID+ info.AcceptedAnswerID = data.AcceptedAnswerID+ info.LastAnswerID = data.LastAnswerIDinfo.CreateTime = data.CreatedAt.Unix()info.UpdateTime = data.UpdatedAt.Unix()info.PostUpdateTime = data.PostUpdateTime.Unix()info.QuestionUpdateTime = data.UpdatedAt.Unix()info.Status = data.Status- info.UserId = data.UserID+ info.UserID = data.UserIDinfo.Tags = make([]*schema.TagResp, 0)return &info}diff --git a/internal/service/question_service.go b/internal/service/question_service.goindex 88178654..69aa1669 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -89,9 +89,10 @@ func (qs *QuestionService) CloseQuestion(ctx context.Context, req *schema.CloseQ// CloseMsgList list close question conditionfunc (qs *QuestionService) CloseMsgList(ctx context.Context, lang i18n.Language) (- resp []*schema.GetCloseTypeResp, err error) {+ resp []*schema.GetCloseTypeResp, err error,+) {resp = make([]*schema.GetCloseTypeResp, 0)- err = json.Unmarshal([]byte(constant.QuestionCloseJson), &resp)+ err = json.Unmarshal([]byte(constant.QuestionCloseJSON), &resp)if err != nil {return nil, errors.InternalServer(reason.UnknownError).WithError(err).WithStack()}@@ -110,7 +111,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Questionquestion.UserID = req.UserIDquestion.Title = req.Titlequestion.OriginalText = req.Content- question.ParsedText = req.Html+ question.ParsedText = req.HTMLquestion.AcceptedAnswerID = "0"question.LastAnswerID = "0"question.PostUpdateTime = now@@ -123,7 +124,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Questionreturn}objectTagData := schema.TagChange{}- objectTagData.ObjectId = question.ID+ objectTagData.ObjectID = question.IDobjectTagData.Tags = req.TagsobjectTagData.UserID = req.UserIDerr = qs.ChangeTag(ctx, &objectTagData)@@ -136,14 +137,14 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.QuestionObjectID: question.ID,Title: "",}- InfoJson, _ := json.Marshal(question)- revisionDTO.Content = string(InfoJson)+ infoJSON, _ := json.Marshal(question)+ revisionDTO.Content = string(infoJSON)err = qs.revisionService.AddRevision(ctx, revisionDTO, true)if err != nil {return}- //user add question count+ // user add question counterr = qs.userCommon.UpdateQuestionCount(ctx, question.UserID, 1)if err != nil {log.Error("user IncreaseQuestionCount error", err.Error())@@ -168,7 +169,7 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Removreturn err}- //user add question count+ // user add question counterr = qs.userCommon.UpdateQuestionCount(ctx, questionInfo.UserID, -1)if err != nil {log.Error("user IncreaseQuestionCount error", err.Error())@@ -190,7 +191,7 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Questquestion.UserID = req.UserIDquestion.Title = req.Titlequestion.OriginalText = req.Content- question.ParsedText = req.Html+ question.ParsedText = req.HTMLquestion.ID = req.IDquestion.UpdatedAt = nowdbinfo, has, err := qs.questionRepo.GetQuestion(ctx, question.ID)@@ -208,7 +209,7 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Questreturn}objectTagData := schema.TagChange{}- objectTagData.ObjectId = question.ID+ objectTagData.ObjectID = question.IDobjectTagData.Tags = req.TagsobjectTagData.UserID = req.UserIDerr = qs.ChangeTag(ctx, &objectTagData)@@ -222,8 +223,8 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.QuestTitle: "",Log: req.EditSummary,}- InfoJson, _ := json.Marshal(question)- revisionDTO.Content = string(InfoJson)+ infoJSON, _ := json.Marshal(question)+ revisionDTO.Content = string(infoJSON)err = qs.revisionService.AddRevision(ctx, revisionDTO, true)if err != nil {return@@ -246,7 +247,7 @@ func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID stri}}- question.MemberActions = permission.GetQuestionPermission(loginUserID, question.UserId)+ question.MemberActions = permission.GetQuestionPermission(loginUserID, question.UserID)return question, nil}@@ -300,9 +301,9 @@ func (qs *QuestionService) SearchUserAnswerList(ctx context.Context, userName, oanswersearch.PageSize = pageSizeanswersearch.Page = pageif order == "newest" {- answersearch.Order = entity.Answer_Search_OrderBy_Time+ answersearch.Order = entity.AnswerSearchOrderByTime} else {- answersearch.Order = entity.Answer_Search_OrderBy_Default+ answersearch.Order = entity.AnswerSearchOrderByDefault}questionIDs := make([]string, 0)answerList, count, err := qs.questioncommon.AnswerCommon.Search(ctx, answersearch)@@ -319,16 +320,16 @@ func (qs *QuestionService) SearchUserAnswerList(ctx context.Context, userName, oreturn userAnswerlist, count, err}for _, item := range answerlist {- _, ok := questionMaps[item.QuestionId]+ _, ok := questionMaps[item.QuestionID]if ok {- item.QuestionInfo = questionMaps[item.QuestionId]+ item.QuestionInfo = questionMaps[item.QuestionID]}}for _, item := range answerlist {info := &schema.UserAnswerInfo{}_ = copier.Copy(info, item)info.AnswerID = item.ID- info.QuestionID = item.QuestionId+ info.QuestionID = item.QuestionIDuserAnswerlist = append(userAnswerlist, info)}return userAnswerlist, count, nil@@ -366,7 +367,7 @@ func (qs *QuestionService) SearchUserCollectionList(ctx context.Context, page, pquestionMaps[id].LastAnsweredUserInfo = nilquestionMaps[id].UpdateUserInfo = nilquestionMaps[id].Content = ""- questionMaps[id].Html = ""+ questionMaps[id].HTML = ""list = append(list, questionMaps[id])}}@@ -399,7 +400,7 @@ func (qs *QuestionService) SearchUserTopList(ctx context.Context, userName strinanswersearch := &entity.AnswerSearch{}answersearch.UserID = userinfo.IDanswersearch.PageSize = 5- answersearch.Order = entity.Answer_Search_OrderBy_Vote+ answersearch.Order = entity.AnswerSearchOrderByVotequestionIDs := make([]string, 0)answerList, _, err := qs.questioncommon.AnswerCommon.Search(ctx, answersearch)if err != nil {@@ -415,9 +416,9 @@ func (qs *QuestionService) SearchUserTopList(ctx context.Context, userName strinreturn userQuestionlist, userAnswerlist, err}for _, item := range answerlist {- _, ok := questionMaps[item.QuestionId]+ _, ok := questionMaps[item.QuestionID]if ok {- item.QuestionInfo = questionMaps[item.QuestionId]+ item.QuestionInfo = questionMaps[item.QuestionID]}}@@ -431,7 +432,7 @@ func (qs *QuestionService) SearchUserTopList(ctx context.Context, userName strininfo := &schema.UserAnswerInfo{}_ = copier.Copy(info, item)info.AnswerID = item.ID- info.QuestionID = item.QuestionId+ info.QuestionID = item.QuestionIDuserAnswerlist = append(userAnswerlist, info)}@@ -626,13 +627,13 @@ func (qs *QuestionService) CmsSearchAnswerList(ctx context.Context, search *entireturn answerlist, count, err}for _, item := range answerlist {- _, ok := questionMaps[item.QuestionId]+ _, ok := questionMaps[item.QuestionID]if ok {- item.QuestionInfo.Title = questionMaps[item.QuestionId].Title+ item.QuestionInfo.Title = questionMaps[item.QuestionID].Title}- _, ok = userInfoMap[item.UserId]+ _, ok = userInfoMap[item.UserID]if ok {- item.UserInfo = userInfoMap[item.UserId]+ item.UserInfo = userInfoMap[item.UserID]}}return answerlist, count, nildiff --git a/internal/service/report/report_service.go b/internal/service/report/report_service.goindex ab57aeaf..251c3239 100644--- a/internal/service/report/report_service.go+++ b/internal/service/report/report_service.go@@ -24,7 +24,8 @@ type ReportService struct {// NewReportService new report servicefunc NewReportService(reportRepo report_common.ReportRepo,- objectInfoService *object_info.ObjService) *ReportService {+ objectInfoService *object_info.ObjService,+) *ReportService {return &ReportService{reportRepo: reportRepo,objectInfoService: objectInfoService,@@ -58,15 +59,16 @@ func (rs *ReportService) AddReport(ctx context.Context, req *schema.AddReportReq// GetReportTypeList get report list allfunc (rs *ReportService) GetReportTypeList(ctx context.Context, lang i18n.Language, req *schema.GetReportListReq) (- resp []*schema.GetReportTypeResp, err error) {+ resp []*schema.GetReportTypeResp, err error,+) {resp = make([]*schema.GetReportTypeResp, 0)switch req.Source {case constant.QuestionObjectType:- err = json.Unmarshal([]byte(constant.QuestionReportJson), &resp)+ err = json.Unmarshal([]byte(constant.QuestionReportJSON), &resp)case constant.AnswerObjectType:- err = json.Unmarshal([]byte(constant.AnswerReportJson), &resp)+ err = json.Unmarshal([]byte(constant.AnswerReportJSON), &resp)case constant.CommentObjectType:- err = json.Unmarshal([]byte(constant.CommentReportJson), &resp)+ err = json.Unmarshal([]byte(constant.CommentReportJSON), &resp)}if err != nil {err = errors.BadRequest(reason.UnknownError)diff --git a/internal/service/siteinfo_service.go b/internal/service/siteinfo_service.goindex f1ae6e8d..a4f23fd3 100644--- a/internal/service/siteinfo_service.go+++ b/internal/service/siteinfo_service.go@@ -64,7 +64,7 @@ func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGesiteType = "general"content []byte)- content, err = json.Marshal(req)+ content, _ = json.Marshal(req)data := entity.SiteInfo{Type: siteType,@@ -107,7 +107,7 @@ func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.Sitereturn}- content, err = json.Marshal(req)+ content, _ = json.Marshal(req)data := entity.SiteInfo{Type: siteType,@@ -120,7 +120,8 @@ func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.Site// GetSMTPConfig get smtp configfunc (s *SiteInfoService) GetSMTPConfig(ctx context.Context) (- resp *schema.GetSMTPConfigResp, err error) {+ resp *schema.GetSMTPConfigResp, err error,+) {emailConfig, err := s.emailService.GetEmailConfig()if err != nil {return nil, errdiff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.goindex dd8353eb..7892b9a9 100644--- a/internal/service/tag_common/tag_common.go+++ b/internal/service/tag_common/tag_common.go@@ -47,7 +47,8 @@ type TagCommonService struct {// NewTagCommonService new tag servicefunc NewTagCommonService(tagRepo TagRepo, tagRelRepo TagRelRepo,- revisionService *revision_common.RevisionService) *TagCommonService {+ revisionService *revision_common.RevisionService,+) *TagCommonService {return &TagCommonService{tagRepo: tagRepo,tagRelRepo: tagRelRepo,@@ -97,20 +98,20 @@ func (ts *TagCommonService) GetObjectTag(ctx context.Context, objectId string) (// BatchGetObjectTag batch get object tagfunc (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []string) (map[string][]*schema.TagResp, error) {- objectIdTagMap := make(map[string][]*schema.TagResp)+ objectIDTagMap := make(map[string][]*schema.TagResp)tagIDList := make([]string, 0)tagsInfoMap := make(map[string]*entity.Tag)tagList, err := ts.tagRelRepo.BatchGetObjectTagRelList(ctx, objectIds)if err != nil {- return objectIdTagMap, err+ return objectIDTagMap, err}for _, tag := range tagList {tagIDList = append(tagIDList, tag.TagID)}tagsInfoList, err := ts.tagRepo.GetTagListByIDs(ctx, tagIDList)if err != nil {- return objectIdTagMap, err+ return objectIDTagMap, err}for _, item := range tagsInfoList {tagsInfoMap[item.ID] = item@@ -124,10 +125,10 @@ func (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []sDisplayName: tagInfo.DisplayName,MainTagSlugName: tagInfo.MainTagSlugName,}- objectIdTagMap[item.ObjectID] = append(objectIdTagMap[item.ObjectID], t)+ objectIDTagMap[item.ObjectID] = append(objectIDTagMap[item.ObjectID], t)}}- return objectIdTagMap, nil+ return objectIDTagMap, nil}// ObjectChangeTag change object tag list@@ -191,7 +192,7 @@ func (ts *TagCommonService) ObjectChangeTag(ctx context.Context, objectTagData *}}- err = ts.CreateOrUpdateTagRelList(ctx, objectTagData.ObjectId, thisObjTagIDList)+ err = ts.CreateOrUpdateTagRelList(ctx, objectTagData.ObjectID, thisObjTagIDList)if err != nil {return err}diff --git a/internal/service/user_common/user.go b/internal/service/user_common/user.goindex 0297ae47..4c7f49db 100644--- a/internal/service/user_common/user.go+++ b/internal/service/user_common/user.go@@ -83,7 +83,7 @@ func (us *UserCommon) UserBasicInfoFormat(ctx context.Context, userInfo *entity.userBasicInfo.Avatar = userInfo.AvataruserBasicInfo.Website = userInfo.WebsiteuserBasicInfo.Location = userInfo.Location- userBasicInfo.IpInfo = userInfo.IPInfo+ userBasicInfo.IPInfo = userInfo.IPInfouserBasicInfo.Status = schema.UserStatusShow[userInfo.Status]if userBasicInfo.Status == schema.UserDeleted {userBasicInfo.Avatar = ""diff --git a/internal/service/user_service.go b/internal/service/user_service.goindex af2d4d6f..370dbd8f 100644--- a/internal/service/user_service.go+++ b/internal/service/user_service.go@@ -39,7 +39,8 @@ func NewUserService(userRepo usercommon.UserRepo,userActivity activity.UserActiveActivityRepo,emailService *export.EmailService,authService *auth.AuthService,- serviceConfig *service_config.ServiceConfig) *UserService {+ serviceConfig *service_config.ServiceConfig,+) *UserService {return &UserService{userRepo: userRepo,userActivity: userActivity,@@ -94,7 +95,8 @@ func (us *UserService) GetUserStatus(ctx context.Context, userID, token string)}func (us *UserService) GetOtherUserInfoByUsername(ctx context.Context, username string) (- resp *schema.GetOtherUserInfoResp, err error) {+ resp *schema.GetOtherUserInfoResp, err error,+) {userInfo, exist, err := us.userRepo.GetByUsername(ctx, username)if err != nil {return nil, err@@ -165,8 +167,8 @@ func (us *UserService) RetrievePassWord(ctx context.Context, req *schema.UserRetUserID: userInfo.ID,}code := uuid.NewString()- verifyEmailUrl := fmt.Sprintf("%s/users/password-reset?code=%s", us.serviceConfig.WebHost, code)- title, body, err := us.emailService.PassResetTemplate(ctx, verifyEmailUrl)+ verifyEmailURL := fmt.Sprintf("%s/users/password-reset?code=%s", us.serviceConfig.WebHost, code)+ title, body, err := us.emailService.PassResetTemplate(ctx, verifyEmailURL)if err != nil {return "", err}@@ -179,7 +181,7 @@ func (us *UserService) UseRePassWord(ctx context.Context, req *schema.UserRePassdata := &schema.EmailCodeContent{}err = data.FromJSONString(req.Content)if err != nil {- return nil, errors.BadRequest(reason.EmailVerifyUrlExpired)+ return nil, errors.BadRequest(reason.EmailVerifyURLExpired)}userInfo, exist, err := us.userRepo.GetByEmail(ctx, data.Email)@@ -203,8 +205,7 @@ func (us *UserService) UseRePassWord(ctx context.Context, req *schema.UserRePass}func (us *UserService) UserModifyPassWordVerification(ctx context.Context, request *schema.UserModifyPassWordRequest) (bool, error) {-- userInfo, has, err := us.userRepo.GetByUserID(ctx, request.UserId)+ userInfo, has, err := us.userRepo.GetByUserID(ctx, request.UserID)if err != nil {return false, err}@@ -225,7 +226,7 @@ func (us *UserService) UserModifyPassWord(ctx context.Context, request *schema.Uif err != nil {return err}- userInfo, has, err := us.userRepo.GetByUserID(ctx, request.UserId)+ userInfo, has, err := us.userRepo.GetByUserID(ctx, request.UserID)if err != nil {return err}@@ -251,17 +252,17 @@ func (us *UserService) UpdateInfo(ctx context.Context, req *schema.UpdateInfoReqif err != nil {return err}- if exist && userInfo.ID != req.UserId {+ if exist && userInfo.ID != req.UserID {return errors.BadRequest(reason.UsernameDuplicate)}}userInfo := entity.User{}- userInfo.ID = req.UserId+ userInfo.ID = req.UserIDuserInfo.Avatar = req.AvataruserInfo.DisplayName = req.DisplayNameuserInfo.Bio = req.Bio- userInfo.BioHtml = req.BioHtml+ userInfo.BioHTML = req.BioHTMLuserInfo.Location = req.LocationuserInfo.Website = req.WebsiteuserInfo.Username = req.Username@@ -281,7 +282,8 @@ func (us *UserService) UserEmailHas(ctx context.Context, email string) (bool, er// UserRegisterByEmail user registerfunc (us *UserService) UserRegisterByEmail(ctx context.Context, registerUserInfo *schema.UserRegisterReq) (- resp *schema.GetUserResp, err error) {+ resp *schema.GetUserResp, err error,+) {_, has, err := us.userRepo.GetByEmail(ctx, registerUserInfo.Email)if err != nil {return nil, err@@ -315,8 +317,8 @@ func (us *UserService) UserRegisterByEmail(ctx context.Context, registerUserInfoUserID: userInfo.ID,}code := uuid.NewString()- verifyEmailUrl := fmt.Sprintf("%s/users/account-activation?code=%s", us.serviceConfig.WebHost, code)- title, body, err := us.emailService.RegisterTemplate(ctx, verifyEmailUrl)+ verifyEmailURL := fmt.Sprintf("%s/users/account-activation?code=%s", us.serviceConfig.WebHost, code)+ title, body, err := us.emailService.RegisterTemplate(ctx, verifyEmailURL)if err != nil {return nil, err}@@ -358,8 +360,8 @@ func (us *UserService) UserVerifyEmailSend(ctx context.Context, userID string) eUserID: userInfo.ID,}code := uuid.NewString()- verifyEmailUrl := fmt.Sprintf("%s/users/account-activation?code=%s", us.serviceConfig.WebHost, code)- title, body, err := us.emailService.RegisterTemplate(ctx, verifyEmailUrl)+ verifyEmailURL := fmt.Sprintf("%s/users/account-activation?code=%s", us.serviceConfig.WebHost, code)+ title, body, err := us.emailService.RegisterTemplate(ctx, verifyEmailURL)if err != nil {return err}@@ -367,9 +369,10 @@ func (us *UserService) UserVerifyEmailSend(ctx context.Context, userID string) ereturn nil}-func (us *UserService) UserNoticeSet(ctx context.Context, userId string, noticeSwitch bool) (- resp *schema.UserNoticeSetResp, err error) {- userInfo, has, err := us.userRepo.GetByUserID(ctx, userId)+func (us *UserService) UserNoticeSet(ctx context.Context, userID string, noticeSwitch bool) (+ resp *schema.UserNoticeSetResp, err error,+) {+ userInfo, has, err := us.userRepo.GetByUserID(ctx, userID)if err != nil {return nil, err}@@ -377,9 +380,9 @@ func (us *UserService) UserNoticeSet(ctx context.Context, userId string, noticeSreturn nil, errors.BadRequest(reason.UserNotFound)}if noticeSwitch {- userInfo.NoticeStatus = schema.Notice_Status_On+ userInfo.NoticeStatus = schema.NoticeStatusOn} else {- userInfo.NoticeStatus = schema.Notice_Status_Off+ userInfo.NoticeStatus = schema.NoticeStatusOff}err = us.userRepo.UpdateNoticeStatus(ctx, userInfo.ID, userInfo.NoticeStatus)return &schema.UserNoticeSetResp{NoticeSwitch: noticeSwitch}, err@@ -389,7 +392,7 @@ func (us *UserService) UserVerifyEmail(ctx context.Context, req *schema.UserVeridata := &schema.EmailCodeContent{}err = data.FromJSONString(req.Content)if err != nil {- return nil, errors.BadRequest(reason.EmailVerifyUrlExpired)+ return nil, errors.BadRequest(reason.EmailVerifyURLExpired)}userInfo, has, err := us.userRepo.GetByEmail(ctx, data.Email)@@ -471,17 +474,14 @@ func (us *UserService) makeUsername(ctx context.Context, displayName string) (us// Compare whether the password is correctfunc (us *UserService) verifyPassword(ctx context.Context, LoginPass, UserPass string) bool {err := bcrypt.CompareHashAndPassword([]byte(UserPass), []byte(LoginPass))- if err != nil {- return false- }- return true+ return err == nil}// encryptPassword// The password does irreversible encryption.func (us *UserService) encryptPassword(ctx context.Context, Pass string) (string, error) {hashPwd, err := bcrypt.GenerateFromPassword([]byte(Pass), bcrypt.DefaultCost)- //This encrypted string can be saved to the database and can be used as password matching verification+ // This encrypted string can be saved to the database and can be used as password matching verificationreturn string(hashPwd), err}@@ -508,12 +508,12 @@ func (us *UserService) UserChangeEmailSendCode(ctx context.Context, req *schema.UserID: req.UserID,}code := uuid.NewString()- verifyEmailUrl := fmt.Sprintf("%s/users/confirm-new-email?code=%s", us.serviceConfig.WebHost, code)- title, body, err := us.emailService.ChangeEmailTemplate(ctx, verifyEmailUrl)+ verifyEmailURL := fmt.Sprintf("%s/users/confirm-new-email?code=%s", us.serviceConfig.WebHost, code)+ title, body, err := us.emailService.ChangeEmailTemplate(ctx, verifyEmailURL)if err != nil {return err}- log.Infof("send email confirmation %s", verifyEmailUrl)+ log.Infof("send email confirmation %s", verifyEmailURL)go us.emailService.Send(context.Background(), req.Email, title, body, code, data.ToJSONString())return nil@@ -524,7 +524,7 @@ func (us *UserService) UserChangeEmailVerify(ctx context.Context, content stringdata := &schema.EmailCodeContent{}err = data.FromJSONString(content)if err != nil {- return errors.BadRequest(reason.EmailVerifyUrlExpired)+ return errors.BadRequest(reason.EmailVerifyURLExpired)}_, exist, err := us.userRepo.GetByEmail(ctx, data.Email)diff --git a/internal/service/vote_service.go b/internal/service/vote_service.goindex 74789529..b77fe402 100644--- a/internal/service/vote_service.go+++ b/internal/service/vote_service.go@@ -67,7 +67,7 @@ func (as *VoteService) VoteUp(ctx context.Context, dto *schema.VoteDTO) (voteResvar objectUserID string- objectUserID, err = as.GetObjectUserId(ctx, dto.ObjectID)+ objectUserID, err = as.GetObjectUserID(ctx, dto.ObjectID)if err != nil {return}@@ -91,7 +91,7 @@ func (as *VoteService) VoteDown(ctx context.Context, dto *schema.VoteDTO) (voteRvar objectUserID string- objectUserID, err = as.GetObjectUserId(ctx, dto.ObjectID)+ objectUserID, err = as.GetObjectUserID(ctx, dto.ObjectID)if err != nil {return}@@ -109,7 +109,7 @@ func (as *VoteService) VoteDown(ctx context.Context, dto *schema.VoteDTO) (voteR}}-func (vs *VoteService) GetObjectUserId(ctx context.Context, objectID string) (userID string, err error) {+func (vs *VoteService) GetObjectUserID(ctx context.Context, objectID string) (userID string, err error) {var objectKey stringobjectKey, err = obj.GetObjectTypeStrByObjectID(objectID)@@ -162,7 +162,8 @@ func (vs *VoteService) ListUserVotes(ctx context.Context, req schema.GetVoteWith)for _, typeKey := range typeKeys {- t, err := vs.configRepo.GetConfigType(typeKey)+ var t int+ t, err = vs.configRepo.GetConfigType(typeKey)if err != nil {continue}@@ -175,7 +176,8 @@ func (vs *VoteService) ListUserVotes(ctx context.Context, req schema.GetVoteWith}for _, voteInfo := range voteList {- objInfo, err := vs.objectService.GetInfo(ctx, voteInfo.ObjectID)+ var objInfo *schema.SimpleObjectInfo+ objInfo, err = vs.objectService.GetInfo(ctx, voteInfo.ObjectID)if err != nil {log.Error(err)}diff --git a/pkg/checker/password.go b/pkg/checker/password.goindex 6c1bd6e6..966b851c 100644--- a/pkg/checker/password.go+++ b/pkg/checker/password.go@@ -30,7 +30,7 @@ func CheckPassword(minLength, maxLength, minLevel int, pwd string) error {// The password strength level is initialized to D.// The regular is used to verify the password strength.// If the matching is successful, the password strength increases by 1- var level int = levelD+ level := levelDpatternList := []string{`[0-9]+`, `[a-z]+`, `[A-Z]+`, `[~!@#$%^&*?_-]+`}for _, pattern := range patternList {match, _ := regexp.MatchString(pattern, pwd)@@ -41,7 +41,7 @@ func CheckPassword(minLength, maxLength, minLevel int, pwd string) error {// If the final password strength falls below the required minimum strength, return with an errorif level < minLevel {- return fmt.Errorf("The password does not satisfy the current policy requirements. ")+ return fmt.Errorf("the password does not satisfy the current policy requirements")}return nil}diff --git a/pkg/uid/id.go b/pkg/uid/id.goindex bd29f083..a89daa6b 100644--- a/pkg/uid/id.go+++ b/pkg/uid/id.go@@ -15,7 +15,7 @@ type SnowFlakeID struct {var snowFlakeIDGenerator *SnowFlakeIDfunc init() {- //todo+ // todorand.Seed(time.Now().UnixNano())node, err := snowflake.NewNode(int64(rand.Intn(1000)) + 1)if err != nil {