Beispiel #1
0
        public IActionResult AddLogic(InterfaceAggregation entity)
        {
            ViewData["InterfaceFields"]  = interfaceFieldService.GetEntitiesUnDeletedByMetaObjectId(CurrentMetaObjectId);
            ViewData["SearchConditions"] = searchConditionService.GetEntitiesUnDeletedByMetaObjectId(CurrentMetaObjectId);

            if (string.IsNullOrEmpty(entity.Name))
            {
                return(View("Add", ResponseModel.Error("名称不能为空", entity)));
            }
            if (string.IsNullOrEmpty(entity.Code))
            {
                return(View("Add", ResponseModel.Error("编码不能为空", entity)));
            }

            //校验code格式
            if (!entity.Code.IsAlnum(2, 50))
            {
                return(View("Add", ResponseModel.Error("编码不合法,2-50位且只能包含字母和数字(字母开头)", entity)));
            }

            //检查编码或名称重复
            var checkResult = interfaceAggregationService.CheckSameCodeOrName(CurrentMetaObjectId, entity);

            if (!checkResult.IsSuccess)
            {
                return(View("Add", checkResult.ToResponseModel()));
            }

            if (entity.InterfaceType == (int)InterfaceType.TriggerScriptDataSource)
            {
                if (string.IsNullOrEmpty(entity.Script))
                {
                    return(View("Add", ResponseModel.Error("触发器脚本不能为空", entity)));
                }
            }
            else
            {
                if (entity.FieldListId == default(int))
                {
                    return(View("Add", ResponseModel.Error("接口字段不能为空", entity)));
                }
                if (entity.SearchConditionId == default(int))
                {
                    return(View("Add", ResponseModel.Error("条件不能为空", entity)));
                }
            }

            entity.MetaObjectId = CurrentMetaObjectId;
            //组合编码
            entity.Code = $"{CurrentMetaObjectCode}.Interface.{entity.Code}";
            interfaceAggregationService.Add(entity);

            return(RedirectToAction("List"));
        }
Beispiel #2
0
        public IActionResult AddLogic(InterfaceAggregation entity)
        {
            SetDataSource();

            if (string.IsNullOrEmpty(entity.Name))
            {
                return(View("Add", ResponseModel.Error("名称不能为空", entity)));
            }
            if (string.IsNullOrEmpty(entity.Code))
            {
                return(View("Add", ResponseModel.Error("编码不能为空", entity)));
            }

            //校验code格式
            if (!entity.Code.IsAlnum(2, 50))
            {
                return(View("Add", ResponseModel.Error("编码不合法,2-50位且只能包含字母和数字(字母开头)", entity)));
            }

            string tempCode = entity.Code;

            entity.MetaObjectId = CurrentMetaObjectId;
            entity.Code         = $"{CurrentMetaObjectCode}.Interface.{entity.Code}";
            //检查编码或名称重复
            var checkResult = interfaceAggregationService.CheckSameCodeOrName(CurrentMetaObjectId, entity);

            if (!checkResult.IsSuccess)
            {
                entity.Code = tempCode;
                return(View("Add", checkResult.ToResponseModel()));
            }

            entity.CreateBy = CurrentUserId;
            interfaceAggregationService.Add(entity);

            return(RedirectToAction("List"));
        }