Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Masa.Dcc.Infrastructure.Domain/Services/LabelDomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public async Task AddLabelAsync(UpdateLabelDto labelDto)
}
else
{
var label = await _labelRepository.FindAsync(x => x.TypeCode == labelDto.TypeCode);
var label = await _labelRepository.FindAsync(x => x.TypeCode == labelDto.TypeCode || x.TypeName == labelDto.TypeName);
if (label is not null)
{
throw new UserFriendlyException(_i18n.T("Duplicate label type code"));
throw new UserFriendlyException(_i18n.T(label.TypeCode == labelDto.TypeCode ? "Duplicate label type code" : "Duplicate label type name"));
}

List<Label> labels = new();
Expand All @@ -51,11 +51,15 @@ public async Task AddLabelAsync(UpdateLabelDto labelDto)

public async Task UpdateLabelAsync(UpdateLabelDto labelDto)
{
if (await _labelRepository.AsQueryable().Where(lable => lable.TypeCode != labelDto.TypeCode && lable.TypeName == labelDto.TypeName).AnyAsync())
{
throw new UserFriendlyException(_i18n.T("Duplicate label type name"));
}

var labelEntities = await _labelRepository.GetListAsync(l => l.TypeCode.Equals(labelDto.TypeCode));
if (labelEntities.Any())
{
await _labelRepository.RemoveRangeAsync(labelEntities);

List<Label> labels = new();
var labelEntity = labelEntities.First();
foreach (var item in labelDto.LabelValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IAppConfigObjectRepository : IRepository<AppConfigObject>
public interface IAppConfigObjectRepository : IRepositoryExtensition<AppConfigObject>
{
Task<List<AppConfigObject>> GetListByAppIdAsync(int appId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IAppPinRepository : IRepository<AppPin>
public interface IAppPinRepository : IRepositoryExtensition<AppPin>
{
Task<List<AppPin>> GetListAsync(List<int> appIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IBizConfigObjectRepository : IRepository<BizConfigObject>
public interface IBizConfigObjectRepository : IRepositoryExtensition<BizConfigObject>
{
Task<List<BizConfigObject>> GetListByEnvClusterIdAsync(int envClusterId, int bizConfigId,
bool getLatestRelease = false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IBizConfigRepository : IRepository<BizConfig>
public interface IBizConfigRepository : IRepositoryExtensition<BizConfig>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IConfigObjectReleaseRepository : IRepository<ConfigObjectRelease>
public interface IConfigObjectReleaseRepository : IRepositoryExtensition<ConfigObjectRelease>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IConfigObjectRepository : IRepository<ConfigObject>
public interface IConfigObjectRepository : IRepositoryExtensition<ConfigObject>
{
Task<ConfigObject> GetConfigObjectWithReleaseHistoriesAsync(int Id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IPublicConfigObjectRepository : IRepository<PublicConfigObject>
public interface IPublicConfigObjectRepository : IRepositoryExtensition<PublicConfigObject>
{
Task<List<PublicConfigObject>> GetListByEnvClusterIdAsync(int? envClusterId, int publicConfigId,
bool getLatestRelease = false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Masa.Dcc.Infrastructure.Repository.App;

public interface IPublicConfigRepository : IRepository<PublicConfig>
public interface IPublicConfigRepository : IRepositoryExtensition<PublicConfig>
{
}
11 changes: 11 additions & 0 deletions Masa.Dcc.Infrastructure.Repository/IRepositoryExtensition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.BuildingBlocks.Ddd.Domain.Entities;

namespace Masa.Dcc.Infrastructure.Repository.Label;

public interface IRepositoryExtensition<TEntity> : IRepository<TEntity> where TEntity : class, IEntity
{
IQueryable<TEntity> AsQueryable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Masa.Dcc.Infrastructure.Repository.Label;

public interface ILabelRepository : IRepository<Domain.Shared.Label>
public interface ILabelRepository : IRepositoryExtensition<Domain.Shared.Label>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class AppConfigObjectRepository : Repository<DccDbContext, AppConfigObject>, IAppConfigObjectRepository
internal class AppConfigObjectRepository : EFBaseRepository<DccDbContext, AppConfigObject>, IAppConfigObjectRepository
{
public AppConfigObjectRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class AppPinRepository : Repository<DccDbContext, AppPin>, IAppPinRepository
internal class AppPinRepository : EFBaseRepository<DccDbContext, AppPin>, IAppPinRepository
{
public AppPinRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class BizConfigObjectRepository : Repository<DccDbContext, BizConfigObject>, IBizConfigObjectRepository
internal class BizConfigObjectRepository : EFBaseRepository<DccDbContext, BizConfigObject>, IBizConfigObjectRepository
{
public BizConfigObjectRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class BizConfigRepository : Repository<DccDbContext, BizConfig>, IBizConfigRepository
internal class BizConfigRepository : EFBaseRepository<DccDbContext, BizConfig>, IBizConfigRepository
{
public BizConfigRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class ConfigObjectReleaseRepository : Repository<DccDbContext, ConfigObjectRelease>, IConfigObjectReleaseRepository
internal class ConfigObjectReleaseRepository : EFBaseRepository<DccDbContext, ConfigObjectRelease>, IConfigObjectReleaseRepository
{
public ConfigObjectReleaseRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class ConfigObjectRepository : Repository<DccDbContext, ConfigObject>, IConfigObjectRepository
internal class ConfigObjectRepository : EFBaseRepository<DccDbContext, ConfigObject>, IConfigObjectRepository
{
public ConfigObjectRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class PublicConfigObjectRepository : Repository<DccDbContext, PublicConfigObject>, IPublicConfigObjectRepository
internal class PublicConfigObjectRepository : EFBaseRepository<DccDbContext, PublicConfigObject>, IPublicConfigObjectRepository
{
public PublicConfigObjectRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.App;

internal class PublicConfigRepository : Repository<DccDbContext, PublicConfig>, IPublicConfigRepository
internal class PublicConfigRepository : EFBaseRepository<DccDbContext, PublicConfig>, IPublicConfigRepository
{
public PublicConfigRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.BuildingBlocks.Data;
using Masa.BuildingBlocks.Ddd.Domain.Entities;

namespace Masa.Dcc.Infrastructure.Repository.Repositories;

public class EFBaseRepository<TDbContext, TEntity> : Repository<TDbContext, TEntity>, IRepositoryExtensition<TEntity>
where TEntity : class, IEntity
where TDbContext : DbContext, IMasaDbContext
{
public EFBaseRepository(TDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
}

public IQueryable<TEntity> AsQueryable()
{
return Context.Set<TEntity>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Dcc.Infrastructure.Repository.Repositories.Label;

internal class LabelRepository : Repository<DccDbContext, Domain.Shared.Label>, ILabelRepository
internal class LabelRepository : EFBaseRepository<DccDbContext, Domain.Shared.Label>, ILabelRepository
{
public LabelRepository(DccDbContext context, IUnitOfWork unitOfWork) : base(context, unitOfWork)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@ public class AddConfigObjectDto
{
private string _name = "";

[Required]
[RegularExpression(@"^[\u4E00-\u9FA5A-Za-z0-9`~!@#%^&*()_\-+=<>?:""{}|,.\/;'\\[\]·~!¥%……&*()——《》?:“”【】、;‘’,。]+$", ErrorMessage = "Special symbols are not allowed")]
[StringLength(50, MinimumLength = 2)]
public string Name { get => _name; set => _name = value.Trim(); }

[Required]
public string FormatLabelCode { get; set; } = "JSON";

[Required]
[Range(1, int.MaxValue)]
public ConfigObjectType Type { get; set; }

public bool Encryption { get; set; }

/// <summary>
/// appid or publicid or bizid
/// </summary>
[Required]
/// </summary>
public int ObjectId { get; set; }

public int EnvironmentClusterId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,20 @@ namespace Masa.Dcc.Contracts.Admin.App.Dtos
{
public class AddConfigObjectReleaseDto
{
[Required]
public ReleaseType Type { get; set; }

[Required(ErrorMessage = "Config object Id is required")]
[Range(minimum: 1, maximum: int.MaxValue, ErrorMessage = "Config object Id is required")]

public int ConfigObjectId { get; set; }

[Required(ErrorMessage = "Name is required", AllowEmptyStrings = true)]
[StringLength(50, MinimumLength = 2, ErrorMessage = "Name length range is [2-50]")]

public string Name { get; set; } = "";

[Required(ErrorMessage = "Comment is required", AllowEmptyStrings = true)]
[StringLength(255, MinimumLength = 0, ErrorMessage = "Comment length range is [0-255]")]

public string Comment { get; set; } = "";

[Required]
public string EnvironmentName { get; set; } = "";

[Required]
public string ClusterName { get; set; } = "";

[Required]
public string Identity { get; set; } = "";

[Required]
public string Content { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Dcc.Contracts.Admin.App.Dtos
namespace Masa.Dcc.Contracts.Admin.App.Dtos;

public class AddObjectConfigDto
{
public class AddObjectConfigDto
{
[Required]
[RegularExpression(@"^[\u4E00-\u9FA5A-Za-z0-9_-.]+$", ErrorMessage = "Please enter [Chinese, English、and - _ . symbols] ")]
[StringLength(50, MinimumLength = 2)]
public string Name { get; set; } = "";
public string Name { get; set; } = "";

[Required]
[RegularExpression(@"^[\u4E00-\u9FA5A-Za-z0-9_-.]+$", ErrorMessage = "Please enter [Chinese, English、and - _ . symbols] ")]
[StringLength(50, MinimumLength = 2)]
public string Identity { get; set; } = "";
public string Identity { get; set; } = "";

[StringLength(255)]
public string Description { get; set; } = "";
public string Description { get; set; } = "";

public AddObjectConfigDto()
{
}
public AddObjectConfigDto()
{
}

public AddObjectConfigDto(string name, string identity, string description = "")
{
Name = name;
Identity = identity;
Description = description;
}
public AddObjectConfigDto(string name, string identity, string description = "")
{
Name = name;
Identity = identity;
Description = description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Masa.Dcc.Contracts.Admin.App.Dtos
{
public class ConfigObjectPropertyContentDto
{
[Required]
public string Key { get; set; } = "";

public string Value { get; set; } = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Dcc.Contracts.Admin.App.Dtos
namespace Masa.Dcc.Contracts.Admin.App.Dtos;

public class RollbackConfigObjectReleaseDto
{
public class RollbackConfigObjectReleaseDto
{
[Required]
[Range(1, int.MaxValue)]
public int ConfigObjectId { get; set; }
public int ConfigObjectId { get; set; }

[Required]
[Range(1, int.MaxValue)]
public int RollbackToReleaseId { get; set; }
}
public int RollbackToReleaseId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ namespace Masa.Dcc.Contracts.Admin.App.Dtos
{
public class UpdateObjectConfigDto
{
[Required]
[Range(1, int.MaxValue)]
public int Id { get; set; }

[Required]
[RegularExpression(@"^[\u4E00-\u9FA5A-Za-z0-9_-.]+$", ErrorMessage = "Please enter [Chinese、Number、 English、and - _ . symbols] ")]
[StringLength(50, MinimumLength = 2)]
public string Name { get; set; } = "";

[StringLength(255)]
public string Description { get; set; } = "";

public UpdateObjectConfigDto()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Dcc.Contracts.Admin.App.Enums
namespace Masa.Dcc.Contracts.Admin.App.Enums;

public enum ConfigObjectType
{
public enum ConfigObjectType
{
Public = 1,
Biz = 2,
App = 3
}
Public = 1,
Biz = 2,
App = 3
}
Loading