fix: 上传200MB限制、备案信息、超级管理员仅首注、文件管理菜单

Made-with: Cursor
This commit is contained in:
whm
2026-03-18 16:50:20 +08:00
parent 31b1f2bb4c
commit d5bc102bd7
8 changed files with 92 additions and 9 deletions

View File

@@ -179,12 +179,21 @@ func Register(c *gin.Context) {
}
}
// 超级管理员仅一个:第一个注册用户为超级管理员,后续均为普通用户
count, _ := coll.CountDocuments(ctx, bson.M{})
roleID := models.RoleIDUser
role := "user"
if count == 0 {
roleID = models.RoleIDSuperAdmin
role = "admin"
}
doc := bson.M{
"username": username,
"mobile": input.Mobile,
"password": utils.HashPassword(input.Password),
"role": "admin",
"role_id": models.RoleIDSuperAdmin,
"role": role,
"role_id": roleID,
}
if input.Email != "" {
doc["email"] = input.Email

View File

@@ -79,6 +79,7 @@ func main() {
}
r := gin.Default()
r.MaxMultipartMemory = 200 << 20 // 200MB与 Nginx client_max_body_size 一致,避免上传 413
r.Use(middleware.ErrorLogger())
// CORSALLOWED_ORIGINS 为空则允许所有来源;否则仅允许配置的域名)