using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using SqlSugar;
using Tnb.Common.Contracts;
using Tnb.EquipMgr.Entities.Dto;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Utils;
using Mapster;
namespace Tnb.EquipMgr
{
public class BaseMoldMaintainService
{
private readonly ISqlSugarClient _db;
public BaseMoldMaintainService(ISqlSugarClient db)
{
_db = db;
}
///
/// 关联
///
/// 输入参数类型
/// 目标数据库表类型
/// 输入参数
/// 主表属性名称
/// 次表属性名称
/// 删除条件
///
///
protected async Task Relevance(TSrc input, string mColumnName, string name, Expression> deleleExp) where TDest : BaseEntity, new()
where TSrc : BaseMoldMaintainInput
{
await _db.Deleteable().Where(deleleExp).ExecuteCommandAsync();
if (input == null) throw new ArgumentNullException(nameof(input));
var entities = new List();
if (input.ids?.Count > 0)
{
foreach (var id in input.ids)
{
var pk = id;
TDest entity = new();
entity.id = SnowflakeIdHelper.NextId();
if (!PropertySet.ValueFactories.TryGetValue(mColumnName, out Action