更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+1 -42
View File
@@ -19,12 +19,11 @@ import (
beego "github.com/beego/beego/v2/server/web"
)
// PlatformFileController 平台端文件管理(yz_system_files / yz_system_files_category)
type PlatformFileController struct {
beego.Controller
}
const platformFileUploadMaxMB = 2048 // 2GB,适用于大型软件安装包
const platformFileUploadMaxMB = 2048
const platformFileUploadMaxBytes = platformFileUploadMaxMB * 1024 * 1024
var platformFileTypeByCategory = map[string]uint8{
@@ -40,7 +39,6 @@ var platformAllowedExtByCategory = map[string][]string{
"document": {"pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt"},
"video": {"mp4", "webm", "mov"},
"audio": {"mp3", "wav", "ogg"},
// 安装包 / 软件升级(上传时 cate 选 appsupgrade 分类即可,扩展名在此放行)
"appsupgrade": {"zip", "exe", "dmg", "msi", "msix", "apk", "deb", "rpm", "7z", "tar", "gz", "pkg"},
}
@@ -133,7 +131,6 @@ func platformRemovePhysicalBySrc(webSrc string) {
_ = os.Remove(webSrc)
}
// GetAllFiles GET /platform/allfiles
func (c *PlatformFileController) GetAllFiles() {
claims, err := c.platformClaims()
if err != nil {
@@ -186,7 +183,6 @@ func (c *PlatformFileController) GetAllFiles() {
})
}
// GetUserCate GET /platform/usercate
func (c *PlatformFileController) GetUserCate() {
claims, err := c.platformClaims()
if err != nil {
@@ -228,7 +224,6 @@ type platformCreateCateBody struct {
Tuid *uint64 `json:"tuid"`
}
// CreateFileCate POST /platform/createfilecate
func (c *PlatformFileController) CreateFileCate() {
claims, err := c.platformClaims()
if err != nil {
@@ -276,24 +271,12 @@ type platformRenameCateBody struct {
Name string `json:"name"`
}
// protectedFileCateNames 受保护的文件分组名称(平台端)。
//
// 这些分组由功能模块按「名称」定位,删除或改名都会导致模块找不到分组:
// - 删除:素材被分散到未分类,且模块会重新补建一个空分组;
// - 改名:模块按名称找不到旧分组,会新建一个同名分组,历史文件被遗留在旧分组里。
// 因此统一禁止删除/重命名,需要调整时走 SQL 人工处理。
//
// 官网素材 官网管理(platform/src/views/website)所有上传的归属分组
// (见 platform/src/utils/websiteUpload.js)
// appsupgrade 软件升级安装包分组(见 platform/src/views/platform/softwareupgrade)
// 图片 平台预留的图片分组,作为官网/后台配图的固定归档位
var protectedFileCateNames = []string{
"官网素材",
"appsupgrade",
"图片",
}
// isProtectedFileCate 判断分组是否为受保护的系统默认分组
func isProtectedFileCate(name string) bool {
name = strings.TrimSpace(name)
for _, n := range protectedFileCateNames {
@@ -304,7 +287,6 @@ func isProtectedFileCate(name string) bool {
return false
}
// RenameFileCate POST /platform/renamefilecate/:id
func (c *PlatformFileController) RenameFileCate() {
claims, err := c.platformClaims()
if err != nil {
@@ -335,7 +317,6 @@ func (c *PlatformFileController) RenameFileCate() {
return
}
// 受保护分组禁止改名:功能模块按名称定位该分组
var existCate models.SystemFilesCategory
if err = models.Orm.QueryTable(new(models.SystemFilesCategory)).
Filter("id", id).
@@ -367,7 +348,6 @@ func (c *PlatformFileController) RenameFileCate() {
_ = c.ServeJSON()
}
// DeleteFileCate DELETE /platform/deletefilecate/:id
func (c *PlatformFileController) DeleteFileCate() {
claims, err := c.platformClaims()
if err != nil {
@@ -382,7 +362,6 @@ func (c *PlatformFileController) DeleteFileCate() {
c.jsonErr(400, 400, "无效的分组ID")
return
}
// 受保护分组禁止删除(先取出分组,便于给出明确提示)
var existCate models.SystemFilesCategory
if err = models.Orm.QueryTable(new(models.SystemFilesCategory)).
Filter("id", id).
@@ -428,7 +407,6 @@ func (c *PlatformFileController) DeleteFileCate() {
_ = c.ServeJSON()
}
// GetCateFiles GET /platform/catefiles/:id
func (c *PlatformFileController) GetCateFiles() {
claims, err := c.platformClaims()
if err != nil {
@@ -485,7 +463,6 @@ func (c *PlatformFileController) GetCateFiles() {
})
}
// GetFileByID GET /platform/file/:id
func (c *PlatformFileController) GetFileByID() {
claims, err := c.platformClaims()
if err != nil {
@@ -513,7 +490,6 @@ func (c *PlatformFileController) GetFileByID() {
c.jsonOK(platformFileToMap(&f))
}
// UploadFile POST /platform/uploadfile
func (c *PlatformFileController) UploadFile() {
claims, err := c.platformClaims()
if err != nil {
@@ -545,14 +521,12 @@ func (c *PlatformFileController) UploadFile() {
return
}
// 获取存储服务
storageService, err := services.GetStorageService()
if err != nil {
c.jsonErr(500, 500, "获取存储服务失败: "+err.Error())
return
}
// 1. 先写入临时文件并计算 MD5(此时文件尚未进入正式目录)
staged, err := storageService.Stage(fh, header)
if err != nil {
c.jsonErr(500, 500, "读取上传文件失败: "+err.Error())
@@ -565,11 +539,9 @@ func (c *PlatformFileController) UploadFile() {
}
}()
// 平台端不做租户/用户分层,统一 platform/yyyy/MM/dd/
ctx := services.UploadContext{Source: services.SourcePlatform, Tid: tid}
scope := ctx.Scope()
// 2. 精确查重(平台端按 tid + MD5)
exist, err := services.FindDuplicate(services.SourcePlatform, scope, tid, 0, staged.MD5)
if err != nil {
c.jsonErr(500, 500, "查重失败: "+err.Error())
@@ -589,7 +561,6 @@ func (c *PlatformFileController) UploadFile() {
return
}
// 3. 提交到正式目录
result, err := storageService.Commit(staged, ctx)
if err != nil {
c.jsonErr(500, 500, "上传文件失败: "+err.Error())
@@ -597,14 +568,12 @@ func (c *PlatformFileController) UploadFile() {
}
committed = true
// 获取分类
cateStr := c.GetString("cate")
var cate uint64
if cateStr != "" {
cate, _ = strconv.ParseUint(cateStr, 10, 64)
}
// 4. 保存文件记录到数据库
id, err := services.CreateFileRecord(services.FileUploadParams{
Source: services.SourcePlatform,
Scope: scope,
@@ -655,7 +624,6 @@ type platformUpdateFileBody struct {
Cate *uint64 `json:"cate"`
}
// UpdateFile POST /platform/updatefile/:id
func (c *PlatformFileController) UpdateFile() {
claims, err := c.platformClaims()
if err != nil {
@@ -710,7 +678,6 @@ func (c *PlatformFileController) UpdateFile() {
_ = c.ServeJSON()
}
// DeleteFile DELETE /platform/deletefile/:id
func (c *PlatformFileController) DeleteFile() {
claims, err := c.platformClaims()
if err != nil {
@@ -743,7 +710,6 @@ func (c *PlatformFileController) DeleteFile() {
_ = c.ServeJSON()
}
// DeleteFilePermanently DELETE /platform/deletefilepermanently/:id
func (c *PlatformFileController) DeleteFilePermanently() {
claims, err := c.platformClaims()
if err != nil {
@@ -782,7 +748,6 @@ func (c *PlatformFileController) DeleteFilePermanently() {
_ = c.ServeJSON()
}
// MoveFile GET /platform/movefile/:id
func (c *PlatformFileController) MoveFile() {
claims, err := c.platformClaims()
if err != nil {
@@ -821,7 +786,6 @@ type platformIdsBody struct {
Cate *uint64 `json:"cate"`
}
// BatchDeleteFiles POST /platform/batchdeletefiles
func (c *PlatformFileController) BatchDeleteFiles() {
claims, err := c.platformClaims()
if err != nil {
@@ -844,7 +808,6 @@ func (c *PlatformFileController) BatchDeleteFiles() {
c.jsonErr(400, 400, "请选择要删除的文件")
return
}
// 软删除:只标记 delete_time,不删除物理文件(彻底删除接口才会删)
now := time.Now()
n, err := models.Orm.QueryTable(new(models.SystemFile)).
Filter("id__in", body.IDs).
@@ -862,7 +825,6 @@ func (c *PlatformFileController) BatchDeleteFiles() {
_ = c.ServeJSON()
}
// BatchDeleteFilesPermanently POST /platform/batchDeleteFilesPermanently
func (c *PlatformFileController) BatchDeleteFilesPermanently() {
claims, err := c.platformClaims()
if err != nil {
@@ -915,19 +877,16 @@ func (c *PlatformFileController) BatchDeleteFilesPermanently() {
_ = c.ServeJSON()
}
// UploadAvatar POST /platform/uploadavatar(占位)
func (c *PlatformFileController) UploadAvatar() {
c.Data["json"] = map[string]interface{}{"code": 501, "msg": "上传头像暂未实现"}
_ = c.ServeJSON()
}
// UpdateAvatar POST /platform/uploadavatar/:id(占位)
func (c *PlatformFileController) UpdateAvatar() {
c.Data["json"] = map[string]interface{}{"code": 501, "msg": "更新头像暂未实现"}
_ = c.ServeJSON()
}
// BatchMoveFiles POST /platform/batchMoveFiles
func (c *PlatformFileController) BatchMoveFiles() {
claims, err := c.platformClaims()
if err != nil {