|
@@ -28,6 +28,16 @@ using ZhonTai.Admin.Services.Pkg;
|
|
|
using ZhonTai.Admin.Domain.ProjectLink;
|
|
|
using ZhonTai.Admin.Domain.Dict;
|
|
|
using ZhonTai.Common.Extensions;
|
|
|
+using Microsoft.AspNetCore.Hosting;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
+using System.Data;
|
|
|
+using System.IO;
|
|
|
+using ZhonTai.Admin.Core.Helpers;
|
|
|
+using ZhonTai.Admin.Repositories.ProjectLink;
|
|
|
+using ZhonTai.Common.Files;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using ZhonTai.Admin.Core.Configs;
|
|
|
|
|
|
namespace ZhonTai.Admin.Services.Project
|
|
|
{
|
|
@@ -43,6 +53,8 @@ namespace ZhonTai.Admin.Services.Project
|
|
|
private readonly IProjectRecordRepository _projectRecordRepository;
|
|
|
private readonly IProjectLinkRepository _projectLinkRepository;
|
|
|
private readonly IDictRepository _dictRepository;
|
|
|
+ private OSSConfig _oSSConfig => LazyGetRequiredService<IOptions<OSSConfig>>().Value;
|
|
|
+ private IHttpContextAccessor _httpContextAccessor => LazyGetRequiredService<IHttpContextAccessor>();
|
|
|
|
|
|
public ProjectService(IProjectRepository projectRepository, IProjectPriceRepository projectPriceRepository, IProjectRecordRepository projectRecordRepository, IProjectLinkRepository projectLinkRepository, IDictRepository dictRepository)
|
|
|
{
|
|
@@ -280,6 +292,98 @@ namespace ZhonTai.Admin.Services.Project
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ ///// <summary>
|
|
|
+ ///// 上传视频文件
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="file">文件</param>
|
|
|
+ ///// <param name="ProjectId">文件目录</param>
|
|
|
+ ///// <param name="Company">文件重命名</param>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //public async Task UploadVideoAsync([Required] IFormFile file, [Required] long ProjectId, [Required] string Company)
|
|
|
+ //{
|
|
|
+ // var localUploadConfig = _oSSConfig.LocalUploadConfig;
|
|
|
+
|
|
|
+ // var extention = Path.GetExtension(file.FileName).ToLower();
|
|
|
+ // if (extention != ".xlsx")
|
|
|
+ // {
|
|
|
+ // throw new Exception($"请上传excel格式文件");
|
|
|
+ // }
|
|
|
+ // var fileLenth = file.Length;
|
|
|
+ // if (fileLenth <= 0)
|
|
|
+ // {
|
|
|
+ // throw new Exception("文件不能为空");
|
|
|
+ // }
|
|
|
+ // if (fileLenth > localUploadConfig.MaxSize)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"文件大小不能超过{new FileSize(localUploadConfig.MaxSize)}");
|
|
|
+ // }
|
|
|
+ // if (ProjectId <= 0)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"请输入有效项目Id");
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // string fileDirectory = "link";
|
|
|
+
|
|
|
+ // string SaveFileName = FreeUtil.NewMongodbId().ToString();
|
|
|
+
|
|
|
+ // var filePath = Path.Combine(fileDirectory, SaveFileName + extention).ToPath();
|
|
|
+
|
|
|
+ // var uploadHelper = LazyGetRequiredService<UploadHelper>();
|
|
|
+ // var env = LazyGetRequiredService<IWebHostEnvironment>();
|
|
|
+ // fileDirectory = Path.Combine(env.WebRootPath, fileDirectory).ToPath();
|
|
|
+ // if (!Directory.Exists(fileDirectory))
|
|
|
+ // {
|
|
|
+ // Directory.CreateDirectory(fileDirectory);
|
|
|
+ // }
|
|
|
+ // filePath = Path.Combine(env.WebRootPath, filePath).ToPath();
|
|
|
+ // await uploadHelper.SaveAsync(file, filePath);
|
|
|
+
|
|
|
+ // //导入数据
|
|
|
+ // var datatable = NOPIHelper.ReadExcel(filePath);
|
|
|
+ // if (datatable == null || datatable.Rows.Count <= 0)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"文件不能为空");
|
|
|
+ // }
|
|
|
+ // if (datatable.Columns["编号"] == null || datatable.Columns["口令"] == null || datatable.Columns["短链"] == null || datatable.Columns["二维码"] == null || datatable.Columns["查单链接"] == null)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"导入格式不正确");
|
|
|
+ // }
|
|
|
+ // var projectAny = await _projectRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.Id == ProjectId).AnyAsync();
|
|
|
+ // if (!projectAny)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"项目不存在");
|
|
|
+ // }
|
|
|
+ // var ListCompany = _ProjectLinkRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == ProjectId)
|
|
|
+ // .GroupBy(m => m.Company).Select(m => m.Key).ToList();
|
|
|
+ // if (ListCompany.Count > 0 && !ListCompany.Contains(Company))
|
|
|
+ // {
|
|
|
+ // throw new Exception($"一个项目只能上传一个推广码来源");
|
|
|
+ // }
|
|
|
+ // List<string> listNum = (from d in datatable.AsEnumerable() select d.Field<string>("编号")).ToList();
|
|
|
+ // var count = await _ProjectLinkRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => m.ProjectId == ProjectId && m.Company == Company && listNum.Contains(m.Num)).CountAsync();
|
|
|
+ // if (count > 0)
|
|
|
+ // {
|
|
|
+ // throw new Exception($"编码重复");
|
|
|
+ // }
|
|
|
+ // List<ProjectLinkEntity> list = new List<ProjectLinkEntity>();
|
|
|
+ // foreach (DataRow row in datatable.Rows)
|
|
|
+ // {
|
|
|
+ // list.Add(new ProjectLinkEntity()
|
|
|
+ // {
|
|
|
+ // Num = row["编号"]?.ToString(),
|
|
|
+ // ShareCommand = row["口令"]?.ToString(),
|
|
|
+ // ShortUrl = row["短链"]?.ToString(),
|
|
|
+ // QrcodeUrl = row["二维码"]?.ToString(),
|
|
|
+ // QueryUrl = row["查单链接"]?.ToString(),
|
|
|
+ // ProjectId = ProjectId,
|
|
|
+ // Company = Company,
|
|
|
+ // TenantId = -1
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // await _ProjectLinkRepository.InsertAsync(list);
|
|
|
+ //}
|
|
|
+
|
|
|
#region 私有方法
|
|
|
/// <summary>
|
|
|
/// 获取项目状态
|