示例#1
0
        public IActionResult EditStreamSolutionRule([FromBody] StreamSolutionRuleCreateDataModel 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 n = applyAuditStreamServices.GetRule(model.Id);

            if (n == null)
            {
                return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolutionRule.NotExist));
            }
            // 判断新增实体的权限
            var result = CheckPermission(auditUser, n.ToDtoModel(), model.CompanyRegion, n.RegionOnCompany);

            if (result.Status != 0)
            {
                return(new JsonResult(result));
            }

            ApplyAuditStream solution = applyAuditStreamServices.EditSolution(model.SolutionName);

            if (solution == null)
            {
                return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolution.NotExist));
            }
            // 判断所需方案的权限
            result = CheckPermission(auditUser, null, solution.RegionOnCompany, solution.RegionOnCompany);
            if (result.Status != 0)
            {
                return(new JsonResult(result));
            }

            model.Filter.ToModel <ApplyAuditStreamSolutionRule>().ToApplyAuditStreamSolutionRule(n);
            n.Description     = model.Description;
            n.Create          = n.Create;
            n.Priority        = model.Priority;
            n.Solution        = solution;
            n.Enable          = model.Enable;
            n.EntityType      = model.EntityType;
            n.Name            = model.Name;
            n.RegionOnCompany = model.CompanyRegion;
            context.ApplyAuditStreamSolutionRules.Update(n);
            context.SaveChanges();
            return(new JsonResult(ActionStatusMessage.Success));
        }
示例#2
0
        public IActionResult AddStreamSolutionRule([FromBody] StreamSolutionRuleCreateDataModel 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));
                }
            }

            ApplyAuditStreamSolutionRule checkExist = applyAuditStreamServices.EditSolutionRule(model.Name);

            if (checkExist != null)
            {
                return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolutionRule.AlreadyExist));
            }

            // 判断新增实体的权限
            var result = CheckPermission(auditUser, model.Filter, model.CompanyRegion, model.CompanyRegion);

            if (result.Status != 0)
            {
                return(new JsonResult(result));
            }

            ApplyAuditStream solution = applyAuditStreamServices.EditSolution(model.SolutionName);

            if (solution == null)
            {
                return(new JsonResult(ActionStatusMessage.ApplyMessage.AuditStreamMessage.StreamSolution.NotExist));
            }
            // 判断所需要调用的方案的权限
            result = CheckPermission(auditUser, null, solution.RegionOnCompany, solution.RegionOnCompany);
            if (result.Status != 0)
            {
                return(new JsonResult(result));
            }

            var r = applyAuditStreamServices.NewSolutionRule(solution, model.Filter.ToModel <BaseMembersFilter>(), model.Name, model.CompanyRegion, model.Description, model.Priority, model.Enable, model.EntityType);

            return(new JsonResult(ActionStatusMessage.Success));
        }