diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.go index bf3c483c..8c88552f 100644 --- a/cmd/answer/wire_gen.go +++ b/cmd/answer/wire_gen.go @@ -59,7 +59,6 @@ import ( "github.com/answerdev/answer/internal/service/report_backyard" "github.com/answerdev/answer/internal/service/report_handle_backyard" "github.com/answerdev/answer/internal/service/revision_common" - "github.com/answerdev/answer/internal/service/search_parser" "github.com/answerdev/answer/internal/service/service_config" "github.com/answerdev/answer/internal/service/siteinfo" "github.com/answerdev/answer/internal/service/siteinfo_common" @@ -136,7 +135,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, tagCommonService := tag_common2.NewTagCommonService(tagCommonRepo, tagRelRepo, revisionService, siteInfoCommonService) followRepo := activity_common.NewFollowRepo(dataData, uniqueIDRepo, activityRepo) tagService := tag2.NewTagService(tagRepo, tagCommonService, revisionService, followRepo, siteInfoCommonService) - tagController := controller.NewTagController(tagService, rankService) + tagController := controller.NewTagController(tagService, tagCommonService, rankService) followFollowRepo := activity.NewFollowRepo(dataData, uniqueIDRepo, activityRepo) followService := follow.NewFollowService(followFollowRepo, followRepo, tagCommonRepo) followController := controller.NewFollowController(followService) @@ -157,9 +156,8 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, answerService := service.NewAnswerService(answerRepo, questionRepo, questionCommon, userCommon, collectionCommon, userRepo, revisionService, answerActivityService, answerCommon, voteRepo) dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configRepo, siteInfoCommonService, serviceConf, dataData) answerController := controller.NewAnswerController(answerService, rankService, dashboardService) - searchParser := search_parser.NewSearchParser(tagCommonService, userCommon) searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon) - searchService := service.NewSearchService(searchParser, searchRepo) + searchService := service.NewSearchService(searchRepo, tagCommonService, userCommon, followRepo) searchController := controller.NewSearchController(searchService) serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService) revisionController := controller.NewRevisionController(serviceRevisionService) @@ -183,8 +181,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, notificationService := notification2.NewNotificationService(dataData, notificationRepo, notificationCommon) notificationController := controller.NewNotificationController(notificationService) dashboardController := controller.NewDashboardController(dashboardService) - uploadController := controller.NewUploadController(uploaderService) - answerAPIRouter := router.NewAnswerAPIRouter(langController, userController, commentController, reportController, voteController, tagController, followController, collectionController, questionController, answerController, searchController, revisionController, rankController, controller_backyardReportController, userBackyardController, reasonController, themeController, siteInfoController, siteinfoController, notificationController, dashboardController, uploadController) + answerAPIRouter := router.NewAnswerAPIRouter(langController, userController, commentController, reportController, voteController, tagController, followController, collectionController, questionController, answerController, searchController, revisionController, rankController, controller_backyardReportController, userBackyardController, reasonController, themeController, siteInfoController, siteinfoController, notificationController, dashboardController) swaggerRouter := router.NewSwaggerRouter(swaggerConf) uiRouter := router.NewUIRouter() authUserMiddleware := middleware.NewAuthUserMiddleware(authService) diff --git a/internal/controller/tag_controller.go b/internal/controller/tag_controller.go index 33791cb1..673a746c 100644 --- a/internal/controller/tag_controller.go +++ b/internal/controller/tag_controller.go @@ -20,8 +20,12 @@ type TagController struct { } // NewTagController new controller -func NewTagController(tagService *tag.TagService, rankService *rank.RankService) *TagController { - return &TagController{tagService: tagService, rankService: rankService} +func NewTagController( + tagService *tag.TagService, + tagCommonService *tag_common.TagCommonService, + rankService *rank.RankService, +) *TagController { + return &TagController{tagService: tagService, tagCommonService: tagCommonService, rankService: rankService} } // SearchTagLike get tag list diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go index dda1c923..ec67720a 100644 --- a/internal/service/tag_common/tag_common.go +++ b/internal/service/tag_common/tag_common.go @@ -271,6 +271,9 @@ func (ts *TagCommonService) TagFormat(ctx context.Context, tags []*entity.Tag) ( } func (ts *TagCommonService) tagsFormatRecommendAndReserved(ctx context.Context, tagList []*entity.Tag) { + if len(tagList) == 0 { + return + } tagConfig, err := ts.siteInfoService.GetSiteWrite(ctx) if err != nil { log.Error(err) @@ -284,6 +287,9 @@ func (ts *TagCommonService) tagsFormatRecommendAndReserved(ctx context.Context, } func (ts *TagCommonService) tagFormatRecommendAndReserved(ctx context.Context, tag *entity.Tag) { + if tag == nil { + return + } tagConfig, err := ts.siteInfoService.GetSiteWrite(ctx) if err != nil { log.Error(err)