fix: revision use created_at as the condition

This commit is contained in:
LinkinStar 2022-11-01 16:27:33 +08:00
parent 425159ecc3
commit c10930d160
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ func Test_userBackyardRepo_GetUserInfo(t *testing.T) {
func Test_userBackyardRepo_GetUserPage(t *testing.T) { func Test_userBackyardRepo_GetUserPage(t *testing.T) {
userBackyardRepo := user.NewUserBackyardRepo(testDataSource, auth.NewAuthRepo(testDataSource)) userBackyardRepo := user.NewUserBackyardRepo(testDataSource, auth.NewAuthRepo(testDataSource))
got, total, err := userBackyardRepo.GetUserPage(context.TODO(), 1, 1, &entity.User{Username: "admin"}) got, total, err := userBackyardRepo.GetUserPage(context.TODO(), 1, 1, &entity.User{Username: "admin"}, "")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, int64(1), total) assert.Equal(t, int64(1), total)
assert.Equal(t, "1", got[0].ID) assert.Equal(t, "1", got[0].ID)

View File

@ -96,7 +96,7 @@ func (rr *revisionRepo) GetLastRevisionByObjectID(ctx context.Context, objectID
revision *entity.Revision, exist bool, err error, revision *entity.Revision, exist bool, err error,
) { ) {
revision = &entity.Revision{} revision = &entity.Revision{}
exist, err = rr.data.DB.Where("object_id = ?", objectID).OrderBy("create_time DESC").Get(revision) exist, err = rr.data.DB.Where("object_id = ?", objectID).OrderBy("created_at DESC").Get(revision)
if err != nil { if err != nil {
return nil, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() return nil, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
} }