using System.Data; using System.Threading.Tasks; using Znyc.Admin.Commons.Services; using Znyc.Admin.Security.Dtos; using Znyc.Admin.Security.Entitys; using Znyc.Admin.Security.IRepositories; using Znyc.Admin.Security.IServices; namespace Znyc.Admin.Security.Services { /// /// /// public class MessageService : BaseService, IMessageService { private readonly IMessageRepository _messageRepository; public MessageService( IMessageRepository repository ) : base(repository) { _messageRepository = repository; } /// /// 同步新增实体。 /// /// 实体 /// 事务对象 /// public override long Insert(Message entity, IDbTransaction trans = null) { entity.Id = Yitter.IdGenerator.YitIdHelper.NextId(); long result = repository.Insert(entity, trans); return result; } /// /// 异步更新实体。 /// /// 实体 /// 主键ID /// 事务对象 /// public override async Task UpdateAsync(Message entity, long id, IDbTransaction trans = null) { bool result = await repository.UpdateAsync(entity, id, trans); return result; } /// /// 异步步新增实体。 /// /// 实体 /// 事务对象 /// public override async Task InsertAsync(Message entity, IDbTransaction trans = null) { entity.Id = Yitter.IdGenerator.YitIdHelper.NextId(); int result = await repository.InsertAsync(entity, trans); return result; } } }