1
This commit is contained in:
@@ -26,10 +26,29 @@ namespace Tnb.EquipMgr
|
||||
public class ToolMoldMaintainRuleService : BaseMoldMaintainService, IToolMoldMaintainRuleService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager) : base(repository.AsSugarClient())
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository) : base(repository.AsSugarClient())
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据规则Id获取匹配的模具列表
|
||||
/// </summary>
|
||||
/// <param name="ruleId">规则Id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetListById([FromRoute] string ruleId)
|
||||
{
|
||||
var result = new List<MaintainRuleMoldListOutput>();
|
||||
var list = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(it => it.rule_id == ruleId).ToListAsync();
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
var ids = list.Select(it => it.mold_id).ToList();
|
||||
result = await _db.Queryable<ToolMolds>().Where(it => ids.Contains(it.id))
|
||||
.Select(it => new MaintainRuleMoldListOutput { mold_id = it.id }, true).ToListAsync();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联模具
|
||||
/// </summary>
|
||||
@@ -39,6 +58,16 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task RelevanceMold(RelevanceMoldInput input) =>
|
||||
await Relevance<RelevanceMoldInput, ToolMoldMaintainRuleRelation>(input, nameof(ToolMoldMaintainRuleRelation.rule_id), nameof(ToolMoldMaintainRuleRelation.mold_id), it => it.rule_id == input.rule_id);
|
||||
|
||||
/// <summary>
|
||||
/// 删除模具信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task DeleteMoldRelevance(RelevanceMoldInput input)
|
||||
{
|
||||
var row = await _db.Deleteable<ToolMoldMaintainRuleRelation>().Where(it => it.rule_id == input.rule_id && input.ids.Contains(it.mold_id)).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user