mirror of https://gitee.com/answerdev/answer.git
GetUnreviewedRevisionList
This commit is contained in:
parent
6202877bdc
commit
a923e6f0b4
|
@ -163,7 +163,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,
|
||||||
searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon)
|
searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon)
|
||||||
searchService := service.NewSearchService(searchParser, searchRepo)
|
searchService := service.NewSearchService(searchParser, searchRepo)
|
||||||
searchController := controller.NewSearchController(searchService)
|
searchController := controller.NewSearchController(searchService)
|
||||||
serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService)
|
serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService, objService)
|
||||||
revisionController := controller.NewRevisionController(serviceRevisionService)
|
revisionController := controller.NewRevisionController(serviceRevisionService)
|
||||||
rankController := controller.NewRankController(rankService)
|
rankController := controller.NewRankController(rankService)
|
||||||
commonRepo := common.NewCommonRepo(dataData, uniqueIDRepo)
|
commonRepo := common.NewCommonRepo(dataData, uniqueIDRepo)
|
||||||
|
|
|
@ -30,6 +30,10 @@ type RevisionSearch struct {
|
||||||
Page int `json:"page" form:"page"` // Query number of pages
|
Page int `json:"page" form:"page"` // Query number of pages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUnreviewedRevisionResp struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetRevisionResp get revision response
|
// GetRevisionResp get revision response
|
||||||
type GetRevisionResp struct {
|
type GetRevisionResp struct {
|
||||||
// id
|
// id
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/answerdev/answer/internal/base/constant"
|
"github.com/answerdev/answer/internal/base/constant"
|
||||||
"github.com/answerdev/answer/internal/entity"
|
"github.com/answerdev/answer/internal/entity"
|
||||||
"github.com/answerdev/answer/internal/schema"
|
"github.com/answerdev/answer/internal/schema"
|
||||||
|
"github.com/answerdev/answer/internal/service/object_info"
|
||||||
questioncommon "github.com/answerdev/answer/internal/service/question_common"
|
questioncommon "github.com/answerdev/answer/internal/service/question_common"
|
||||||
"github.com/answerdev/answer/internal/service/revision"
|
"github.com/answerdev/answer/internal/service/revision"
|
||||||
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
||||||
|
@ -16,33 +17,46 @@ import (
|
||||||
|
|
||||||
// RevisionService user service
|
// RevisionService user service
|
||||||
type RevisionService struct {
|
type RevisionService struct {
|
||||||
revisionRepo revision.RevisionRepo
|
revisionRepo revision.RevisionRepo
|
||||||
userCommon *usercommon.UserCommon
|
userCommon *usercommon.UserCommon
|
||||||
questionCommon *questioncommon.QuestionCommon
|
questionCommon *questioncommon.QuestionCommon
|
||||||
answerService *AnswerService
|
answerService *AnswerService
|
||||||
|
objectInfoService *object_info.ObjService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRevisionService(
|
func NewRevisionService(
|
||||||
revisionRepo revision.RevisionRepo,
|
revisionRepo revision.RevisionRepo,
|
||||||
userCommon *usercommon.UserCommon,
|
userCommon *usercommon.UserCommon,
|
||||||
questionCommon *questioncommon.QuestionCommon,
|
questionCommon *questioncommon.QuestionCommon,
|
||||||
answerService *AnswerService) *RevisionService {
|
answerService *AnswerService,
|
||||||
|
objectInfoService *object_info.ObjService,
|
||||||
|
) *RevisionService {
|
||||||
return &RevisionService{
|
return &RevisionService{
|
||||||
revisionRepo: revisionRepo,
|
revisionRepo: revisionRepo,
|
||||||
userCommon: userCommon,
|
userCommon: userCommon,
|
||||||
questionCommon: questionCommon,
|
questionCommon: questionCommon,
|
||||||
answerService: answerService,
|
answerService: answerService,
|
||||||
|
objectInfoService: objectInfoService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchUnreviewedList get unreviewed list
|
// SearchUnreviewedList get unreviewed list
|
||||||
func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []schema.GetRevisionResp, count int64, err error) {
|
func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []*schema.GetUnreviewedRevisionResp, count int64, err error) {
|
||||||
resp = []schema.GetRevisionResp{}
|
resp = []*schema.GetUnreviewedRevisionResp{}
|
||||||
search := &entity.RevisionSearch{}
|
search := &entity.RevisionSearch{}
|
||||||
_ = copier.Copy(search, req)
|
_ = copier.Copy(search, req)
|
||||||
list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search)
|
list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search)
|
||||||
for _, item := range list {
|
for _, revision := range list {
|
||||||
spew.Dump(item)
|
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
|
return
|
||||||
|
|
Loading…
Reference in New Issue