first commit

This commit is contained in:
yanpeng200212
2026-10-08 10:43:59 +08:00
commit 8430ba0452
288 changed files with 29595 additions and 0 deletions
@@ -0,0 +1,17 @@
using FreeSql;
using F9WebAiTest.Application.Dtos.SYS.Departments;
using F9WebAiTest.Application.Interfaces.Repositories.SYS.Departments;
using F9WebAiTest.Domain.Entities.SYS.Departments;
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Departments;
internal class DepartmentReadRepository : F9RepositoryBase, IDepartmentReadRepository
{
public DepartmentReadRepository(IFreeSql fsql) : base(fsql) { }
public async Task<List<DepartmentReadDto_View>> GetAllAsync()
=> await Orm.Select<Department>()
.Where(x => x.DeletedAt == null)
.OrderBy(x => x.SortOrder)
.ToListAsync(x => new DepartmentReadDto_View(x.Id, x.Code, x.Name, x.ParentId, x.ManageType, x.DutyType, x.Description, x.IsActive, x.SortOrder));
}
@@ -0,0 +1,21 @@
using FreeSql;
using F9WebAiTest.Domain.Entities.SYS.Departments;
using F9WebAiTest.Domain.Interfaces.SYS.Departments;
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Departments;
internal class DepartmentUserRepository : F9RepositoryBase, IDepartmentUserRepository
{
public DepartmentUserRepository(IFreeSql fsql) : base(fsql) { }
public async Task<bool> AssignAsync(DepartmentUser depUser)
{
depUser.CreatedAt = DateTime.Now;
return await Orm.Insert(depUser).ExecuteAffrowsAsync() > 0;
}
public async Task<bool> RemoveAsync(long depId, long userId)
=> await Orm.Delete<DepartmentUser>()
.Where(x => x.DepartmentId == depId && x.UserId == userId)
.ExecuteAffrowsAsync() > 0;
}
@@ -0,0 +1,38 @@
using FreeSql;
using F9WebAiTest.Domain.Entities.SYS.Departments;
using F9WebAiTest.Domain.Interfaces.SYS.Departments;
namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Departments;
internal class DepartmentWriteRepository : F9RepositoryBase, IDepartmentWriteRepository
{
public DepartmentWriteRepository(IFreeSql fsql) : base(fsql) { }
public async Task<Department> GetByIdAsync(long id, CancellationToken cancellationToken)
=> await Orm.Select<Department>().Where(x => x.Id == id ).FirstAsync(cancellationToken);
public async Task<bool> AddAsync(Department dep)
{
dep.CreatedAt = DateTime.Now;
return await Orm.Insert(dep).ExecuteAffrowsAsync() > 0;
}
public async Task<bool> UpdateAsync(Department dep)
{
dep.UpdatedAt = DateTime.Now;
return await Orm.Update<Department>().SetSource(dep).ExecuteAffrowsAsync() > 0;
}
public async Task<bool> SoftDeleteAsync(long id)
=> await Orm.Update<Department>()
.Set(x => x.IsDeleted, true)
.Where(x => x.Id == id )
.ExecuteAffrowsAsync() > 0;
public async Task<bool> ActiveOrDeactive(long id, bool active)
=> await Orm.Update<Department>()
.Set(x => x.IsActive, active)
.Set(x => x.UpdatedAt, DateTime.Now)
.Where(x => x.Id == id)
.ExecuteAffrowsAsync() > 0;
}