Skip to content

Commit

Permalink
Update CultureDto and SettingService
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyunchong committed Mar 17, 2024
1 parent ad10856 commit eec3688
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace LinCms.Base.Localizations;
public class CultureDto : EntityDto<long>
{
[Required]
[StringLength(10)]
[StringLength(50,ErrorMessage = "名称最大长度为50")]
public string Name { get; set; }

[Required]
[StringLength(10)]
[StringLength(50,ErrorMessage = "显示名称最大长度为50")]
public string DisplayName { get; set; }
}
11 changes: 7 additions & 4 deletions src/LinCms.Application/Cms/Settings/SettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public async Task<string> 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<LinSetting>(createSetting));
Expand All @@ -65,7 +66,9 @@ public async Task<SettingDto> GetAsync(Guid id)

public async Task<PagedResultDto<SettingDto>> GetPagedListAsync(PageDto pageDto)
{
List<SettingDto> list = (await _settingRepository.Select.ToPagerListAsync(pageDto, out long totalCount))
List<SettingDto> list =
(await _settingRepository.Select.OrderByDescending(r => r.CreateTime)
.ToPagerListAsync(pageDto, out long totalCount))
.Select(r => Mapper.Map<SettingDto>(r)).ToList();

return new PagedResultDto<SettingDto>(list, totalCount);
Expand All @@ -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("该配置已存在");
Expand Down
9 changes: 6 additions & 3 deletions src/LinCms.Infrastructure/Repositories/SettingRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

namespace LinCms.Repositories;

public class SettingRepository : AuditDefaultRepository<LinSetting,Guid,long>, ISettingRepository
public class SettingRepository : AuditDefaultRepository<LinSetting, Guid, Guid>, ISettingRepository
{
public SettingRepository(UnitOfWorkManager unitOfWorkManager, ICurrentUser currentUser) : base(unitOfWorkManager, currentUser)
public SettingRepository(UnitOfWorkManager unitOfWorkManager, ICurrentUser currentUser) : base(unitOfWorkManager,
currentUser)
{
}

Expand All @@ -26,6 +27,8 @@ public async Task<List<LinSetting>> GetListAsync(string providerName, string pro
return await Select
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
)
.OrderByDescending(r => r.CreateTime)
.ToListAsync();
}
}

0 comments on commit eec3688

Please sign in to comment.