|
@@ -1,8 +1,30 @@
|
|
|
using XF.Domain.Dependency;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
|
|
|
namespace Hotline.Settings.TimeLimits
|
|
|
{
|
|
|
public class TimeLimitDomainService : ITimeLimitDomainService, IScopeDependency
|
|
|
{
|
|
|
+ private readonly ITimeLimitRepository _timeLimitRepository;
|
|
|
+
|
|
|
+ public TimeLimitDomainService(ITimeLimitRepository timeLimitRepository)
|
|
|
+ {
|
|
|
+ _timeLimitRepository = timeLimitRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<string> AddAsync(TimeLimit model, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ return await _timeLimitRepository.AddAsync(model, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task UpdateAsync(TimeLimit model, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var dbModel = await _timeLimitRepository.GetAsync(model.Id, cancellationToken);
|
|
|
+ if (dbModel == null)
|
|
|
+ {
|
|
|
+ throw new UserFriendlyException("无效数据");
|
|
|
+ }
|
|
|
+ await _timeLimitRepository.UpdateAsync(model, cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
}
|