コード例 #1
0
        public async Task <TData <object> > CodePreviewJson([FromForm] BaseConfigModel baseConfig)
        {
            var obj = new TData <object>();

            if (string.IsNullOrEmpty(baseConfig.OutputConfig.OutputModule))
            {
                obj.Message = "请选择输出到的模块";
                return(obj);
            }

            var objTable = await _databaseTableBLL.GetTableFieldList(baseConfig.TableName);

            var dt = DataTableHelper.ListToDataTable(objTable.Data); // 用DataTable类型,避免依赖

            var codeEntity      = _singleTableTemplate.BuildEntity(baseConfig, dt);
            var codeEntityParam = _singleTableTemplate.BuildEntityParam(baseConfig, dt);
            var codeService     = _singleTableTemplate.BuildService(baseConfig, dt);
            var codeBusiness    = _singleTableTemplate.BuildBusiness(baseConfig);
            var codeIService    = _singleTableTemplate.BuildIService(baseConfig, dt);
            var codeIBusiness   = _singleTableTemplate.BuildIBusiness(baseConfig);

            var codeController = _singleTableTemplate.BuildController(baseConfig);
            var codeIndex      = _singleTableTemplate.BuildIndex(baseConfig, dt);
            var codeForm       = _singleTableTemplate.BuildForm(baseConfig, dt);

            var json = new
            {
                CodeEntity      = HttpUtility.HtmlEncode(codeEntity),
                CodeEntityParam = HttpUtility.HtmlEncode(codeEntityParam),
                CodeService     = HttpUtility.HtmlEncode(codeService),
                CodeBusiness    = HttpUtility.HtmlEncode(codeBusiness),
                CodeIService    = HttpUtility.HtmlEncode(codeIService),
                CodeIBusiness   = HttpUtility.HtmlEncode(codeIBusiness),
                CodeController  = HttpUtility.HtmlEncode(codeController),
                CodeIndex       = HttpUtility.HtmlEncode(codeIndex),
                CodeForm        = HttpUtility.HtmlEncode(codeForm)
            };

            obj.Data = json;
            obj.Tag  = 1;

            return(obj);
        }
コード例 #2
0
        public async Task <IActionResult> CodePreviewJson(BaseConfigModel baseConfig)
        {
            TData <object> obj = new TData <object>();

            if (string.IsNullOrEmpty(baseConfig.OutputConfig.OutputModule))
            {
                obj.Message = "请选择输出到的模块";
            }
            else
            {
                SingleTableTemplate            template = new SingleTableTemplate();
                TData <List <TableFieldInfo> > objTable = await databaseTableBLL.GetTableFieldList(baseConfig.TableName);

                DataTable dt                 = DataTableHelper.ListToDataTable(objTable.Data); // 用DataTable类型,避免依赖
                string    codeEntity         = template.BuildEntity(baseConfig, dt);
                string    codePartialEntity  = template.BuildPartialEntity(baseConfig, dt);
                string    codeEntityParam    = template.BuildEntityParam(baseConfig);
                string    codeService        = template.BuildService(baseConfig, dt);
                string    codePartialService = template.BuildPartialService(baseConfig, dt);
                string    codeBusiness       = template.BuildBusiness(baseConfig);
                string    codeController     = template.BuildController(baseConfig);
                string    codeIndex          = template.BuildIndex(baseConfig);
                string    codeForm           = template.BuildForm(baseConfig);
                string    codeMenu           = template.BuildMenu(baseConfig);

                var json = new
                {
                    CodeEntity         = HttpUtility.HtmlEncode(codeEntity),
                    CodePartialEntity  = HttpUtility.HtmlEncode(codePartialEntity),
                    CodeEntityParam    = HttpUtility.HtmlEncode(codeEntityParam),
                    CodeService        = HttpUtility.HtmlEncode(codeService),
                    CodePartialService = HttpUtility.HtmlEncode(codePartialService),
                    CodeBusiness       = HttpUtility.HtmlEncode(codeBusiness),
                    CodeController     = HttpUtility.HtmlEncode(codeController),
                    CodeIndex          = HttpUtility.HtmlEncode(codeIndex),
                    CodeForm           = HttpUtility.HtmlEncode(codeForm),
                    CodeMenu           = HttpUtility.HtmlEncode(codeMenu)
                };
                obj.Data = json;
                obj.Tag  = 1;
            }
            return(Json(obj));
        }