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)); }