コード例 #1
0
        /// <summary>
        /// 删除,需要先解除引用关系
        /// </summary>
        /// <param name="id"></param>
        public new ResultModel Delete(int id)
        {
            //先检查引用关系
            if (dbContext.QueryExist <FieldListAggregation>(t => t.MetaFieldId == id))
            {
                return(ResultModel.Error("字段列表存在相关字段的引用关系,请先解除引用关系"));
            }

            if (dbContext.QueryExist <SearchConditionAggregation>(t => t.FieldId == id))
            {
                return(ResultModel.Error("搜索条件存在相关字段的引用关系,请先解除引用关系"));
            }

            // ... 如果有其他引用字段的地方需要补充引用关系检查

            base.Delete(id);

            return(ResultModel.Success("删除成功"));
        }
 /// <summary>
 /// 根据id删除配置字段,校验是否被引用
 /// </summary>
 /// <param name="id"></param>
 public new ResultModel Delete(int id)
 {
     if (dbContext.QueryExist <InterfaceAggregation>(t => t.SearchConditionId == id))
     {
         //存在引用关系,先删除引用该数据的数据
         return(ResultModel.Error("存在引用关系,先删除引用该数据的数据"));
     }
     else
     {
         base.Delete(id);
         return(ResultModel.Success());
     }
 }
コード例 #3
0
        public new ResultModel Update(Application application)
        {
            if (dbContext.QueryExist <Application>(t => t.Id != application.Id && t.Name == application.Name))
            {
                return(ResultModel.Error("该名称已存在"));
            }

            var app = GetById(application.Id);

            if (app != null)
            {
                app.Name        = application.Name;
                app.Icon        = application.Icon;
                app.Group       = application.Group;
                app.SortNumber  = application.SortNumber;
                app.Description = application.Description;
                app.ModifyBy    = -1;
                app.ModifyTime  = DateTime.Now;

                base.Update(app);
            }
            return(ResultModel.Success());
        }
コード例 #4
0
 public bool ExistSameNameWithOtherIdByApplicationId(int applicationId, int id, string name)
 => dbContext.QueryExist <MetaObject>(t => t.ApplicationId != applicationId && t.Name.Equals(name) && t.Id != id);
コード例 #5
0
        //组织接口搜索条件
        public ResultModel AggregateCondition(int interfaceConditionId, int brotherNodeId, int conditionJointTypeId, int fieldId, int conditionTypeId, string conditionValue, int conditionValueTypeId)
        {
            //如果不是参数传递值,则根据传入的字段校验数据
            if (conditionValueTypeId != (int)ConditionValueType.Parameter)
            {
                if (!metaFieldService.CheckAndGetFieldValueByFieldType(fieldId, conditionValue).IsSuccess)
                {
                    return(ResultModel.Error("字段值和字段定义的类型不匹配"));
                }
            }

            return(TransactionHelper.Transaction(() =>
            {
                int parentId = brotherNodeId;
                //如果兄弟节点!=-1,说明当前树有值。反之,则构建新树
                if (parentId != -1)
                {
                    //判断是否有树存在
                    List <SearchConditionAggregation> conditionListExist = GetListBySearchConditionId(interfaceConditionId);
                    //查看当前兄弟节点的父节点id
                    SearchConditionAggregation brotherCondition = conditionListExist.FirstOrDefault(t => t.Id == brotherNodeId);
                    parentId = brotherCondition.ParentId;
                    //拿到父节点的信息
                    SearchConditionAggregation parentCondition = conditionListExist.FirstOrDefault(t => t.Id == brotherCondition.ParentId);
                    //如果父节点的连接条件和当前新建的条件一致,则不需要新建条件节点,直接附加在已有的条件下面
                    if (parentCondition == null || parentCondition.ConditionType != conditionJointTypeId)
                    {
                        //先添加一个父节点,然后把兄弟节点的父节点指向新建的父节点
                        string tempKey = DateTime.Now.ToString("yyyyMMddhhmmss");
                        SearchConditionAggregation newParentCondition = new SearchConditionAggregation
                        {
                            SearchConditionId = interfaceConditionId,
                            ParentId = conditionListExist.Count > 0 ? parentId : -1, //如果有树,则插入节点的父节点为刚才的兄弟节点的父节点,否则,插入-1作为根节点
                            FieldId = -1,                                            //连接节点没有field
                            FieldCode = "-1",
                            FieldName = tempKey,
                            ConditionType = conditionJointTypeId,
                            Name = EnumsTranslaterUseInProgram.Tran_ConditionJoint(conditionJointTypeId),
                            Value = "-1",
                            ValueType = -1
                        };
                        base.Add(newParentCondition);
                        //查询刚才插入的节点
                        newParentCondition = dbContext.QueryOne <SearchConditionAggregation>(t => t.FieldName.Contains(tempKey));

                        //将兄弟节点的父节点指向新插入的节点
                        brotherCondition.ParentId = newParentCondition.Id;
                        base.Update(brotherCondition);

                        //重新赋值parentId
                        parentId = newParentCondition.Id;
                    }
                }
                //检验是否没有条件节点
                if (parentId == -1)
                {
                    if (dbContext.QueryExist <SearchConditionAggregation>(t => t.Id == parentId))
                    {
                        return ResultModel.Error("已经存在条件节点,请查证后操作!");
                    }
                }
                //新增节点
                MetaField metaField = metaFieldService.GetById(fieldId);
                SearchConditionAggregation newCondition = new SearchConditionAggregation
                {
                    SearchConditionId = interfaceConditionId,
                    ParentId = parentId,
                    FieldId = fieldId,
                    FieldName = metaField.Name,
                    FieldCode = metaField.Code,
                    ConditionType = conditionTypeId,
                    Name = $"{metaField.Name} {EnumsTranslaterUseInProgram.Tran_ConditionType(conditionTypeId)} {conditionValue}",
                    Value = conditionValue,
                    ValueType = conditionValueTypeId
                };
                base.Add(newCondition);

                return ResultModel.Success("保存成功!");
            }));
        }