模具组保养管理

This commit is contained in:
DEVICE8\12494
2023-05-17 18:31:22 +08:00
parent b12d91b48c
commit 4fa3124aea
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.EquipMgr.Entities.Dto
{
/// <summary>
/// 模具保养删除参数
/// </summary>
public class MoldMaintainDelInput : BaseInput
{
/// <summary>
/// 删除的表名
/// </summary>
public string table_name { get; set; }
}
}

View File

@@ -97,11 +97,34 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) =>
await Relevance<MoldMaintainGroupItemRelationInput, ToolMoldMaintainGroupRelation>(input, nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.item_group_id);
/// <summary>
/// 删除项目组与模具检查项信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task Delete(MoldMaintainDelInput input)
{
if (input.table_name == "item")
{
await Delete<ToolMoldMaintainGroupItem>(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.item_id));
}
else
{
await Delete<ToolMoldMaintainGroupRelation>(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.mold_id));
}
}
#endregion
private async Task Delete<T>(Expression<Func<T, bool>> deleteExp) where T : BaseEntity<string>, new()
{
await _db.Deleteable<T>().Where(deleteExp).ExecuteCommandAsync();
}
private async Task Relevance<TSrc, TDest>(TSrc input, string name, Expression<Func<TDest, bool>> deleleExp) where TDest : BaseEntity<string>, new()
where TSrc : BaseInput
{