You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.4 KiB
72 lines
2.4 KiB
3 years ago
|
using Sanhe.Abp.LocalizationManagement.Permissions;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Threading.Tasks;
|
||
|
using Volo.Abp.Application.Dtos;
|
||
|
using Volo.Abp.Application.Services;
|
||
|
|
||
|
namespace Sanhe.Abp.LocalizationManagement;
|
||
|
|
||
|
public class TextAppService : CrudAppService<
|
||
|
Text,
|
||
|
TextDto,
|
||
|
TextDifferenceDto,
|
||
|
int,
|
||
|
GetTextsInput,
|
||
|
CreateTextInput,
|
||
|
UpdateTextInput>, ITextAppService
|
||
|
{
|
||
|
private readonly ITextRepository _textRepository;
|
||
|
|
||
|
public TextAppService(ITextRepository repository) : base(repository)
|
||
|
{
|
||
|
_textRepository = repository;
|
||
|
|
||
|
GetPolicyName = LocalizationManagementPermissions.Text.Default;
|
||
|
GetListPolicyName = LocalizationManagementPermissions.Text.Default;
|
||
|
CreatePolicyName = LocalizationManagementPermissions.Text.Create;
|
||
|
UpdatePolicyName = LocalizationManagementPermissions.Text.Update;
|
||
|
DeletePolicyName = LocalizationManagementPermissions.Text.Delete;
|
||
|
}
|
||
|
|
||
|
public async virtual Task<TextDto> GetByCultureKeyAsync(GetTextByKeyInput input)
|
||
|
{
|
||
|
await CheckGetPolicyAsync();
|
||
|
|
||
|
var text = await _textRepository.GetByCultureKeyAsync(
|
||
|
input.ResourceName, input.CultureName, input.Key);
|
||
|
|
||
|
return await MapToGetOutputDtoAsync(text);
|
||
|
}
|
||
|
|
||
|
public async override Task<PagedResultDto<TextDifferenceDto>> GetListAsync(GetTextsInput input)
|
||
|
{
|
||
|
await CheckGetListPolicyAsync();
|
||
|
|
||
|
var count = await _textRepository.GetDifferenceCountAsync(
|
||
|
input.CultureName, input.TargetCultureName,
|
||
|
input.ResourceName, input.OnlyNull, input.Filter);
|
||
|
|
||
|
var texts = await _textRepository.GetDifferencePagedListAsync(
|
||
|
input.CultureName, input.TargetCultureName,
|
||
|
input.ResourceName, input.OnlyNull, input.Filter,
|
||
|
input.Sorting, input.SkipCount, input.MaxResultCount);
|
||
|
|
||
|
return new PagedResultDto<TextDifferenceDto>(count,
|
||
|
ObjectMapper.Map<List<TextDifference>, List<TextDifferenceDto>>(texts));
|
||
|
}
|
||
|
|
||
|
protected override Text MapToEntity(CreateTextInput createInput)
|
||
|
{
|
||
|
return new Text(
|
||
|
createInput.ResourceName,
|
||
|
createInput.CultureName,
|
||
|
createInput.Key,
|
||
|
createInput.Value);
|
||
|
}
|
||
|
|
||
|
protected override void MapToEntity(UpdateTextInput updateInput, Text entity)
|
||
|
{
|
||
|
entity.SetValue(updateInput.Value);
|
||
|
}
|
||
|
}
|