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:
@@ -7,9 +7,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"lv8girl/internal/middleware"
|
||||
"lv8girl/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type DiscussionController struct {
|
||||
@@ -72,7 +73,17 @@ func (c *DiscussionController) CreatePost(ctx *gin.Context) {
|
||||
uploadDir := "uploads/posts"
|
||||
|
||||
if _, err := os.Stat(uploadDir); os.IsNotExist(err) {
|
||||
os.MkdirAll(uploadDir, 0755)
|
||||
if err := os.MkdirAll(uploadDir, 0755); err != nil {
|
||||
ctx.HTML(http.StatusOK, "post_discussion.html", gin.H{
|
||||
"IsLoggedIn": true,
|
||||
"UserID": userID,
|
||||
"Username": username,
|
||||
"UserRole": userRole,
|
||||
"Error": "创建上传目录失败",
|
||||
"Success": "",
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
imagePath = filepath.Join(uploadDir, filename)
|
||||
|
||||
Reference in New Issue
Block a user