33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using FreeSql;
|
|
using F9WebAiTest.Domain.Entities.SYS.YuanliaoZhuangkous;
|
|
using F9WebAiTest.Domain.Interfaces.SYS.YuanliaoZhuangkous;
|
|
|
|
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.YuanliaoZhuangkous;
|
|
|
|
internal class YuanliaoZhuangkouWriteRepository : F9RepositoryBase, IYuanliaoZhuangkouWriteRepository
|
|
{
|
|
public YuanliaoZhuangkouWriteRepository(IFreeSql fsql) : base(fsql) { }
|
|
|
|
public async Task<YuanliaoZhuangkou> GetByIdAsync(long id, CancellationToken cancellationToken)
|
|
=> await Orm.Select<YuanliaoZhuangkou>().Where(x => x.Id == id && x.DeletedAt == null).FirstAsync(cancellationToken);
|
|
|
|
public async Task<bool> AddAsync(YuanliaoZhuangkou entity)
|
|
{
|
|
entity.CreatedAt = DateTime.Now;
|
|
return await Orm.Insert(entity).ExecuteAffrowsAsync() > 0;
|
|
}
|
|
|
|
public async Task<bool> UpdateAsync(YuanliaoZhuangkou entity)
|
|
{
|
|
entity.UpdatedAt = DateTime.Now;
|
|
return await Orm.Update<YuanliaoZhuangkou>().SetSource(entity).ExecuteAffrowsAsync() > 0;
|
|
}
|
|
|
|
public async Task<bool> SoftDeleteAsync(long id)
|
|
=> await Orm.Update<YuanliaoZhuangkou>()
|
|
.Set(x => x.IsDeleted, true)
|
|
.Set(x => x.DeletedAt, DateTime.Now)
|
|
.Where(x => x.Id == id)
|
|
.ExecuteAffrowsAsync() > 0;
|
|
}
|