public Result SaveSetting(Guid metaObjectId, Guid interfaceFieldId, List <Guid> metaFieldIds)
        {
            if (metaFieldIds == null || !metaFieldIds.Any())
            {
                return(Result.Success());
            }

            //获取现在已经有的
            var currentList = _interfaceFieldsRepository.GetInterfaceFieldsByParentId(interfaceFieldId) ?? new List <InterfaceFields>(0);

            //删掉已经不包含的字段
            _interfaceFieldsRepository.BatchDelete(currentList.Where(t => !metaFieldIds.Contains(t.MetaFieldId)).Select(t => t.Id));

            //缓存当前已经存在的字段id集合
            var currentMetaFieldIds = currentList.Select(t => t.MetaFieldId).ToArray();

            //找出本次需要添加的字段
            var toAddIds = metaFieldIds.Where(t => !currentMetaFieldIds.Contains(t)).ToArray();

            if (!toAddIds.Any())
            {
                return(Result.Success());
            }

            //查询字段
            var fieldDic = _metaFieldRepository.GetMetaFieldIdDicByMetaObjectId(metaObjectId);

            var toAdds = toAddIds.Select(t => new InterfaceFields
            {
                Code                    = fieldDic.SafeGet(t)?.Code,
                Name                    = fieldDic.SafeGet(t)?.Name,
                ParentId                = interfaceFieldId,
                MetaFieldId             = t,
                MetaFieldShortCode      = fieldDic.SafeGet(t)?.ShortCode,
                MetaFieldCustomViewName = fieldDic.SafeGet(t)?.Name,
                MetaObjectId            = metaObjectId,
                CloudApplicationtId     = fieldDic.SafeGet(t)?.CloudApplicationtId ?? Guid.Empty
            });

            base.BatchAdd(toAdds);

            return(Result.Success());
        }
        public Result AddSortItem(InterfaceSort entity)
        {
            //查询字段
            var fieldDic = _metaFieldRepository.GetMetaFieldIdDicByMetaObjectId(entity.MetaObjectId);

            if (!fieldDic.ContainsKey(entity.MetaFieldId))
            {
                return(Result.Error("当前对象中不存在该字段"));
            }

            var metaField = fieldDic[entity.MetaFieldId];

            entity.Name = metaField.Name;
            //短编码重新赋值
            entity.MetaFieldShortCode = metaField.ShortCode;

            //校验是否已经存在了这个字段
            if (_repository.CheckMetaFieldShortCodeHasExistInCurrentSort(entity.ParentId, entity.MetaFieldShortCode))
            {
                return(Result.Error("已经存在一个该字段的规则了"));
            }

            return(base.Add(entity));
        }