Files
f9-web-ai-test/backend/F9WebAiTest.Infrastructure/FreeSqls/Repositories/SYS/Departments/DepartmentWriteRepository.cs
T
yanpeng200212 a8890c81e9 新增质量模块(工艺执行书 / 样茧试缫)与报表中心
质量模块:
- 11 张工艺执行书表:封面、试产、选剥茧(含混茧明细)、试缫与大样、煮茧(含分车间配温、副煮车间)、自动缫(含大样)、后缫
- 10 张样茧试缫表:原料小样/综合样主表 + 选茧、解舒、茧幅、切剖、清洁洁净、茧丝百回纤度
- 服务与接口、主控指针回写(列表 √ 标记)、封面编号自增、报表数据包
- 前端 8 张报表打印版式、7 类工艺单据与 6 类调查录入弹窗、字段驱动表单/表格组件
- 菜单种子新增「质量」目录,样茧子表增加 YjssType 判别列,避免原料小样与综合样自增 Id 重号串数据

报表中心:
- 报表模板管理、锐浪 grhtml5 加载与预览、全屏设计面板、数据源 Provider(落丝记录、职工花名册)

其他:同步工作进度 1-11 文档、开发数据库快照、.gitignore 忽略运行日志目录
2026-10-22 10:30:37 +08:00

43 lines
1.6 KiB
C#

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;
// 编辑只覆盖业务字段:启用/禁用有独立命令,不能被 SetSource 连带重置;创建信息与删除标记同理
return await Orm.Update<Department>()
.SetSource(dep)
.IgnoreColumns(x => new { x.IsActive, x.IsDeleted, x.CreatedAt, x.CreatedBy })
.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;
}