fix(admin): 添加管理操作错误处理及更新模板样式
- 管理后台帖子与用户审核操作中添加失败错误重定向处理 - 管理后台帖子、用户、评论删除操作中添加错误检查及提示 - 用户角色更新操作失败时添加错误重定向 - 用户封禁通知失败时添加相应错误提示 - 登录登出时session保存加入错误处理 - 讨论区上传目录创建失败时显示错误提示 - 移除admin_dashboard.html多余样式及修正侧边栏当前页高亮 - admin_posts.html和admin_users.html添加状态样式动态使用的隐藏span元素 - admin_users.html为角色选择添加label以提升无障碍性 - 升级项目依赖版本,包含gin、gorm、validator等核心库版本更新
This commit is contained in:
@@ -4,11 +4,12 @@ import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"lv8girl/internal/middleware"
|
||||
"lv8girl/internal/repositories"
|
||||
"lv8girl/internal/services"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type HomeController struct {
|
||||
@@ -36,7 +37,7 @@ func (c *HomeController) Index(ctx *gin.Context) {
|
||||
|
||||
if isLoggedIn {
|
||||
userRepo := repositories.NewUserRepository()
|
||||
userRepo.UpdateLastActive(userID)
|
||||
_ = userRepo.UpdateLastActive(userID)
|
||||
}
|
||||
|
||||
posts, _ := c.discussionSvc.GetApprovedPosts(30)
|
||||
@@ -86,10 +87,10 @@ func (c *HomeController) ShowPost(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
if !viewedMap[postID] {
|
||||
c.discussionSvc.IncrementViews(postID)
|
||||
_ = c.discussionSvc.IncrementViews(postID)
|
||||
viewedMap[postID] = true
|
||||
session.Set(viewedKey, viewedMap)
|
||||
session.Save()
|
||||
_ = session.Save()
|
||||
}
|
||||
|
||||
detail, err := c.discussionSvc.GetPostDetail(postID, userID)
|
||||
@@ -129,7 +130,7 @@ func (c *HomeController) LikePost(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
postID := parseUint(ctx.Param("id"))
|
||||
c.discussionSvc.AddLike(postID, userID)
|
||||
_ = c.discussionSvc.AddLike(postID, userID)
|
||||
ctx.Redirect(http.StatusFound, "/post/"+ctx.Param("id"))
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ func (c *HomeController) AddComment(ctx *gin.Context) {
|
||||
content := ctx.PostForm("content")
|
||||
|
||||
if content != "" {
|
||||
c.discussionSvc.AddComment(postID, userID, content)
|
||||
_ = c.discussionSvc.AddComment(postID, userID, content)
|
||||
}
|
||||
|
||||
ctx.Redirect(http.StatusFound, "/post/"+ctx.Param("id"))
|
||||
|
||||
Reference in New Issue
Block a user