fix(P2): 修复 import cycle — 将 apierror 移出 internal/http 避免循环依赖

This commit is contained in:
Sisyphus
2026-04-25 16:18:57 +08:00
parent 4094a13846
commit 15f86f08ae
9 changed files with 61 additions and 61 deletions

View File

@@ -3,7 +3,7 @@ package account
import (
"errors"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
@@ -19,7 +19,7 @@ func NewAccountHandler(accountService *AccountService) *AccountHandler {
func (h *AccountHandler) CreateAccount(c *gin.Context) {
var req CreateAccountRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if err := h.accountService.CreateAccount(c.Request.Context(), &Account{
@@ -35,18 +35,18 @@ func (h *AccountHandler) CreateAccount(c *gin.Context) {
func (h *AccountHandler) Rename(c *gin.Context) {
var req RenameRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
accountID, err := getAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
token, err := h.accountService.Rename(c.Request.Context(), accountID, req.NewUsername)
if err != nil {
if errors.Is(err, ErrNewUsernameRequired) {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if errors.Is(err, ErrUsernameTaken) {
@@ -66,7 +66,7 @@ func (h *AccountHandler) Rename(c *gin.Context) {
func (h *AccountHandler) ChangePassword(c *gin.Context) {
var req ChangePasswordRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if err := h.accountService.ChangePassword(c.Request.Context(), req.Username, req.OldPassword, req.NewPassword); err != nil {
@@ -79,7 +79,7 @@ func (h *AccountHandler) ChangePassword(c *gin.Context) {
func (h *AccountHandler) FindByID(c *gin.Context) {
var req FindByIDRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if account, err := h.accountService.FindByID(c.Request.Context(), req.ID); err != nil {
@@ -93,7 +93,7 @@ func (h *AccountHandler) FindByID(c *gin.Context) {
func (h *AccountHandler) FindByUsername(c *gin.Context) {
var req FindByUsernameRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if account, err := h.accountService.FindByUsername(c.Request.Context(), req.Username); err != nil {
@@ -107,7 +107,7 @@ func (h *AccountHandler) FindByUsername(c *gin.Context) {
func (h *AccountHandler) Login(c *gin.Context) {
var req LoginRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if token, err := h.accountService.Login(c.Request.Context(), req.Username, req.Password); err != nil {
@@ -121,7 +121,7 @@ func (h *AccountHandler) Login(c *gin.Context) {
func (h *AccountHandler) Logout(c *gin.Context) {
accountID, err := getAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if err := h.accountService.Logout(c.Request.Context(), accountID); err != nil {

View File

@@ -1,4 +1,4 @@
package http
package apierror
import (
"errors"

View File

@@ -2,7 +2,7 @@ package feed
import (
"feedsystem_video_go/internal/middleware/jwt"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"time"
"github.com/gin-gonic/gin"
@@ -19,7 +19,7 @@ func NewFeedHandler(service *FeedService) *FeedHandler {
func (f *FeedHandler) ListLatest(c *gin.Context) {
var req ListLatestRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.Limit <= 0 || req.Limit > 50 {
@@ -45,7 +45,7 @@ func (f *FeedHandler) ListLatest(c *gin.Context) {
func (f *FeedHandler) ListLikesCount(c *gin.Context) {
var req ListLikesCountRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.Limit <= 0 || req.Limit > 50 {
@@ -94,7 +94,7 @@ func (f *FeedHandler) ListLikesCount(c *gin.Context) {
func (f *FeedHandler) ListByFollowing(c *gin.Context) {
var req ListByFollowingRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.Limit <= 0 || req.Limit > 50 {
@@ -120,7 +120,7 @@ func (f *FeedHandler) ListByFollowing(c *gin.Context) {
func (f *FeedHandler) ListByPopularity(c *gin.Context) {
var req ListByPopularityRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.Limit <= 0 || req.Limit > 50 {

View File

@@ -2,7 +2,7 @@ package social
import (
"feedsystem_video_go/internal/account"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"feedsystem_video_go/internal/middleware/jwt"
"net/http"
@@ -20,7 +20,7 @@ func NewSocialHandler(service *SocialService) *SocialHandler {
func (h *SocialHandler) Follow(c *gin.Context) {
var req FollowRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VloggerID <= 0 {
@@ -37,7 +37,7 @@ func (h *SocialHandler) Follow(c *gin.Context) {
VloggerID: req.VloggerID,
}
if err := h.service.Follow(c.Request.Context(), social); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "followed"})
@@ -46,7 +46,7 @@ func (h *SocialHandler) Follow(c *gin.Context) {
func (h *SocialHandler) Unfollow(c *gin.Context) {
var req UnfollowRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VloggerID <= 0 {
@@ -63,7 +63,7 @@ func (h *SocialHandler) Unfollow(c *gin.Context) {
VloggerID: req.VloggerID,
}
if err := h.service.Unfollow(c.Request.Context(), social); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "unfollowed"})
@@ -72,7 +72,7 @@ func (h *SocialHandler) Unfollow(c *gin.Context) {
func (h *SocialHandler) GetAllFollowers(c *gin.Context) {
var req GetAllFollowersRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
@@ -88,7 +88,7 @@ func (h *SocialHandler) GetAllFollowers(c *gin.Context) {
followers, err := h.service.GetAllFollowers(c.Request.Context(), vloggerID)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if followers == nil {
@@ -100,7 +100,7 @@ func (h *SocialHandler) GetAllFollowers(c *gin.Context) {
func (h *SocialHandler) GetAllVloggers(c *gin.Context) {
var req GetAllVloggersRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
@@ -116,7 +116,7 @@ func (h *SocialHandler) GetAllVloggers(c *gin.Context) {
vloggers, err := h.service.GetAllVloggers(c.Request.Context(), followerID)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if vloggers == nil {

View File

@@ -2,7 +2,7 @@ package video
import (
"feedsystem_video_go/internal/account"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"feedsystem_video_go/internal/middleware/jwt"
"github.com/gin-gonic/gin"
@@ -19,7 +19,7 @@ func NewCommentHandler(service *CommentService, accountService *account.AccountS
func (h *CommentHandler) PublishComment(c *gin.Context) {
var req PublishCommentRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.Content == "" {
@@ -32,12 +32,12 @@ func (h *CommentHandler) PublishComment(c *gin.Context) {
}
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
user, err := h.accountService.FindByID(c.Request.Context(), authorId)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
comment := &Comment{
@@ -47,7 +47,7 @@ func (h *CommentHandler) PublishComment(c *gin.Context) {
Content: req.Content,
}
if err := h.service.Publish(c.Request.Context(), comment); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "comment published successfully"})
@@ -56,12 +56,12 @@ func (h *CommentHandler) PublishComment(c *gin.Context) {
func (h *CommentHandler) DeleteComment(c *gin.Context) {
var req DeleteCommentRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.CommentID <= 0 {
@@ -69,7 +69,7 @@ func (h *CommentHandler) DeleteComment(c *gin.Context) {
return
}
if err := h.service.Delete(c.Request.Context(), req.CommentID, accountID); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
@@ -79,7 +79,7 @@ func (h *CommentHandler) DeleteComment(c *gin.Context) {
func (h *CommentHandler) GetAllComments(c *gin.Context) {
var req GetAllCommentsRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VideoID == 0 {
@@ -88,7 +88,7 @@ func (h *CommentHandler) GetAllComments(c *gin.Context) {
}
comments, err := h.service.GetAll(c.Request.Context(), req.VideoID)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if comments == nil {

View File

@@ -5,7 +5,7 @@ import (
"errors"
"feedsystem_video_go/internal/middleware/rabbitmq"
rediscache "feedsystem_video_go/internal/middleware/redis"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"strings"
"gorm.io/gorm"
@@ -95,7 +95,7 @@ func (s *CommentService) Delete(ctx context.Context, commentID uint, accountID u
return errors.New("comment not found")
}
if comment.AuthorID != accountID {
return httputil.ErrUnauthorized
return apierror.ErrUnauthorized
}
if s.commentMQ != nil {
if err := s.commentMQ.Delete(ctx, commentID); err == nil {

View File

@@ -2,7 +2,7 @@ package video
import (
"feedsystem_video_go/internal/middleware/jwt"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"github.com/gin-gonic/gin"
)
@@ -18,7 +18,7 @@ func NewLikeHandler(service *LikeService) *LikeHandler {
func (lh *LikeHandler) Like(c *gin.Context) {
var req LikeRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VideoID <= 0 {
@@ -28,7 +28,7 @@ func (lh *LikeHandler) Like(c *gin.Context) {
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
@@ -46,7 +46,7 @@ func (lh *LikeHandler) Like(c *gin.Context) {
func (lh *LikeHandler) Unlike(c *gin.Context) {
var req LikeRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VideoID <= 0 {
@@ -56,7 +56,7 @@ func (lh *LikeHandler) Unlike(c *gin.Context) {
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
@@ -74,7 +74,7 @@ func (lh *LikeHandler) Unlike(c *gin.Context) {
func (lh *LikeHandler) IsLiked(c *gin.Context) {
var req LikeRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if req.VideoID <= 0 {
@@ -84,7 +84,7 @@ func (lh *LikeHandler) IsLiked(c *gin.Context) {
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
isLiked, err := lh.service.IsLiked(c.Request.Context(), req.VideoID, accountID)
@@ -98,7 +98,7 @@ func (lh *LikeHandler) IsLiked(c *gin.Context) {
func (lh *LikeHandler) ListMyLikedVideos(c *gin.Context) {
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}

View File

@@ -12,7 +12,7 @@ import (
"time"
"feedsystem_video_go/internal/account"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"feedsystem_video_go/internal/middleware/jwt"
"github.com/gin-gonic/gin"
@@ -30,18 +30,18 @@ func NewVideoHandler(service *VideoService, accountService *account.AccountServi
func (vh *VideoHandler) PublishVideo(c *gin.Context) {
var req PublishVideoRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
username, err := jwt.GetUsername(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
video := &Video{
@@ -54,7 +54,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) {
CreateTime: time.Now(),
}
if err := vh.service.Publish(c.Request.Context(), video); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(200, video)
@@ -194,16 +194,16 @@ func buildAbsoluteURL(c *gin.Context, p string) string {
func (vh *VideoHandler) DeleteVideo(c *gin.Context) {
var req DeleteVideoRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if err := vh.service.Delete(c.Request.Context(), req.ID, authorId); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "video deleted"})
@@ -212,12 +212,12 @@ func (vh *VideoHandler) DeleteVideo(c *gin.Context) {
func (vh *VideoHandler) ListByAuthorID(c *gin.Context) {
var req ListByAuthorIDRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
videos, err := vh.service.ListByAuthorID(c.Request.Context(), req.AuthorID)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if videos == nil {
@@ -229,12 +229,12 @@ func (vh *VideoHandler) ListByAuthorID(c *gin.Context) {
func (vh *VideoHandler) GetDetail(c *gin.Context) {
var req GetDetailRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
video, err := vh.service.GetDetail(c.Request.Context(), req.ID)
if err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(200, video)
@@ -243,11 +243,11 @@ func (vh *VideoHandler) GetDetail(c *gin.Context) {
func (vh *VideoHandler) UpdateLikesCount(c *gin.Context) {
var req UpdateLikesCountRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
if err := vh.service.UpdateLikesCount(c.Request.Context(), req.ID, req.LikesCount); err != nil {
c.JSON(httputil.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
c.JSON(apierror.ClassifyHTTPStatus(err), gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "likes count updated"})

View File

@@ -11,7 +11,7 @@ import (
"feedsystem_video_go/internal/middleware/rabbitmq"
rediscache "feedsystem_video_go/internal/middleware/redis"
httputil "feedsystem_video_go/internal/http"
"feedsystem_video_go/internal/apierror"
"gorm.io/gorm"
)
@@ -77,7 +77,7 @@ func (vs *VideoService) Delete(ctx context.Context, id uint, authorID uint) erro
return errors.New("video not found")
}
if video.AuthorID != authorID {
return httputil.ErrUnauthorized
return apierror.ErrUnauthorized
}
if err := vs.repo.DeleteVideo(ctx, id); err != nil {
return err