fix: stabilize backend tests
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -127,8 +128,7 @@ func (s *content) List(ctx context.Context, filter *content_dto.ContentListFilte
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *content) Get(ctx context.Context, userID int64, id int64) (*content_dto.ContentDetail, error) {
|
||||
|
||||
func (s *content) Get(ctx context.Context, userID, id int64) (*content_dto.ContentDetail, error) {
|
||||
// Increment Views
|
||||
_, _ = models.ContentQuery.WithContext(ctx).
|
||||
Where(models.ContentQuery.ID.Eq(id)).
|
||||
@@ -212,7 +212,7 @@ func (s *content) Get(ctx context.Context, userID int64, id int64) (*content_dto
|
||||
if userID > 0 {
|
||||
exists, _ := models.TenantUserQuery.WithContext(ctx).
|
||||
Where(models.TenantUserQuery.TenantID.Eq(item.TenantID),
|
||||
models.TenantUserQuery.Role.Contains(string(consts.TenantUserRoleMember))).
|
||||
models.TenantUserQuery.Role.Contains(types.Array[consts.TenantUserRole]{consts.TenantUserRoleMember})).
|
||||
Exists()
|
||||
authorIsFollowing = exists
|
||||
}
|
||||
@@ -232,7 +232,7 @@ func (s *content) Get(ctx context.Context, userID int64, id int64) (*content_dto
|
||||
return detail, nil
|
||||
}
|
||||
|
||||
func (s *content) ListComments(ctx context.Context, userID int64, id int64, page int) (*requests.Pager, error) {
|
||||
func (s *content) ListComments(ctx context.Context, userID, id int64, page int) (*requests.Pager, error) {
|
||||
tbl, q := models.CommentQuery.QueryContext(ctx)
|
||||
|
||||
q = q.Where(tbl.ContentID.Eq(id)).Preload(tbl.User)
|
||||
@@ -319,7 +319,7 @@ func (s *content) CreateComment(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *content) LikeComment(ctx context.Context, userID int64, id int64) error {
|
||||
func (s *content) LikeComment(ctx context.Context, userID, id int64) error {
|
||||
if userID == 0 {
|
||||
return errorx.ErrUnauthorized
|
||||
}
|
||||
@@ -402,11 +402,11 @@ func (s *content) GetFavorites(ctx context.Context, userID int64) ([]user_dto.Co
|
||||
return s.getInteractList(ctx, userID, "favorite")
|
||||
}
|
||||
|
||||
func (s *content) AddFavorite(ctx context.Context, userID int64, contentId int64) error {
|
||||
func (s *content) AddFavorite(ctx context.Context, userID, contentId int64) error {
|
||||
return s.addInteract(ctx, userID, contentId, "favorite")
|
||||
}
|
||||
|
||||
func (s *content) RemoveFavorite(ctx context.Context, userID int64, contentId int64) error {
|
||||
func (s *content) RemoveFavorite(ctx context.Context, userID, contentId int64) error {
|
||||
return s.removeInteract(ctx, userID, contentId, "favorite")
|
||||
}
|
||||
|
||||
@@ -414,11 +414,11 @@ func (s *content) GetLikes(ctx context.Context, userID int64) ([]user_dto.Conten
|
||||
return s.getInteractList(ctx, userID, "like")
|
||||
}
|
||||
|
||||
func (s *content) AddLike(ctx context.Context, userID int64, contentId int64) error {
|
||||
func (s *content) AddLike(ctx context.Context, userID, contentId int64) error {
|
||||
return s.addInteract(ctx, userID, contentId, "like")
|
||||
}
|
||||
|
||||
func (s *content) RemoveLike(ctx context.Context, userID int64, contentId int64) error {
|
||||
func (s *content) RemoveLike(ctx context.Context, userID, contentId int64) error {
|
||||
return s.removeInteract(ctx, userID, contentId, "like")
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ func (s *content) toMediaURLs(assets []*models.ContentAsset) []content_dto.Media
|
||||
return urls
|
||||
}
|
||||
|
||||
func (s *content) addInteract(ctx context.Context, userID int64, contentId int64, typ string) error {
|
||||
func (s *content) addInteract(ctx context.Context, userID, contentId int64, typ string) error {
|
||||
if userID == 0 {
|
||||
return errorx.ErrUnauthorized
|
||||
}
|
||||
@@ -605,7 +605,7 @@ func (s *content) addInteract(ctx context.Context, userID int64, contentId int64
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *content) removeInteract(ctx context.Context, userID int64, contentId int64, typ string) error {
|
||||
func (s *content) removeInteract(ctx context.Context, userID, contentId int64, typ string) error {
|
||||
if userID == 0 {
|
||||
return errorx.ErrUnauthorized
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user