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.
64 lines
2.1 KiB
64 lines
2.1 KiB
using System.Data;
|
|
using System.Threading.Tasks;
|
|
using Yitter.IdGenerator;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
/// <summary>
|
|
/// </summary>
|
|
public class MessageService : BaseService<MessageEntity, MessageOutputDto, long>, IMessageService
|
|
{
|
|
private readonly IMessageRepository _messageRepository;
|
|
|
|
public MessageService(
|
|
IMessageRepository repository
|
|
) : base(repository)
|
|
{
|
|
_messageRepository = repository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同步新增实体。
|
|
/// </summary>
|
|
/// <param name="entity">实体</param>
|
|
/// <param name="trans">事务对象</param>
|
|
/// <returns></returns>
|
|
public override long Insert(MessageEntity entity, IDbTransaction trans = null)
|
|
{
|
|
entity.Id = YitIdHelper.NextId();
|
|
long result = repository.Insert(entity, trans);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异步更新实体。
|
|
/// </summary>
|
|
/// <param name="entity">实体</param>
|
|
/// <param name="id">主键ID</param>
|
|
/// <param name="trans">事务对象</param>
|
|
/// <returns></returns>
|
|
public override async Task<bool> UpdateAsync(MessageEntity entity, long id, IDbTransaction trans = null)
|
|
{
|
|
bool result = await repository.UpdateAsync(entity, id, trans);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异步步新增实体。
|
|
/// </summary>
|
|
/// <param name="entity">实体</param>
|
|
/// <param name="trans">事务对象</param>
|
|
/// <returns></returns>
|
|
public override async Task<int> InsertAsync(MessageEntity entity, IDbTransaction trans = null)
|
|
{
|
|
entity.Id = YitIdHelper.NextId();
|
|
int result = await repository.InsertAsync(entity, trans);
|
|
return result;
|
|
}
|
|
}
|
|
}
|