diff --git a/src/LinCms.Application.Contracts/Base/Localizations/CultureDto.cs b/src/LinCms.Application.Contracts/Base/Localizations/CultureDto.cs index 92df7c94..008a3864 100644 --- a/src/LinCms.Application.Contracts/Base/Localizations/CultureDto.cs +++ b/src/LinCms.Application.Contracts/Base/Localizations/CultureDto.cs @@ -6,10 +6,10 @@ namespace LinCms.Base.Localizations; public class CultureDto : EntityDto { [Required] - [StringLength(10)] + [StringLength(50,ErrorMessage = "名称最大长度为50")] public string Name { get; set; } [Required] - [StringLength(10)] + [StringLength(50,ErrorMessage = "显示名称最大长度为50")] public string DisplayName { get; set; } } \ No newline at end of file diff --git a/src/LinCms.Application/Cms/Settings/SettingService.cs b/src/LinCms.Application/Cms/Settings/SettingService.cs index 042b2cbf..0284f991 100644 --- a/src/LinCms.Application/Cms/Settings/SettingService.cs +++ b/src/LinCms.Application/Cms/Settings/SettingService.cs @@ -45,8 +45,9 @@ public async Task GetOrNullAsync(string name, string providerName, strin public async Task SetAsync(CreateUpdateSettingDto createSetting) { - LinSetting setting = await _settingRepository.FindAsync(createSetting.Name, createSetting.ProviderName,createSetting.ProviderKey); - + LinSetting setting = await _settingRepository.FindAsync(createSetting.Name, createSetting.ProviderName, + createSetting.ProviderKey); + if (setting == null) { await _settingRepository.InsertAsync(Mapper.Map(createSetting)); @@ -65,7 +66,9 @@ public async Task GetAsync(Guid id) public async Task> GetPagedListAsync(PageDto pageDto) { - List list = (await _settingRepository.Select.ToPagerListAsync(pageDto, out long totalCount)) + List list = + (await _settingRepository.Select.OrderByDescending(r => r.CreateTime) + .ToPagerListAsync(pageDto, out long totalCount)) .Select(r => Mapper.Map(r)).ToList(); return new PagedResultDto(list, totalCount); @@ -75,7 +78,7 @@ public async Task CreateAsync(CreateUpdateSettingDto createSettingDto) { LinSetting setting = await _settingRepository.FindAsync(createSettingDto.Name, createSettingDto.ProviderName, createSettingDto.ProviderKey); - ; + if (setting != null) { throw new LinCmsException("该配置已存在"); diff --git a/src/LinCms.Infrastructure/Repositories/SettingRepository.cs b/src/LinCms.Infrastructure/Repositories/SettingRepository.cs index 8c5be410..27884fdd 100644 --- a/src/LinCms.Infrastructure/Repositories/SettingRepository.cs +++ b/src/LinCms.Infrastructure/Repositories/SettingRepository.cs @@ -9,9 +9,10 @@ namespace LinCms.Repositories; -public class SettingRepository : AuditDefaultRepository, ISettingRepository +public class SettingRepository : AuditDefaultRepository, ISettingRepository { - public SettingRepository(UnitOfWorkManager unitOfWorkManager, ICurrentUser currentUser) : base(unitOfWorkManager, currentUser) + public SettingRepository(UnitOfWorkManager unitOfWorkManager, ICurrentUser currentUser) : base(unitOfWorkManager, + currentUser) { } @@ -26,6 +27,8 @@ public async Task> GetListAsync(string providerName, string pro return await Select .Where( s => s.ProviderName == providerName && s.ProviderKey == providerKey - ).ToListAsync(); + ) + .OrderByDescending(r => r.CreateTime) + .ToListAsync(); } } \ No newline at end of file