课件附件 打包下载 压缩包名称 会跟着附件修改后名称来 而非初始上传名称

master
xiaochanghai 8 months ago
parent 5e83a54257
commit bf762037b5
  1. 3
      Tiobon.Core.Model/Base/Ghrh/Ghrh_ResumeHome.Dto.Base.cs
  2. 5
      Tiobon.Core.Model/Models/Ghrh/Ghrh_ResumeHome.cs
  3. 33
      Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs

@ -64,7 +64,8 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 性别
/// </summary>
public int? Gender { get; set; }
[Display(Name = "Telephone"), Description("性别"), MaxLength(32, ErrorMessage = "性别 不能超过 32 个字符")]
public string Gender { get; set; }
/// <summary>
/// 身份证号码

@ -13,7 +13,7 @@
*  
* SimonHsiao
*
*/
*/
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SqlSugar;
@ -66,7 +66,8 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 性别
/// </summary>
public int? Gender { get; set; }
[Display(Name = "Telephone"), Description("性别"), MaxLength(32, ErrorMessage = "性别 不能超过 32 个字符")]
public string Gender { get; set; }
/// <summary>
/// 身份证号码

@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq;
using SqlSugar;
using Tiobon.Core.Common;
using Tiobon.Core.Common.Caches;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.IServices;
using Tiobon.Core.Model;
@ -48,7 +49,11 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course
entity.CourseNames = string.Join(",", courses.Select(x => x.CourseName));
}
var result = await base.Add(entity);
entity.Attachments.ForEach(x => x.CourseWareId = result);
entity.Attachments.ForEach(x =>
{
x.CourseWareId = result;
x.RelativePath = x.RelativePath.Replace("/Advanced", null);
});
await _ghre_CourseWareAttachmentServices.Add(entity.Attachments);
return result;
}
@ -63,7 +68,11 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course
}
await _ghre_CourseWareAttachmentServices.Delete(x => x.CourseWareId == Id);
editModel.Attachments.ForEach(x => x.CourseWareId = Id);
editModel.Attachments.ForEach(x =>
{
x.CourseWareId = Id;
x.RelativePath = x.RelativePath.Replace("/Advanced", null);
});
await _ghre_CourseWareAttachmentServices.Add(editModel.Attachments);
@ -86,6 +95,10 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course
else result.result.DT_TableDataT1[0].CourseIds2 = new List<long>();
result.result.DT_TableDataT1[0].Attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == body.id);
if (result.result.DT_TableDataT1[0].Attachments.Any())
{
result.result.DT_TableDataT1[0].Attachments.ForEach(x => x.RelativePath = "/Advanced" + x.RelativePath);
}
var IDS = result.result.DT_TableDataT1[0].CourseIds2;
result.result.DT_TableDataT1[0].Courses = await _ghre_CourseServices.Query(x => IDS.Contains(x.Id));
@ -202,13 +215,23 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course
var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == id);
var webRootPath = _hostingEnvironment.WebRootPath;
var outPath = $"/files/upload/{result.CourseWareName}_{result.VersionNo}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
var files = attachments.Select(x => $"{webRootPath}{"\\" + x.RelativePath}").ToArray();
if (files.Length > 0)
if (attachments.Any())
{
var newFilePath = $"{webRootPath}/files/upload/{SnowFlakeSingle.Instance.NextId()}";
Directory.CreateDirectory(newFilePath);
attachments.ForEach(x =>
{
if (File.Exists($"{webRootPath}{"\\" + x.RelativePath}"))
FileHelper.FileCoppy($"{webRootPath}{"\\" + x.RelativePath}", $"{newFilePath}/{x.AttachmentName}");
});
var files = attachments.Select(x => $"{newFilePath}{"\\" + x.AttachmentName}").ToArray();
if (files.Length > 1)
CreateZip($"{webRootPath}{outPath}", files);
else
outPath = attachments[0].RelativePath;
outPath = newFilePath + "/" + attachments[0].AttachmentName;
return ServiceResult<string>.OprateSuccess(null, "/Advanced" + outPath);
}
else

Loading…
Cancel
Save