public IActionResult AddStreamSolution([FromBody] StreamSolutionCreateDataModel model) { var auditUser = currentUserService.CurrentUser; if (model.Auth?.AuthByUserID != null && auditUser?.Id != model.Auth?.AuthByUserID) { if (model.Auth.Verify(googleAuthService, currentUserService.CurrentUser?.Id)) { auditUser = usersService.GetById(model.Auth.AuthByUserID); } else { return(new JsonResult(ActionStatusMessage.Account.Auth.AuthCode.Invalid)); } } var checkExist = applyAuditStreamServices.EditSolution(model.Name); if (checkExist != null) { return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolution.AlreadyExist)); } var list = new List <ApplyAuditStreamNodeAction>(); var errorList = new StringBuilder(); foreach (var node in model.Nodes) { applyAuditStreamServices.EditNode(node, (n) => { if (n == null) { ModelState.AddModelError(node, "节点不存在"); } else { list.Add(n); } return(false); }); } // 检查新增实体权限 var result = CheckPermission(auditUser, null, model.CompanyRegion, model.CompanyRegion); if (result.Status != 0) { return(new JsonResult(result)); } // 检查每个节点权限 result = CheckPermissionNodes(auditUser, list); if (result.Status != 0) { return(new JsonResult(result)); } if (!ModelState.IsValid) { return(new JsonResult(new ModelStateExceptionViewModel(ModelState))); } var r = applyAuditStreamServices.NewSolution(list, model.Name, model.CompanyRegion, model.Description); return(new JsonResult(ActionStatusMessage.Success)); }
public IActionResult EditStreamSolution([FromBody] StreamSolutionCreateDataModel model) { var auditUser = currentUserService.CurrentUser; if (model.Auth?.AuthByUserID != null && auditUser?.Id != model.Auth?.AuthByUserID) { if (model.Auth.Verify(googleAuthService, currentUserService.CurrentUser?.Id)) { auditUser = usersService.GetById(model.Auth.AuthByUserID); } else { return(new JsonResult(ActionStatusMessage.Account.Auth.AuthCode.Invalid)); } } var node = applyAuditStreamServices.GetSolution(model.Id); if (node == null) { return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolution.NotExist)); } var result = CheckPermission(auditUser, null, model.CompanyRegion, node.RegionOnCompany); if (result.Status != 0) { return(new JsonResult(result)); } var list = new List <ApplyAuditStreamNodeAction>(); var errorList = new StringBuilder(); foreach (var no in model.Nodes) { applyAuditStreamServices.EditNode(no, (n) => { if (n == null) { ModelState.AddModelError("节点列表", $"节点{no}不存在"); } else { list.Add(n); } return(false); }); } if (!ModelState.IsValid) { return(new JsonResult(new ModelStateExceptionViewModel(ModelState))); } // 检查每个节点权限 result = CheckPermissionNodes(auditUser, list); if (result.Status != 0) { return(new JsonResult(result)); } node.Description = model.Description; node.Nodes = string.Join("##", list.Select(i => i.Name).ToArray()); node.Name = model.Name; node.RegionOnCompany = model.CompanyRegion; context.ApplyAuditStreams.Update(node); context.SaveChanges(); return(new JsonResult(ActionStatusMessage.Success)); }