相关bug调整

This commit is contained in:
fuenmao
2026-09-18 16:08:14 +08:00
parent ab0248d73d
commit fa48e73b84
4 changed files with 90 additions and 4 deletions
@@ -345,6 +345,8 @@ public class OnboardingEmployeeService : IOnboardingEmployeeService
.Where(item => item > 0)
.Distinct()
.ToList();
if (fileIds.Count > 10)
throw Oops.Bah("转正材料文件总数不能超过 10 份");
var files = fileIds.Count == 0
? new List<SysFile>()
: await _db.Queryable<SysFile>()
@@ -142,6 +142,24 @@ public class OnboardingEntryConfigService : IOnboardingEntryConfigService
throw Oops.Bah("资料名称不能为空");
if (input.MaxFileCount <= 0)
throw Oops.Bah("最大文件数量必须大于0");
if (input.MaxFileSizeMb.HasValue && (input.MaxFileSizeMb.Value <= 0 || input.MaxFileSizeMb.Value > 20))
throw Oops.Bah("单个文件大小必须设置在1至20MB之间");
var supportedExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"png", "jpg", "jpeg", "gif", "bmp", "webp", "pdf"
};
var allowedExtensions = (input.AllowedExtensions ?? string.Empty)
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Select(item => item.TrimStart('.').ToLowerInvariant())
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
if (allowedExtensions.Count == 0)
allowedExtensions.AddRange(new[] { "png", "jpg", "jpeg", "pdf" });
var unsupportedExtensions = allowedExtensions.Where(item => !supportedExtensions.Contains(item)).ToList();
if (unsupportedExtensions.Count > 0)
throw Oops.Bah($"不支持的材料扩展名:{string.Join("、", unsupportedExtensions)},仅允许图片或PDF文件");
input.AllowedExtensions = string.Join(",", allowedExtensions);
var materialCodeExists = await _db.Queryable<ObMaterialType>()
.AnyAsync(x => x.MaterialCode == input.MaterialCode && x.Id != input.Id);
@@ -5,6 +5,7 @@ namespace SimpleAdmin.Application;
/// </summary>
public class OnboardingPublicSubmissionService : IOnboardingPublicSubmissionService
{
private const int PublicMaterialMaxFileSizeMb = 20;
private readonly SqlSugarScope _db;
private readonly IOnboardingContractSnapshotService _snapshotService;
private readonly IOnboardingIdentityValidationService _identityValidationService;
@@ -233,10 +234,12 @@ public class OnboardingPublicSubmissionService : IOnboardingPublicSubmissionServ
if (suffixNotAllowed)
throw Oops.Bah("该材料不允许上传此文件类型");
var fileTooLarge = requirement.MaxFileSizeMb.HasValue
&& input.FileLength > requirement.MaxFileSizeMb.Value * 1024L * 1024L;
var maxFileSizeMb = requirement.MaxFileSizeMb.HasValue
? Math.Min(requirement.MaxFileSizeMb.Value, PublicMaterialMaxFileSizeMb)
: PublicMaterialMaxFileSizeMb;
var fileTooLarge = input.FileLength > maxFileSizeMb * 1024L * 1024L;
if (fileTooLarge)
throw Oops.Bah("文件超过允许的大小");
throw Oops.Bah($"单个文件不能超过{maxFileSizeMb}MB,请压缩后重新上传");
var materials = await _db.Queryable<ObTaskMaterial>()
.Where(item => item.TaskId == task.Id && item.MaterialTypeId == input.MaterialTypeId)