GetUnreviewedRevisionList

This commit is contained in:
aichy126 2022-11-23 16:52:27 +08:00
parent 6202877bdc
commit a923e6f0b4
3 changed files with 32 additions and 14 deletions

View File

@ -163,7 +163,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,
searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon)
searchService := service.NewSearchService(searchParser, searchRepo)
searchController := controller.NewSearchController(searchService)
serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService)
serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService, objService)
revisionController := controller.NewRevisionController(serviceRevisionService)
rankController := controller.NewRankController(rankService)
commonRepo := common.NewCommonRepo(dataData, uniqueIDRepo)

View File

@ -30,6 +30,10 @@ type RevisionSearch struct {
Page int `json:"page" form:"page"` // Query number of pages
}
type GetUnreviewedRevisionResp struct {
Type string `json:"type"`
}
// GetRevisionResp get revision response
type GetRevisionResp struct {
// id

View File

@ -7,6 +7,7 @@ import (
"github.com/answerdev/answer/internal/base/constant"
"github.com/answerdev/answer/internal/entity"
"github.com/answerdev/answer/internal/schema"
"github.com/answerdev/answer/internal/service/object_info"
questioncommon "github.com/answerdev/answer/internal/service/question_common"
"github.com/answerdev/answer/internal/service/revision"
usercommon "github.com/answerdev/answer/internal/service/user_common"
@ -20,29 +21,42 @@ type RevisionService struct {
userCommon *usercommon.UserCommon
questionCommon *questioncommon.QuestionCommon
answerService *AnswerService
objectInfoService *object_info.ObjService
}
func NewRevisionService(
revisionRepo revision.RevisionRepo,
userCommon *usercommon.UserCommon,
questionCommon *questioncommon.QuestionCommon,
answerService *AnswerService) *RevisionService {
answerService *AnswerService,
objectInfoService *object_info.ObjService,
) *RevisionService {
return &RevisionService{
revisionRepo: revisionRepo,
userCommon: userCommon,
questionCommon: questionCommon,
answerService: answerService,
objectInfoService: objectInfoService,
}
}
// SearchUnreviewedList get unreviewed list
func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []schema.GetRevisionResp, count int64, err error) {
resp = []schema.GetRevisionResp{}
func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []*schema.GetUnreviewedRevisionResp, count int64, err error) {
resp = []*schema.GetUnreviewedRevisionResp{}
search := &entity.RevisionSearch{}
_ = copier.Copy(search, req)
list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search)
for _, item := range list {
spew.Dump(item)
for _, revision := range list {
spew.Dump(revision)
item := &schema.GetUnreviewedRevisionResp{}
_, ok := constant.ObjectTypeNumberMapping[revision.ObjectType]
if !ok {
continue
}
item.Type = constant.ObjectTypeNumberMapping[revision.ObjectType]
info, err := rs.objectInfoService.GetInfo(ctx, revision.ObjectID)
spew.Dump(info, err)
resp = append(resp, item)
}
return