refactor: 将redis提取到middleware文件夹

This commit is contained in:
Leon
2025-12-28 18:38:14 +08:00
parent c43b9d8cd6
commit fbd0cd38ec
12 changed files with 38 additions and 39 deletions

View File

@@ -2,7 +2,7 @@ package video
import (
"feedsystem_video_go/internal/account"
"feedsystem_video_go/internal/middleware"
"feedsystem_video_go/internal/middleware/jwt"
"github.com/gin-gonic/gin"
)
@@ -30,7 +30,7 @@ func (h *CommentHandler) PublishComment(c *gin.Context) {
c.JSON(400, gin.H{"error": "video_id is required"})
return
}
authorId, err := middleware.GetAccountID(c)
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
@@ -63,7 +63,7 @@ func (h *CommentHandler) DeleteComment(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()})
return
}
accountID, err := middleware.GetAccountID(c)
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return

View File

@@ -1,7 +1,7 @@
package video
import (
"feedsystem_video_go/internal/middleware"
"feedsystem_video_go/internal/middleware/jwt"
"github.com/gin-gonic/gin"
)
@@ -26,7 +26,7 @@ func (lh *LikeHandler) Like(c *gin.Context) {
return
}
accountID, err := middleware.GetAccountID(c)
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
@@ -58,7 +58,7 @@ func (lh *LikeHandler) Unlike(c *gin.Context) {
return
}
accountID, err := middleware.GetAccountID(c)
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
@@ -90,7 +90,7 @@ func (lh *LikeHandler) IsLiked(c *gin.Context) {
return
}
accountID, err := middleware.GetAccountID(c)
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
@@ -104,7 +104,7 @@ func (lh *LikeHandler) IsLiked(c *gin.Context) {
}
func (lh *LikeHandler) ListMyLikedVideos(c *gin.Context) {
accountID, err := middleware.GetAccountID(c)
accountID, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return

View File

@@ -12,7 +12,7 @@ import (
"time"
"feedsystem_video_go/internal/account"
"feedsystem_video_go/internal/middleware"
"feedsystem_video_go/internal/middleware/jwt"
"github.com/gin-gonic/gin"
)
@@ -33,7 +33,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) {
return
}
authorId, err := middleware.GetAccountID(c)
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
@@ -60,7 +60,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) {
}
func (vh *VideoHandler) UploadVideo(c *gin.Context) {
authorId, err := middleware.GetAccountID(c)
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
@@ -110,7 +110,7 @@ func (vh *VideoHandler) UploadVideo(c *gin.Context) {
}
func (vh *VideoHandler) UploadCover(c *gin.Context) {
authorId, err := middleware.GetAccountID(c)
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
@@ -184,7 +184,7 @@ func (vh *VideoHandler) DeleteVideo(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()})
return
}
authorId, err := middleware.GetAccountID(c)
authorId, err := jwt.GetAccountID(c)
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return

View File

@@ -9,7 +9,7 @@ import (
"strings"
"time"
rediscache "feedsystem_video_go/internal/redis"
rediscache "feedsystem_video_go/internal/middleware/redis"
)
type VideoService struct {