chore: stabilize lint and verify builds
This commit is contained in:
@@ -160,6 +160,7 @@ func (s *content) Get(ctx context.Context, tenantID, userID, id int64) (*content
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, errorx.ErrRecordNotFound
|
||||
}
|
||||
|
||||
return nil, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
|
||||
@@ -288,6 +289,7 @@ func (s *content) ListComments(ctx context.Context, tenantID, userID, id int64,
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, errorx.ErrRecordNotFound
|
||||
}
|
||||
|
||||
return nil, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
if err := s.ensureContentReadable(ctx, userID, content); err != nil {
|
||||
@@ -388,6 +390,7 @@ func (s *content) CreateComment(
|
||||
if err := models.CommentQuery.WithContext(ctx).Create(comment); err != nil {
|
||||
return errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -415,6 +418,7 @@ func (s *content) LikeComment(ctx context.Context, tenantID, userID, id int64) e
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return errorx.ErrRecordNotFound
|
||||
}
|
||||
|
||||
return errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
if err := s.ensureContentReadable(ctx, userID, c); err != nil {
|
||||
@@ -435,6 +439,7 @@ func (s *content) LikeComment(ctx context.Context, tenantID, userID, id int64) e
|
||||
}
|
||||
|
||||
_, err := tx.Comment.WithContext(ctx).Where(tx.Comment.ID.Eq(id)).UpdateSimple(tx.Comment.Likes.Add(1))
|
||||
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
@@ -444,6 +449,7 @@ func (s *content) LikeComment(ctx context.Context, tenantID, userID, id int64) e
|
||||
if Notification != nil {
|
||||
_ = Notification.Send(ctx, tenantID, cm.UserID, "interaction", "评论点赞", "有人点赞了您的评论")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -493,6 +499,7 @@ func (s *content) GetLibrary(ctx context.Context, tenantID, userID int64) ([]use
|
||||
dto.IsPurchased = true
|
||||
data = append(data, dto)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -630,6 +637,7 @@ func (s *content) ListTopics(ctx context.Context, tenantID int64) ([]content_dto
|
||||
Cover: cover,
|
||||
})
|
||||
}
|
||||
|
||||
return topics, nil
|
||||
}
|
||||
|
||||
@@ -683,6 +691,7 @@ func (s *content) toContentItemDTO(item *models.Content, price float64, authorIs
|
||||
for _, asset := range item.ContentAssets {
|
||||
if asset.Asset != nil && asset.Asset.Type == consts.MediaAssetTypeImage {
|
||||
dto.Cover = Common.GetAssetURL(asset.Asset.ObjectKey)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -745,6 +754,7 @@ func (s *content) ensureContentReadable(ctx context.Context, userID int64, item
|
||||
if !isMember {
|
||||
return errorx.ErrForbidden.WithMsg("内容仅限本店铺成员访问")
|
||||
}
|
||||
|
||||
return nil
|
||||
default:
|
||||
return nil
|
||||
@@ -765,6 +775,7 @@ func (s *content) ensureContentOwnerOrAdmin(ctx context.Context, userID int64, i
|
||||
if !isAdmin {
|
||||
return errorx.ErrForbidden.WithMsg(msg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -780,6 +791,7 @@ func (s *content) isTenantAdmin(ctx context.Context, tenantID, userID int64) (bo
|
||||
if err != nil {
|
||||
return false, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
@@ -792,6 +804,7 @@ func (s *content) isTenantMember(ctx context.Context, tenantID, userID int64) (b
|
||||
if err != nil {
|
||||
return false, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
@@ -806,6 +819,7 @@ func (s *content) toMediaURLs(assets []*models.ContentAsset) []content_dto.Media
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return urls
|
||||
}
|
||||
|
||||
@@ -850,8 +864,10 @@ func (s *content) addInteract(ctx context.Context, tenantID, userID, contentId i
|
||||
contentQuery = contentQuery.Where(tx.Content.TenantID.Eq(tenantID))
|
||||
}
|
||||
_, err := contentQuery.UpdateSimple(tx.Content.Likes.Add(1))
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -868,6 +884,7 @@ func (s *content) addInteract(ctx context.Context, tenantID, userID, contentId i
|
||||
}
|
||||
_ = Notification.Send(ctx, tenantID, c.UserID, "interaction", "新的"+actionName, "有人"+actionName+"了您的作品: "+c.Title)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -894,8 +911,10 @@ func (s *content) removeInteract(ctx context.Context, tenantID, userID, contentI
|
||||
contentQuery = contentQuery.Where(tx.Content.TenantID.Eq(tenantID))
|
||||
}
|
||||
_, err := contentQuery.UpdateSimple(tx.Content.Likes.Sub(1))
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -940,5 +959,6 @@ func (s *content) getInteractList(ctx context.Context, tenantID, userID int64, t
|
||||
for _, item := range list {
|
||||
data = append(data, s.toContentItemDTO(item, 0, false))
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user