feat: 文传易匿名临时文件传输站初始版本

- 后端 .NET 8 + FreeSql + 阿里云 OSS,支持共享/私密/标签三种文件模式
- 前端 Vue3 + Vite + TDesign,上传/取件/管理三页
- 取件码/二维码/海报合成(含保存二维码为图片)
- deploy/ 部署文档与一键 FTP 发布脚本
- appsettings.json 含真实凭据,已 gitignore 不入库
This commit is contained in:
2026-08-24 00:03:28 +08:00
commit 1bfc72f9cb
40 changed files with 6849 additions and 0 deletions
@@ -0,0 +1,92 @@
using Microsoft.AspNetCore.Mvc;
using WenChuanyi.Api.Dtos;
using WenChuanyi.Api.Models;
using WenChuanyi.Api.Services;
namespace WenChuanyi.Api.Controllers;
/// <summary>发送者管理:凭管理码查看文件列表 / 删除文件</summary>
[ApiController]
[Route("api/admin")]
public class AdminController : ControllerBase
{
private readonly IFreeSql _fsql;
private readonly OssStorageService _oss;
private readonly ILogger<AdminController> _logger;
public AdminController(IFreeSql fsql, OssStorageService oss, ILogger<AdminController> logger)
{
_fsql = fsql;
_oss = oss;
_logger = logger;
}
/// <summary>管理码查询文件列表(含上传 IP</summary>
[HttpGet("files/{adminCode}")]
public async Task<IActionResult> List(string adminCode)
{
if (string.IsNullOrEmpty(adminCode) || adminCode.Length != 8)
{
return BadRequest(new { message = "管理码无效" });
}
var list = await _fsql.Select<FileItem>()
.Where(f => f.AdminCode == adminCode)
.OrderByDescending(f => f.CreatedAt)
.ToListAsync();
return Ok(list.Select(ToDto));
}
/// <summary>删除指定文件(body 传 id 或取件码,校验管理码)</summary>
[HttpDelete("files/{adminCode}")]
public async Task<IActionResult> Delete(string adminCode, [FromBody] DeleteRequest? req)
{
if (string.IsNullOrEmpty(adminCode) || adminCode.Length != 8)
{
return BadRequest(new { message = "管理码无效" });
}
if (req == null || (req.Id == null && string.IsNullOrEmpty(req.PickCode)))
{
return BadRequest(new { message = "请提供要删除的文件 Id 或取件码" });
}
FileItem? item;
if (req.Id != null)
{
item = await _fsql.Select<FileItem>()
.Where(f => f.Id == req.Id.Value && f.AdminCode == adminCode).FirstAsync();
}
else
{
item = await _fsql.Select<FileItem>()
.Where(f => f.PickCode == req.PickCode && f.AdminCode == adminCode).FirstAsync();
}
if (item == null)
{
return NotFound(new { message = "文件不存在或管理码不匹配" });
}
var deleted = await _fsql.Delete<FileItem>().Where(f => f.Id == item.Id).ExecuteAffrowsAsync() > 0;
if (deleted)
{
_oss.TryDeleteObject(item.ObjectKey);
}
return Ok(new { message = "已删除" });
}
private static FileInfoDto ToDto(FileItem f) => new()
{
Id = f.Id,
PickCode = f.PickCode,
FileType = f.FileType,
HasPassword = f.FileType == "private",
OriginalName = f.OriginalName,
Size = f.Size,
MimeType = f.MimeType,
DownloadCount = f.DownloadCount,
UploadIp = f.UploadIp,
IsPermanent = f.IsPermanent,
ExpiresAt = f.ExpiresAt,
CreatedAt = f.CreatedAt,
ExpireText = FileRules.ExpireText(f)
};
}