Skip to content

Commit

Permalink
路线图关联关系倒序排序
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed Jul 21, 2024
1 parent ab6902a commit f29365f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
32 changes: 16 additions & 16 deletions internal/roadmap/internal/integration/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ func (s *AdminHandlerTestSuite) TestDetail() {
}).Error
require.NoError(s.T(), err)
edges := []dao.Edge{
{Id: 1, Rid: 1, SrcBiz: domain.BizQuestionSet, SrcId: 1, DstBiz: domain.BizQuestion, DstId: 2},
{Id: 2, Rid: 1, SrcBiz: domain.BizQuestion, SrcId: 2, DstBiz: domain.BizQuestionSet, DstId: 3},
{Id: 3, Rid: 2, SrcBiz: domain.BizQuestion, SrcId: 2, DstBiz: domain.BizQuestionSet, DstId: 3},
{Id: 1, Rid: 1, SrcBiz: domain.BizQuestionSet, SrcId: 1, DstBiz: domain.BizQuestion, DstId: 2, Utime: 123},
{Id: 2, Rid: 1, SrcBiz: domain.BizQuestion, SrcId: 2, DstBiz: domain.BizQuestionSet, DstId: 3, Utime: 124},
{Id: 3, Rid: 2, SrcBiz: domain.BizQuestion, SrcId: 2, DstBiz: domain.BizQuestionSet, DstId: 3, Utime: 125},
}
err = db.Create(&edges).Error
require.NoError(s.T(), err)
Expand All @@ -340,19 +340,6 @@ func (s *AdminHandlerTestSuite) TestDetail() {
BizTitle: "题目123",
Utime: 222,
Edges: []web.Edge{
{
Id: 1,
Src: web.Node{
Biz: domain.BizQuestionSet,
BizId: 1,
Title: "题集1",
},
Dst: web.Node{
Biz: domain.BizQuestion,
BizId: 2,
Title: "题目2",
},
},
{
Id: 2,
Src: web.Node{
Expand All @@ -366,6 +353,19 @@ func (s *AdminHandlerTestSuite) TestDetail() {
Title: "题集3",
},
},
{
Id: 1,
Src: web.Node{
Biz: domain.BizQuestionSet,
BizId: 1,
Title: "题集1",
},
Dst: web.Node{
Biz: domain.BizQuestion,
BizId: 2,
Title: "题目2",
},
},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion internal/roadmap/internal/repository/dao/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (dao *GORMAdminDAO) AddEdge(ctx context.Context, edge Edge) error {

func (dao *GORMAdminDAO) GetEdgesByRid(ctx context.Context, rid int64) ([]Edge, error) {
var res []Edge
err := dao.db.WithContext(ctx).Where("rid = ?", rid).Find(&res).Error
// 按照更新时间倒序排序
err := dao.db.WithContext(ctx).Where("rid = ?", rid).Order("utime DESC").Find(&res).Error
return res, err
}

Expand Down

0 comments on commit f29365f

Please sign in to comment.