diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs
index d77417546..e3daff5ce 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Platform.Versions
{
@@ -7,20 +7,27 @@ namespace LINGYUN.Platform.Versions
///
/// 标题
///
+ [Required]
+ [StringLength(AppVersionConsts.MaxTitleLength)]
public string Title { get; set; }
///
/// 版本号
///
+ [Required]
+ [StringLength(AppVersionConsts.MaxVersionLength)]
public string Version { get; set; }
///
/// 描述
///
+ [StringLength(AppVersionConsts.MaxDescriptionLength)]
public string Description { get; set; }
///
+ /// 适应平台
+ ///
+ public PlatformType PlatformType { get; set; } = PlatformType.None;
+ ///
/// 重要级别
///
public ImportantLevel Level { get; set; } = ImportantLevel.Low;
-
- public List VersionFiles { get; set; } = new List();
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs
index 7d3f707bb..6385684f2 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs
@@ -1,7 +1,13 @@
-namespace LINGYUN.Platform.Versions
+using System.ComponentModel.DataAnnotations;
+
+namespace LINGYUN.Platform.Versions
{
public class VersionDeleteDto
{
+ [Required]
+ [StringLength(AppVersionConsts.MaxVersionLength)]
public string Version { get; set; }
+
+ public PlatformType PlatformType { get; set; }
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs
index 2b95f1925..cc9bdb714 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs
@@ -10,8 +10,14 @@ namespace LINGYUN.Platform.Versions
public Guid VersionId { get; set; }
[Required]
+ [StringLength(AppVersionConsts.MaxVersionLength)]
public string Version { get; set; }
///
+ /// 文件路径
+ ///
+ [StringLength(VersionFileConsts.MaxPathLength)]
+ public string FilePath { get; set; }
+ ///
/// 文件名称
///
[Required]
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs
index afa3cfd10..9d6ed39f9 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs
@@ -1,10 +1,15 @@
using System;
+using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Platform.Versions
{
public class VersionFileDeleteDto
{
+ [Required]
public Guid VersionId { get; set; }
+
+ [Required]
+ [StringLength(VersionFileConsts.MaxNameLength)]
public string FileName { get; set; }
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs
index 85330f3d5..35a57ffb5 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs
@@ -1,11 +1,24 @@
-using System;
+using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Platform.Versions
{
public class VersionFileGetDto
{
+ public PlatformType PlatformType { get; set; } = PlatformType.None;
+
+ [Required]
+ [StringLength(AppVersionConsts.MaxVersionLength)]
public string Version { get; set; }
+
+ [StringLength(VersionFileConsts.MaxPathLength)]
+ public string FilePath { get; set; }
+
+ [Required]
+ [StringLength(VersionFileConsts.MaxNameLength)]
public string FileName { get; set; }
+
+ [Required]
+ [StringLength(VersionFileConsts.MaxVersionLength)]
public string FileVersion { get; set; }
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs
index bacfcb1ad..affb65e1a 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs
@@ -5,5 +5,6 @@ namespace LINGYUN.Platform.Versions
public class VersionGetByPagedDto : PagedAndSortedResultRequestDto
{
public string Filter { get; set; }
+ public PlatformType PlatformType { get; set; } = PlatformType.None;
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs
index 65365d3d7..7b6f066cb 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs
@@ -6,7 +6,7 @@ namespace LINGYUN.Platform.Versions
{
public interface IVersionAppService : IApplicationService
{
- Task GetLastestAsync();
+ Task GetLastestAsync(PlatformType platformType);
Task> GetAsync(VersionGetByPagedDto versionGetByPaged);
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs
index a40ce7c6f..5c8834390 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs
@@ -18,17 +18,17 @@ namespace LINGYUN.Platform.Versions
{
await _versionManager.AppendFileAsync(versionFileCreate.VersionId,
versionFileCreate.SHA256, versionFileCreate.FileName, versionFileCreate.FileVersion,
- versionFileCreate.TotalByte, versionFileCreate.FileType);
+ versionFileCreate.TotalByte, versionFileCreate.FilePath, versionFileCreate.FileType);
}
public virtual async Task CreateAsync(VersionCreateDto versionCreate)
{
- if (await _versionManager.ExistsAsync(versionCreate.Version))
+ if (await _versionManager.ExistsAsync(versionCreate.PlatformType,versionCreate.Version))
{
throw new UserFriendlyException("VersionAlreadyExists");
}
var version = new AppVersion(GuidGenerator.Create(), versionCreate.Title,
- versionCreate.Version, CurrentTenant.Id)
+ versionCreate.Version, versionCreate.PlatformType, CurrentTenant.Id)
{
Description = versionCreate.Description,
Level = versionCreate.Level
@@ -41,7 +41,7 @@ namespace LINGYUN.Platform.Versions
public virtual async Task DeleteAsync(VersionDeleteDto versionDelete)
{
- var version = await _versionManager.GetByVersionAsync(versionDelete.Version);
+ var version = await _versionManager.GetByVersionAsync(versionDelete.PlatformType, versionDelete.Version);
if (version != null)
{
await _versionManager.DeleteAsync(version.Id);
@@ -50,8 +50,8 @@ namespace LINGYUN.Platform.Versions
public virtual async Task> GetAsync(VersionGetByPagedDto versionGetByPaged)
{
- var versionCount = await _versionManager.GetCountAsync(versionGetByPaged.Filter);
- var versions = await _versionManager.GetPagedListAsync(versionGetByPaged.Filter,
+ var versionCount = await _versionManager.GetCountAsync(versionGetByPaged.PlatformType, versionGetByPaged.Filter);
+ var versions = await _versionManager.GetPagedListAsync(versionGetByPaged.PlatformType, versionGetByPaged.Filter,
versionGetByPaged.Sorting, true,
versionGetByPaged.SkipCount, versionGetByPaged.MaxResultCount);
@@ -66,9 +66,9 @@ namespace LINGYUN.Platform.Versions
return ObjectMapper.Map(version);
}
- public virtual async Task GetLastestAsync()
+ public virtual async Task GetLastestAsync(PlatformType platformType)
{
- var version = await _versionManager.GetLatestAsync();
+ var version = await _versionManager.GetLatestAsync(platformType);
return ObjectMapper.Map(version);
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs
index 3869af371..1fe59078c 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs
@@ -39,7 +39,7 @@ namespace LINGYUN.Platform
///
/// Web通用
///
- Web = WebForm | WebMvc,
+ Web = WebForm | WebMvc | WebMvvm,
///
/// Android
///
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs
index 5a98a5ffb..ce3490eca 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs
@@ -5,7 +5,7 @@ namespace LINGYUN.Platform.Versions
{
public interface IVersionFileManager
{
- Task AppendFileAsync(string version, string fileName, string fileVersion, byte[] data);
- Task GetFileAsync(string version, string fileName, string fileVersion);
+ Task SaveFileAsync(string version, string filePath, string fileName, string fileVersion, byte[] data);
+ Task DownloadFileAsync(PlatformType platformType, string version, string filePath, string fileName, string fileVersion);
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs
index 3ba0274fa..13cdf3528 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs
@@ -1,13 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace LINGYUN.Platform.Versions
+namespace LINGYUN.Platform.Versions
{
public static class VersionFileConsts
{
public const int MaxNameLength = 255;
+ public const int MaxPathLength = 255;
+
public const int MaxVersionLength = 20;
public const int MaxSHA256Length = 65;
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs
index f17173709..2c7477578 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs
@@ -32,6 +32,10 @@ namespace LINGYUN.Platform.Versions
///
public virtual ImportantLevel Level { get; set; }
///
+ /// 适应平台
+ ///
+ public virtual PlatformType PlatformType { get; protected set; }
+ ///
/// 版本文件列表
///
public virtual ICollection Files { get; protected set; }
@@ -41,20 +45,26 @@ namespace LINGYUN.Platform.Versions
Files = new List();
}
- public AppVersion(Guid id, string title, string version, Guid? tenantId = null)
+ public AppVersion(Guid id, string title, string version, PlatformType platformType = PlatformType.None, Guid? tenantId = null)
{
Id = id;
Title = title;
Version = version;
TenantId = tenantId;
+ PlatformType = platformType;
Level = ImportantLevel.Low;
}
- public void AppendFile(string name, string version, long size, string sha256, FileType fileType = FileType.Stream)
+ public void AppendFile(string name, string version, long size, string sha256,
+ string filePath = "", FileType fileType = FileType.Stream)
{
if (!FileExists(name))
{
- Files.Add(new VersionFile(name, version, size, sha256, fileType, TenantId));
+ var versionFile = new VersionFile(name, version, size, sha256, fileType, TenantId)
+ {
+ Path = filePath
+ };
+ Files.Add(versionFile);
}
}
@@ -82,6 +92,18 @@ namespace LINGYUN.Platform.Versions
return Files.Where(x => x.Name.Equals(name)).FirstOrDefault();
}
+ public VersionFile FindFile(string path, string name)
+ {
+ return Files.Where(x => x.Path.Equals(path) && x.Name.Equals(name)).FirstOrDefault();
+ }
+
+ public VersionFile FindFile(string path, string name, string version)
+ {
+ return Files.Where(x => x.Path.Equals(path) && x.Name.Equals(name) && x.Version.Equals(version))
+ .FirstOrDefault();
+ }
+
+
public bool FileExists(string name)
{
// TODO: Windows file system ?
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs
index 3375f00a1..19c847bbf 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs
@@ -8,14 +8,14 @@ namespace LINGYUN.Platform.Versions
{
public interface IVersionRepository : IBasicRepository
{
- Task ExistsAsync(string version, CancellationToken cancellationToken = default);
+ Task ExistsAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default);
- Task GetByVersionAsync(string version, CancellationToken cancellationToken = default);
+ Task GetByVersionAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default);
- Task GetCountAsync(string filter = "", CancellationToken cancellationToken = default);
+ Task GetCountAsync(PlatformType platformType, string filter = "", CancellationToken cancellationToken = default);
- Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default);
+ Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default);
- Task GetLatestVersionAsync(CancellationToken cancellationToken = default);
+ Task GetLatestVersionAsync(PlatformType platformType, CancellationToken cancellationToken = default);
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs
index e6ce01db7..4b4d8d857 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs
@@ -14,6 +14,10 @@ namespace LINGYUN.Platform.Versions
///
public virtual Guid? TenantId { get; protected set; }
///
+ /// 文件路径
+ ///
+ public virtual string Path { get; set; }
+ ///
/// 文件名称
///
public virtual string Name { get; protected set; }
@@ -71,7 +75,8 @@ namespace LINGYUN.Platform.Versions
DownloadCount += 1;
}
- public static string NormalizeBlobName(string appVersion, string fileName, string fileVersion)
+ public static string NormalizeBlobName(string appVersion, string fileName, string fileVersion,
+ string filePath = "")
{
var fileNameWithNotExten = fileName;
// 取出文件扩展名
@@ -85,6 +90,12 @@ namespace LINGYUN.Platform.Versions
}
// 转换不受支持的符号
fileNameWithNotExten = fileNameWithNotExten.Replace(".", "-");
+
+ //路径存储模式 如果传递了绝对路径,需要计算短路径
+ if (!filePath.IsNullOrWhiteSpace())
+ {
+ return $"{appVersion}/{filePath.GetHash()}/{fileNameWithNotExten}/{fileVersion}/{fileName}";
+ }
// 最终文件名为 应用版本号/文件名(不带扩展名)/文件版本/文件名
// 例: 1.0.0.0/test-upload-text-file/1.0.0.0/test-upload-text-file.text
return $"{appVersion}/{fileNameWithNotExten}/{fileVersion}/{fileName}";
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs
index 9f8ee1ada..a20390062 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs
@@ -25,9 +25,9 @@ namespace LINGYUN.Platform.Versions
VersionRepository = versionRepository;
}
- public virtual async Task ExistsAsync(string version)
+ public virtual async Task ExistsAsync(PlatformType platformType, string version)
{
- return await VersionRepository.ExistsAsync(version);
+ return await VersionRepository.ExistsAsync(platformType, version);
}
public virtual async Task GetByIdAsync(Guid id)
@@ -35,19 +35,19 @@ namespace LINGYUN.Platform.Versions
return await VersionRepository.GetAsync(id);
}
- public virtual async Task GetByVersionAsync(string version)
+ public virtual async Task GetByVersionAsync(PlatformType platformType, string version)
{
- return await VersionRepository.GetByVersionAsync(version);
+ return await VersionRepository.GetByVersionAsync(platformType, version);
}
- public virtual async Task GetCountAsync(string filter)
+ public virtual async Task GetCountAsync(PlatformType platformType, string filter)
{
- return await VersionRepository.GetCountAsync(filter);
+ return await VersionRepository.GetCountAsync(platformType, filter);
}
- public virtual async Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10)
+ public virtual async Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10)
{
- return await VersionRepository.GetPagedListAsync(filter, soring, includeDetails, skipCount, maxResultCount);
+ return await VersionRepository.GetPagedListAsync(platformType, filter, soring, includeDetails, skipCount, maxResultCount);
}
[UnitOfWork]
@@ -70,22 +70,26 @@ namespace LINGYUN.Platform.Versions
await VersionRepository.DeleteAsync(id);
}
- public virtual async Task GetLatestAsync()
+ public virtual async Task GetLatestAsync(PlatformType platformType)
{
- return await VersionRepository.GetLatestVersionAsync();
+ return await VersionRepository.GetLatestVersionAsync(platformType);
}
- public virtual async Task GetFileAsync(string version, string fileName, string fileVersion)
+ public virtual async Task DownloadFileAsync(PlatformType platformType, string version, string filePath, string fileName, string fileVersion)
{
+ var appVersion = await GetByVersionAsync(platformType, version);
+ var versionFile = appVersion.FindFile(filePath, fileName, fileVersion);
+ versionFile.Download();
return await VersionBlobContainer.GetAsync(
- VersionFile.NormalizeBlobName(version, fileName, fileVersion));
+ VersionFile.NormalizeBlobName(version, versionFile.Name, versionFile.Version, versionFile.Path));
}
public virtual async Task GetFileAsync(VersionFile versionFile)
{
- return await GetFileAsync(versionFile.AppVersion.Version, versionFile.Name, versionFile.Version);
+ return await DownloadFileAsync(versionFile.AppVersion.PlatformType, versionFile.AppVersion.Version, versionFile.Path,
+ versionFile.Name, versionFile.Version);
}
- public virtual async Task AppendFileAsync(string version, string fileName, string fileVersion, byte[] data)
+ public virtual async Task SaveFileAsync(string version, string filePath, string fileName, string fileVersion, byte[] data)
{
// 计算指纹
var sha256 = new SHA256Managed();
@@ -93,21 +97,23 @@ namespace LINGYUN.Platform.Versions
var sha256Hash = BitConverter.ToString(checkHash).Replace("-", string.Empty);
await VersionBlobContainer
- .SaveAsync(VersionFile.NormalizeBlobName(version, fileName, fileVersion), data, true);
+ .SaveAsync(VersionFile.NormalizeBlobName(version, fileName, fileVersion, filePath), data, true);
return sha256Hash;
}
[UnitOfWork]
public virtual async Task AppendFileAsync(Guid versionId, string fileSha256,
- string fileName, string fileVersion, long fileSize, FileType fileType = FileType.Stream)
+ string fileName, string fileVersion,
+ long fileSize, string filePath = "",
+ FileType fileType = FileType.Stream)
{
var appVersion = await VersionRepository.GetAsync(versionId);
if (appVersion.FileExists(fileName))
{
appVersion.RemoveFile(fileName);
}
- appVersion.AppendFile(fileName, fileVersion, fileSize, fileSha256, fileType);
+ appVersion.AppendFile(fileName, fileVersion, fileSize, fileSha256, filePath, fileType);
}
[UnitOfWork]
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/StringExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/StringExtensions.cs
new file mode 100644
index 000000000..f2118e789
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/StringExtensions.cs
@@ -0,0 +1,17 @@
+using System.Security.Cryptography;
+using System.Text;
+
+namespace System
+{
+ public static class StringExtensions
+ {
+ public static string GetHash(this string str)
+ {
+ using (var sha = new SHA1Managed())
+ {
+ var hashBytes = sha.ComputeHash(Encoding.UTF8.GetBytes(str));
+ return BitConverter.ToString(hashBytes).Replace("-", string.Empty);
+ }
+ }
+ }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs
index 66254f6de..9d01958d9 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs
@@ -128,10 +128,15 @@ namespace LINGYUN.Platform.EntityFrameworkCore
.HasColumnName(nameof(VersionFile.Version))
.HasMaxLength(VersionFileConsts.MaxVersionLength);
+ x.Property(p => p.Path)
+ .HasColumnName(nameof(VersionFile.Path))
+ .HasMaxLength(VersionFileConsts.MaxPathLength);
+
x.ConfigureAudited();
x.ConfigureMultiTenant();
- x.HasIndex(i => new { i.Name, i.Version });
+ x.HasIndex(i => new { i.Path, i.Name, i.Version }).IsUnique();
+
});
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs
index b6f730ac4..d12b5ec0a 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs
@@ -20,17 +20,19 @@ namespace LINGYUN.Platform.Versions
{
}
- public virtual async Task GetCountAsync(string filter = "", CancellationToken cancellationToken = default)
+ public virtual async Task GetCountAsync(PlatformType platformType, string filter = "", CancellationToken cancellationToken = default)
{
return await DbSet
+ .Where(x => (platformType | x.PlatformType) == x.PlatformType)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
- public virtual async Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default)
+ public virtual async Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeIf(includeDetails, x => x.Files)
+ .Where(x => (platformType | x.PlatformType) == x.PlatformType)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter))
.OrderBy(soring ?? "") // TODO: 排序待优化
.Page(skipCount, maxResultCount)
@@ -38,24 +40,25 @@ namespace LINGYUN.Platform.Versions
}
- public virtual async Task ExistsAsync(string version, CancellationToken cancellationToken = default)
+ public virtual async Task ExistsAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default)
{
return await DbSet
- .AnyAsync(x => x.Version.Equals(version), GetCancellationToken(cancellationToken));
+ .AnyAsync(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version), GetCancellationToken(cancellationToken));
}
- public virtual async Task GetByVersionAsync(string version, CancellationToken cancellationToken = default)
+ public virtual async Task GetByVersionAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default)
{
return await DbSet
.Include(x => x.Files)
- .Where(x => x.Version.Equals(version))
+ .Where(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version))
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
- public virtual async Task GetLatestVersionAsync(CancellationToken cancellationToken = default)
+ public virtual async Task GetLatestVersionAsync(PlatformType platformType, CancellationToken cancellationToken = default)
{
return await DbSet
.Include(x => x.Files)
+ .Where(x => (platformType | x.PlatformType) == x.PlatformType)
.OrderByDescending(x => x.CreationTime)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs
index 642207454..c02899904 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using System;
+using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -15,7 +16,7 @@ namespace LINGYUN.Platform.Versions
{
[Area("platform")]
[Route("api/platform/version")]
- public class VersionController : PlatformControllerBase
+ public class VersionController : PlatformControllerBase, IVersionAppService
{
private readonly IVersionFileManager _versionFileManager;
private readonly IVersionAppService _versionAppService;
@@ -102,8 +103,8 @@ namespace LINGYUN.Platform.Versions
}
// 上传最终合并的文件并取得SHA256指纹
var fileData = await mergeSavedFileStream.GetAllBytesAsync();
- versionFileCreate.SHA256 = await _versionFileManager.AppendFileAsync(versionFileCreate.Version,
- versionFileCreate.FileName, versionFileCreate.FileVersion, fileData);
+ versionFileCreate.SHA256 = await _versionFileManager.SaveFileAsync(versionFileCreate.Version,
+ versionFileCreate.FilePath, versionFileCreate.FileName, versionFileCreate.FileVersion, fileData);
}
// 添加到版本信息
await _versionAppService.AppendFileAsync(versionFileCreate);
@@ -146,9 +147,9 @@ namespace LINGYUN.Platform.Versions
[HttpGet]
[Route("lastest")]
- public virtual async Task GetLastestAsync()
+ public virtual async Task GetLastestAsync([Required] PlatformType platformType)
{
- return await _versionAppService.GetLastestAsync();
+ return await _versionAppService.GetLastestAsync(platformType);
}
[HttpDelete]
@@ -172,8 +173,9 @@ namespace LINGYUN.Platform.Versions
// 分块模式下载文件
// 得到文件流
- var fileStream = await _versionFileManager.GetFileAsync(
- versionFileGet.Version, versionFileGet.FileName, versionFileGet.FileVersion);
+ var fileStream = await _versionFileManager.DownloadFileAsync(
+ versionFileGet.PlatformType, versionFileGet.Version, versionFileGet.FilePath,
+ versionFileGet.FileName, versionFileGet.FileVersion);
// 得到文件扩展名
var fileExt = Path.GetExtension(versionFileGet.FileName);
var provider = new FileExtensionContentTypeProvider();
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.Designer.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.Designer.cs
new file mode 100644
index 000000000..9f980379f
--- /dev/null
+++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.Designer.cs
@@ -0,0 +1,406 @@
+//
+using System;
+using LINGYUN.Platform.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Volo.Abp.EntityFrameworkCore;
+
+namespace LINGYUN.Platform.Migrations
+{
+ [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))]
+ [Migration("20200724092022_Add-Version-File-Field-Path-And-Platform-Type")]
+ partial class AddVersionFileFieldPathAndPlatformType
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
+ .HasAnnotation("ProductVersion", "3.1.5")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("LINGYUN.Platform.Routes.RoleRoute", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeleterId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeletionTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnType("char(36)");
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasColumnName("RoleName")
+ .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
+ .HasMaxLength(256);
+
+ b.Property("RouteId")
+ .HasColumnType("char(36)");
+
+ b.Property("TenantId")
+ .HasColumnName("TenantId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleName", "RouteId");
+
+ b.ToTable("AppPlatformRoleRoute");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("AlwaysShow")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnName("Code")
+ .HasColumnType("varchar(95) CHARACTER SET utf8mb4")
+ .HasMaxLength(95);
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnName("ConcurrencyStamp")
+ .HasColumnType("varchar(40) CHARACTER SET utf8mb4")
+ .HasMaxLength(40);
+
+ b.Property("CreationTime")
+ .HasColumnName("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnName("CreatorId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeleterId")
+ .HasColumnName("DeleterId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeletionTime")
+ .HasColumnName("DeletionTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Description")
+ .HasColumnName("Description")
+ .HasColumnType("varchar(255) CHARACTER SET utf8mb4")
+ .HasMaxLength(255);
+
+ b.Property("DisplayName")
+ .IsRequired()
+ .HasColumnName("DisplayName")
+ .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
+ .HasMaxLength(128);
+
+ b.Property("ExtraProperties")
+ .HasColumnName("ExtraProperties")
+ .HasColumnType("longtext CHARACTER SET utf8mb4");
+
+ b.Property("FullName")
+ .HasColumnName("FullName")
+ .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
+ .HasMaxLength(128);
+
+ b.Property("Icon")
+ .HasColumnName("Icon")
+ .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
+ .HasMaxLength(128);
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnName("IsDeleted")
+ .HasColumnType("tinyint(1)")
+ .HasDefaultValue(false);
+
+ b.Property("IsMenu")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsPublic")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsSideBar")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsStatic")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsToolBar")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LastModificationTime")
+ .HasColumnName("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnName("LastModifierId")
+ .HasColumnType("char(36)");
+
+ b.Property("LinkUrl")
+ .IsRequired()
+ .HasColumnName("LinkUrl")
+ .HasColumnType("varchar(255) CHARACTER SET utf8mb4")
+ .HasMaxLength(255);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnName("Name")
+ .HasColumnType("varchar(64) CHARACTER SET utf8mb4")
+ .HasMaxLength(64);
+
+ b.Property("ParentId")
+ .HasColumnType("char(36)");
+
+ b.Property("PlatformType")
+ .HasColumnType("int");
+
+ b.Property("TenantId")
+ .HasColumnName("TenantId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Code");
+
+ b.HasIndex("ParentId");
+
+ b.ToTable("AppPlatformRoute");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Routes.UserRoute", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeleterId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeletionTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnType("char(36)");
+
+ b.Property("RouteId")
+ .HasColumnType("char(36)");
+
+ b.Property("TenantId")
+ .HasColumnName("TenantId")
+ .HasColumnType("char(36)");
+
+ b.Property("UserId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "RouteId");
+
+ b.ToTable("AppPlatformUserRoute");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnName("ConcurrencyStamp")
+ .HasColumnType("varchar(40) CHARACTER SET utf8mb4")
+ .HasMaxLength(40);
+
+ b.Property("CreationTime")
+ .HasColumnName("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnName("CreatorId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeleterId")
+ .HasColumnName("DeleterId")
+ .HasColumnType("char(36)");
+
+ b.Property("DeletionTime")
+ .HasColumnName("DeletionTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Description")
+ .HasColumnName("Description")
+ .HasColumnType("longtext CHARACTER SET utf8mb4")
+ .HasMaxLength(2048);
+
+ b.Property("ExtraProperties")
+ .HasColumnName("ExtraProperties")
+ .HasColumnType("longtext CHARACTER SET utf8mb4");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnName("IsDeleted")
+ .HasColumnType("tinyint(1)")
+ .HasDefaultValue(false);
+
+ b.Property("LastModificationTime")
+ .HasColumnName("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnName("LastModifierId")
+ .HasColumnType("char(36)");
+
+ b.Property("Level")
+ .HasColumnType("int");
+
+ b.Property("PlatformType")
+ .HasColumnType("int");
+
+ b.Property("TenantId")
+ .HasColumnName("TenantId")
+ .HasColumnType("char(36)");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnName("Title")
+ .HasColumnType("varchar(50) CHARACTER SET utf8mb4")
+ .HasMaxLength(50);
+
+ b.Property("Version")
+ .IsRequired()
+ .HasColumnName("Version")
+ .HasColumnType("varchar(20) CHARACTER SET utf8mb4")
+ .HasMaxLength(20);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Version");
+
+ b.ToTable("AppPlatformVersion");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("AppVersionId")
+ .HasColumnType("char(36)");
+
+ b.Property("CreationTime")
+ .HasColumnName("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnName("CreatorId")
+ .HasColumnType("char(36)");
+
+ b.Property("DownloadCount")
+ .HasColumnType("int");
+
+ b.Property("FileType")
+ .HasColumnType("int");
+
+ b.Property("LastModificationTime")
+ .HasColumnName("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnName("LastModifierId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnName("Name")
+ .HasColumnType("varchar(255) CHARACTER SET utf8mb4")
+ .HasMaxLength(255);
+
+ b.Property("Path")
+ .HasColumnName("Path")
+ .HasColumnType("varchar(255) CHARACTER SET utf8mb4")
+ .HasMaxLength(255);
+
+ b.Property("SHA256")
+ .IsRequired()
+ .HasColumnName("SHA256")
+ .HasColumnType("varchar(65) CHARACTER SET utf8mb4")
+ .HasMaxLength(65);
+
+ b.Property("Size")
+ .HasColumnType("bigint");
+
+ b.Property("TenantId")
+ .HasColumnName("TenantId")
+ .HasColumnType("char(36)");
+
+ b.Property("Version")
+ .IsRequired()
+ .HasColumnName("Version")
+ .HasColumnType("varchar(20) CHARACTER SET utf8mb4")
+ .HasMaxLength(20);
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppVersionId");
+
+ b.HasIndex("Path", "Name", "Version")
+ .IsUnique();
+
+ b.ToTable("AppPlatformVersionFile");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b =>
+ {
+ b.HasOne("LINGYUN.Platform.Routes.Route", null)
+ .WithMany()
+ .HasForeignKey("ParentId");
+ });
+
+ modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b =>
+ {
+ b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion")
+ .WithMany("Files")
+ .HasForeignKey("AppVersionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.cs
new file mode 100644
index 000000000..269bf8cfc
--- /dev/null
+++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200724092022_Add-Version-File-Field-Path-And-Platform-Type.cs
@@ -0,0 +1,52 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace LINGYUN.Platform.Migrations
+{
+ public partial class AddVersionFileFieldPathAndPlatformType : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_AppPlatformVersionFile_Name_Version",
+ table: "AppPlatformVersionFile");
+
+ migrationBuilder.AddColumn(
+ name: "Path",
+ table: "AppPlatformVersionFile",
+ maxLength: 255,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "PlatformType",
+ table: "AppPlatformVersion",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AppPlatformVersionFile_Path_Name_Version",
+ table: "AppPlatformVersionFile",
+ columns: new[] { "Path", "Name", "Version" },
+ unique: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_AppPlatformVersionFile_Path_Name_Version",
+ table: "AppPlatformVersionFile");
+
+ migrationBuilder.DropColumn(
+ name: "Path",
+ table: "AppPlatformVersionFile");
+
+ migrationBuilder.DropColumn(
+ name: "PlatformType",
+ table: "AppPlatformVersion");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AppPlatformVersionFile_Name_Version",
+ table: "AppPlatformVersionFile",
+ columns: new[] { "Name", "Version" });
+ }
+ }
+}
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs
index b22be8893..339fcfa7f 100644
--- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs
+++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs
@@ -286,6 +286,9 @@ namespace LINGYUN.Platform.Migrations
b.Property("Level")
.HasColumnType("int");
+ b.Property("PlatformType")
+ .HasColumnType("int");
+
b.Property("TenantId")
.HasColumnName("TenantId")
.HasColumnType("char(36)");
@@ -346,6 +349,11 @@ namespace LINGYUN.Platform.Migrations
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasMaxLength(255);
+ b.Property("Path")
+ .HasColumnName("Path")
+ .HasColumnType("varchar(255) CHARACTER SET utf8mb4")
+ .HasMaxLength(255);
+
b.Property("SHA256")
.IsRequired()
.HasColumnName("SHA256")
@@ -369,7 +377,8 @@ namespace LINGYUN.Platform.Migrations
b.HasIndex("AppVersionId");
- b.HasIndex("Name", "Version");
+ b.HasIndex("Path", "Name", "Version")
+ .IsUnique();
b.ToTable("AppPlatformVersionFile");
});