完善基础数据

This commit is contained in:
yanpeng200212
2026-10-08 15:44:07 +08:00
parent 8430ba0452
commit 2ffb83830c
95 changed files with 37759 additions and 5 deletions
@@ -0,0 +1,28 @@
using FreeSql;
using F9WebAiTest.Application.Dtos.SYS.Registries;
using F9WebAiTest.Application.Interfaces.Repositories.SYS.Registries;
using F9WebAiTest.Domain.Entities.SYS.Registries;
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Registries;
internal class RegistryReadRepository : F9RepositoryBase, IRegistryReadRepository
{
public RegistryReadRepository(IFreeSql fsql) : base(fsql) { }
public async Task<List<RegistryReadDto_View>> GetAllAsync()
=> await Orm.Select<Registry>()
.Where(x => x.DeletedAt == null)
.OrderBy(x => x.Category)
.OrderBy(x => x.KeyName)
.ToListAsync(x => new RegistryReadDto_View(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive));
public async Task<RegistryReadDto_Edit> GetByIdForEditAsync(long id)
=> await Orm.Select<Registry>()
.Where(x => x.Id == id && x.DeletedAt == null)
.FirstAsync(x => new RegistryReadDto_Edit(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive));
public async Task<RegistryReadDto_Edit> GetByCategoryAndKeyAsync(string category, string keyName)
=> await Orm.Select<Registry>()
.Where(x => x.DeletedAt == null && x.Category == category && x.KeyName == keyName)
.FirstAsync(x => new RegistryReadDto_Edit(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive));
}
@@ -0,0 +1,37 @@
using FreeSql;
using F9WebAiTest.Domain.Entities.SYS.Registries;
using F9WebAiTest.Domain.Interfaces.SYS.Registries;
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Registries;
internal class RegistryWriteRepository : F9RepositoryBase, IRegistryWriteRepository
{
public RegistryWriteRepository(IFreeSql fsql) : base(fsql) { }
public async Task<Registry> GetByIdAsync(long id, CancellationToken cancellationToken)
=> await Orm.Select<Registry>().Where(x => x.Id == id && x.DeletedAt == null).FirstAsync(cancellationToken);
public async Task<Registry> GetByCategoryAndKeyAsync(string category, string keyName)
=> await Orm.Select<Registry>()
.Where(x => x.DeletedAt == null && x.Category == category && x.KeyName == keyName)
.FirstAsync();
public async Task<bool> AddAsync(Registry registry)
{
registry.CreatedAt = DateTime.Now;
return await Orm.Insert(registry).ExecuteAffrowsAsync() > 0;
}
public async Task<bool> UpdateAsync(Registry registry)
{
registry.UpdatedAt = DateTime.Now;
return await Orm.Update<Registry>().SetSource(registry).ExecuteAffrowsAsync() > 0;
}
public async Task<bool> SoftDeleteAsync(long id)
=> await Orm.Update<Registry>()
.Set(x => x.IsDeleted, true)
.Set(x => x.DeletedAt, DateTime.Now)
.Where(x => x.Id == id)
.ExecuteAffrowsAsync() > 0;
}