public JsonResult CreateFile(SystemCodeGenerationCreateFileViewModel model)
        {
            OperateStatus operateStatus = new OperateStatus();

            try
            {
                SystemCodeGenerationBaseInput baseInput = model.Base.ToObject <SystemCodeGenerationBaseInput>();
                //实体
                FileUtil.WriteFile(baseInput.EntityPath + "\\" + baseInput.Entity + ".cs", model.Entities);
                //DataAccess接口
                FileUtil.WriteFile(baseInput.DataAccessInterfacePath + "\\" + baseInput.DataAccessInterface + ".cs", model.DataAccessInterface);
                //DataAccess实现
                FileUtil.WriteFile(baseInput.DataAccessPath + "\\" + baseInput.DataAccess + ".cs", model.DataAccess);
                //Business接口
                FileUtil.WriteFile(baseInput.BusinessInterfacePath + "\\" + baseInput.BusinessInterface + ".cs", model.BusinessInterface);
                //Business实现
                FileUtil.WriteFile(baseInput.BusinessPath + "\\" + baseInput.Business + ".cs", model.Business);
                //控制器
                FileUtil.WriteFile(baseInput.ControllerPath + "\\" + baseInput.Controller + ".cs", model.Controller);
                //控制器
                FileUtil.WriteFile(baseInput.ControllerPath.Replace("Controllers", "Views") + "\\" + baseInput.Controller.Replace("Controller", "") + "\\" + baseInput.List + ".cshtml", model.List);
                //表单
                FileUtil.WriteFile(baseInput.ControllerPath.Replace("Controllers", "Views") + "\\" + baseInput.Controller.Replace("Controller", "") + "\\" + baseInput.Edit + ".cshtml", model.Edit);
            }
            catch (Exception ex)
            {
                operateStatus.Message = ex.Message;
                return(Json(operateStatus));
            }
            operateStatus.Message    = "生成成功";
            operateStatus.ResultSign = ResultSign.Successful;
            return(Json(operateStatus));
        }
Example #2
0
        /// <summary>
        /// 生成编辑界面
        /// </summary>
        /// <param name="baseInput"></param>
        /// <param name="editInputs"></param>
        /// <returns></returns>
        private async Task <string> CreateEdit(SystemCodeGenerationBaseInput baseInput, IEnumerable <SystemCodeGenerationEditInput> editInputs)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath("/DataUsers/Templates/CodeGeneration/Edit.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpaceLower}}", baseInput.TableName.Split('_')[0].ToLower());
            returnContent = returnContent.Replace("{{NameSpace}}", baseInput.TableName.Split('_')[0]);
            //2:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", baseInput.TableName.Replace(baseInput.TableName.Split('_')[0], "").Replace("_", "").ToLower());
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", baseInput.Description);
            //4:类名称
            returnContent = returnContent.Replace("{{ClassName}}", baseInput.TableName.Replace("_", ""));
            //5:主键名称
            returnContent = returnContent.Replace("{{KeyName}}", baseInput.TableKey);
            //6:主体
            foreach (var edit in editInputs)
            {
                switch (edit.ControlType)
                {
                case EnumControlType.文本框:

                    break;
                }
            }
            return(returnContent);
        }
        /// <summary>
        /// 生成Logic接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private Task <string> CreteLogicInterface(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "ILogic.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            //4:是否分页
            if (input.IsPaging)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Task<PagedResults<{1}>> Paging{0}(QueryParam queryParam);", input.Name.Replace("_", ""), input.Name.Replace("_", ""));
                returnContent = returnContent.Replace("{{PagingAction}}", sb.ToString());
            }
            else
            {
                returnContent = returnContent.Replace("{{PagingAction}}", "");
            }
            //5:保存方法
            StringBuilder sbsa = new StringBuilder();

            sbsa.AppendFormat("    Task<OperateStatus> Save{0} ({1} input);", input.Name.Replace("_", ""), input.Name.Replace("_", ""));
            returnContent = returnContent.Replace("{{SaveAction}}", sbsa.ToString());
            return(Task.Factory.StartNew(() => returnContent));
        }
        /// <summary>
        ///     生成编辑页面
        /// </summary>
        /// <param name="input"></param>
        /// <param name="editInputs"></param>
        /// <returns></returns>
        private Task <string> CreateEdit(SystemCodeGenerationBaseInput input, IEnumerable <SystemCodeGenerationEditInput> editInputs)
        {
            var str = "";

            foreach (var item in editInputs)
            {
                if (item.ControlType == Domain.Models.Enums.EnumControlType.文本域)
                {
                    str += $@"  <div class='hr-line-dashed'></div>
                            <div class='form-group'>
                                <label class='col-sm-2 control-label'> {item.ControlName}:</label>
                                <div class='input-group  col-sm-10'>
                                      <textarea  rows='3' name='{item.ControlId}' id='{item.ControlId}' class='form-control'>< /textarea>
                                </div>
                            </div>";
                }
                else
                {
                    str += $@"  <div class='hr-line-dashed'></div>
                            <div class='form-group'>
                                <label class='col-sm-2 control-label'> {item.ControlName}:</label>
                                <div class='input-group  col-sm-10'>
                                    <input type='text' name='{item.ControlId}' id='{item.ControlId}' class='form-control input-sm' >
                                </div>
                            </div>";
                }
            }
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "Edit.txt"));

            //主体
            returnContent = returnContent.Replace("{{Body}}", str);
            return(Task.Factory.StartNew(() => returnContent));
        }
        /// <summary>
        /// 生成DataAccess接口实现
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string CreteDataAccess(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "Repository.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            //4:分页
            if (input.IsPaging)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine($" public Task<PagedResults<{input.Name.Replace("_", "")}>> Paging{input.Name.Replace("_", "")}(QueryParam queryParam)");
                sb.AppendLine("{");
                sb.AppendLine($" string sql=\"select * from {input.Name.Replace("System", "Sys")}\";");
                sb.AppendLine($" return SqlMapperUtil.PagingQuery<{input.Name.Replace("_", "")}>(sql, queryParam);");
                sb.AppendLine("}");
                returnContent = returnContent.Replace("{{PagingAction}}", sb.ToString());
            }
            else
            {
                returnContent = returnContent.Replace("{{PagingAction}}", "");
            }
            return(returnContent);
        }
Example #6
0
        /// <summary>
        /// 生成列表界面
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <string> CreateList(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath("/DataUsers/Templates/CodeGeneration/List.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.TableName.Split('_')[0].ToLower());
            //2:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", input.TableName.Replace(input.TableName.Split('_')[0], "").Replace("_", "").ToLower());
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Description);

            return(returnContent);
        }
Example #7
0
        /// <summary>
        /// 生成Logic接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <string> CreteLogicInterface(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath("/DataUsers/Templates/CodeGeneration/ILogic.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.TableName.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.TableName.Replace("_", ""));
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Description);

            return(returnContent);
        }
Example #8
0
        /// <summary>
        /// 生成编辑界面Js
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <string> CreateEditJs(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath("/DataUsers/Templates/CodeGeneration/EditJs.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.TableName.Split('_')[0]);
            //2:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", input.TableName.Replace(input.TableName.Split('_')[0], "").Replace("_", ""));
            //3:主键名称
            returnContent = returnContent.Replace("{{KeyName}}", input.TableKey);

            return(returnContent);
        }
        /// <summary>
        /// 生成控制器
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private Task <string> CreateController(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "Controller.txt"));

            //替换操作
            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //3:表名转换为小写
            returnContent = returnContent.Replace("{{ClassNameLower}}", input.Name.Replace("_", "").ReplaceFistLower());
            //4:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", input.Name.Replace(input.Name.Split('_')[0], "").Replace("_", ""));
            //5:分页方法
            if (input.IsPaging)
            {
                StringBuilder strPagingAction = new StringBuilder();
                strPagingAction.AppendLine("[HttpPost]");
                strPagingAction.AppendLine($"[Description(\"应用系统-方法-列表-获取{input.Value}分页信息\")]");
                strPagingAction.AppendLine($" public async Task<JsonResult> GetPaging{input.Name.Replace("_", "")}(QueryParam queryParam) ");
                strPagingAction.AppendLine("{");
                strPagingAction.AppendLine($"  return JsonForGridPaging(await _{input.Name.Replace("_", "").ReplaceFistLower()}Logic.Paging{input.Name.Replace("_", "")}(queryParam));");
                strPagingAction.AppendLine("}");
                returnContent = returnContent.Replace("{{PagingAction}}", strPagingAction.ToString());
            }
            else
            {
                returnContent = returnContent.Replace("{{PagingAction}}", "");
            }
            //6:保存方法
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("[HttpPost]");
            sb.AppendLine("   [ValidateAntiForgeryToken]");
            sb.AppendLine($"  [Description(\"应用系统-方法-保存{input.Value}\")]");
            sb.AppendLine($"    public async Task<JsonResult> Save{input.Name.Replace("_", "")}({input.Name.Replace("_", "")} input)");
            sb.AppendLine("{");
            sb.AppendLine($"   return Json(await _{input.Name.Replace("_", "").ReplaceFistLower()}Logic.Save{input.Name.Replace("_", "")}(input));");
            sb.AppendLine("}");
            returnContent = returnContent.Replace("{{SaveAction}}", sb.ToString());
            //描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);

            return(Task.Factory.StartNew(() => returnContent));;
        }
Example #10
0
        /// <summary>
        ///     生成实体
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <string> CreateEntity(SystemCodeGenerationBaseInput input)
        {
            //返回值
            var columnContent = new StringBuilder();
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath("/DataUsers/Templates/CodeGeneration/Entities.txt"));
            //获取对应列
            var columns = (await _dataBaseLogic.GetDataBaseColumns(input)).ToList();

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.TableName.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{TableName}}", input.TableName);
            //3:类名称
            returnContent = returnContent.Replace("{{ClassName}}", input.TableName.Replace("_", ""));
            //4:主键名称
            returnContent = returnContent.Replace("{{KeyName}}", input.TableKey);
            //5:动态生成列
            foreach (var column in columns.Where(column => column.ColumnName != input.TableKey))
            {
                columnContent.Append("        /// <summary>\r\n");
                columnContent.Append(string.Format("        /// {0}\r\n", column.ColumnDescription));
                columnContent.Append("        /// </summary>\r\n");
                columnContent.Append("        public " + ChangeToCSharpType(column.DataType) + " " + column.ColumnName + " { get; set; }\r\n\r\n");
            }
            //6:是否分页
            if (input.IsPaging)
            {
                columnContent.Append("        /// <summary>\r\n");
                columnContent.Append("        /// 记录总数\r\n");
                columnContent.Append("        /// </summary>\r\n");
                columnContent.Append("        /// [Column(IsInsert = false,IsUpdate = false,IsSelect = false,IsSort = false)]\r\n");
                columnContent.Append("        public int RecordCount { get; set; }\r\n");
            }
            returnContent = returnContent.Replace("{{EntitiesBody}}", columnContent.ToString());
            //7:主键类型
            var key = columns.Where(column => column.ColumnName == input.TableKey).FirstOrDefault();

            returnContent = returnContent.Replace("{{GenerationType}}", key != null && key.DataType == "uniqueidentifier" ? "GenerationType.Sequence" : "GenerationType.Indentity");
            //8:描述
            returnContent = returnContent.Replace("{{Description}}", input.Description);
            return(returnContent);
        }
        /// <summary>
        /// 生成列表界面
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string CreateList(SystemCodeGenerationBaseInput input, IEnumerable <SystemCodeGenerationListForListInput> listInput)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "List.txt"));

            //替换操作
            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0].ToLower());
            //2:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", input.Name.Replace(input.Name.Split('_')[0], "").Replace("_", "").ToLower());
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            //4:列表项
            returnContent = returnContent.Replace("{{ColModel}}", GetColModel(listInput.OrderBy(o => o.OrderNo).ToList(), input));
            //5:是否分页
            returnContent = returnContent.Replace("{{IsPaging}}", input.IsPaging.ToString().ToLower());
            return(returnContent);
        }
        /// <summary>
        ///     生成Logic接口实现
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private Task <string> CreateLogic(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "Logic.txt"));

            //替换操作
            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //3:表名转换为小写
            returnContent = returnContent.Replace("{{ClassNameLower}}", input.Name.Replace("_", "").ReplaceFistLower());
            //4:主键
            returnContent = returnContent.Replace("{{KeyName}}", input.TableKey);
            //5:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            //6:分页
            if (input.IsPaging)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine($" public Task<PagedResults<{input.Name.Replace("_", "")}>> Paging{input.Name.Replace("_", "")}(QueryParam queryParam)");
                sb.AppendLine("{");
                sb.AppendLine($" return  _{input.Name.Replace("_", "").ReplaceFistLower()}Repository.Paging{input.Name.Replace("_", "")}(queryParam);");
                sb.AppendLine("}");
                returnContent = returnContent.Replace("{{PagingAction}}", sb.ToString());
            }
            else
            {
                returnContent = returnContent.Replace("{{PagingAction}}", "");
            }
            //7:保存方法
            StringBuilder sbsa = new StringBuilder();

            sbsa.AppendLine($" public  Task<OperateStatus> Save{input.Name.Replace("_", "")} ({input.Name.Replace("_", "")} input) ");
            sbsa.AppendLine("{");
            sbsa.AppendLine($" input.{input.TableKey} = Guid.NewGuid().ToString();");
            sbsa.AppendLine(" return InsertAsync(input);");
            sbsa.AppendLine("}");
            returnContent = returnContent.Replace("{{SaveAction}}", sbsa.ToString());
            return(Task.Factory.StartNew(() => returnContent));
        }
Example #13
0
        /// <summary>
        /// 生成列表界面Js
        /// </summary>
        /// <param name="baseInput"></param>
        /// <param name="listInput"></param>
        /// <returns></returns>
        private async Task <string> CreateListJs(SystemCodeGenerationBaseInput baseInput,
                                                 IEnumerable <SystemCodeGenerationListForListInput> listInput)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Server.MapPath(baseInput.IsPaging ? "/DataUsers/Templates/CodeGeneration/ListJsPaging.txt" : "/DataUsers/Templates/CodeGeneration/ListJsLoadonce.txt"));

            //替换操作

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", baseInput.TableName.Split('_')[0]);
            //2:控制器名称
            returnContent = returnContent.Replace("{{ControllerName}}", baseInput.TableName.Replace(baseInput.TableName.Split('_')[0], "").Replace("_", ""));
            //3:主键名称
            returnContent = returnContent.Replace("{{KeyName}}", baseInput.TableKey);
            //4:列表项
            returnContent = returnContent.Replace("{{ColModel}}", GetColModel(listInput.OrderBy(o => o.OrderNo).ToList(), baseInput));
            //5:描述
            returnContent = returnContent.Replace("{{Description}}", baseInput.Description);
            //6:编辑框高
            returnContent = returnContent.Replace("{{EditHeight}}", baseInput.EditHeight == 0 ? "100%" : baseInput.EditHeight.ToString());
            //7:编辑框宽
            returnContent = returnContent.Replace("{{EditWidth}}", baseInput.EditWidth == 0 ? "100%" : baseInput.EditWidth.ToString());
            return(returnContent);
        }
        /// <summary>
        ///     生成DataAccess接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string CreateDataAccessInterface(SystemCodeGenerationBaseInput input)
        {
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "IRepository.txt"));

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //3:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            //4:分页信息
            if (input.IsPaging)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append($"Task<PagedResults<{input.Name.Replace("_", "")}>> Paging{input.Name.Replace("_", "")}(QueryParam queryParam);");
                returnContent = returnContent.Replace("{{PagingAction}}", sb.ToString());
            }
            else
            {
                returnContent = returnContent.Replace("{{PagingAction}}", "");
            }
            return(returnContent);
        }
        /// <summary>
        ///     生成实体
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <string> CreateEntity(SystemCodeGenerationBaseInput input)
        {
            //返回值
            var columnContent = new StringBuilder();
            //获取文件内容
            var returnContent = FileUtil.ReadFile(Path.Combine("DataUsers", "Templates", "CodeGeneration", "Entities.txt"));
            //获取对应列
            var columns = (await _dataBaseLogic.GetDataBaseColumn(new IdInput {
                Id = input.Name.Replace("System", "Sys")
            })).ToList();

            //1:命名空间
            returnContent = returnContent.Replace("{{NameSpace}}", input.Name.Split('_')[0]);
            //2:表名
            returnContent = returnContent.Replace("{{TableName}}", input.Name.Replace("System", "Sys"));
            //3:类名称
            returnContent = returnContent.Replace("{{ClassName}}", input.Name.Replace("_", ""));
            //4:主键名称
            returnContent = returnContent.Replace("{{KeyName}}", input.TableKey);
            //5:动态生成列
            foreach (var column in columns)
            {
                columnContent.Append("        /// <summary>\r\n");
                columnContent.Append(string.Format("        /// {0}\r\n", column.Remarks));
                columnContent.Append("        /// </summary>\r\n");
                columnContent.Append("        public " + ChangeToCSharpType(column.DataType) + " " + column.FieldName + " { get; set; }\r\n\r\n");
            }
            returnContent = returnContent.Replace("{{EntitiesBody}}", columnContent.ToString());
            //7:主键类型
            var key = columns.Where(column => column.FieldName == input.TableKey).FirstOrDefault();

            returnContent = returnContent.Replace("{{GenerationType}}", key != null && key.DataType == "uniqueidentifier" ? "GenerationType.Sequence" : "GenerationType.Indentity");
            //8:描述
            returnContent = returnContent.Replace("{{Description}}", input.Value);
            return(returnContent);
        }
Example #16
0
        /// <summary>
        ///     根据用户的字段权限拼接界面显示字段表达式
        /// </summary>
        /// <param name="listInput"></param>
        /// <param name="baseInput"></param>
        /// <returns>拼接后的表达式</returns>
        private string GetColModel(IList <SystemCodeGenerationListForListInput> listInput, SystemCodeGenerationBaseInput baseInput)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append("[\r\n");
            foreach (SystemCodeGenerationListForListInput input in listInput)
            {
                stringBuilder.Append("            {");

                stringBuilder.Append("name:\"" + input.Name + "\",");
                //是否隐藏
                if (!input.Hidden)
                {
                    stringBuilder.Append("label:\"" + input.Label + "\",");
                    //是否分页
                    if (baseInput.IsPaging)
                    {
                        if (!string.IsNullOrEmpty(input.Index))
                        {
                            stringBuilder.Append("index:\"" + input.Index + "\",");
                        }
                    }

                    //是否自适应
                    if (input.Fixed)
                    {
                        stringBuilder.Append("fixed:true,");
                    }
                    else
                    {
                        stringBuilder.Append("width:" + input.Width + ",");
                    }

                    //是否排序
                    if (input.Sortable)
                    {
                        if (!input.Sorttype.IsNullOrEmpty())
                        {
                            stringBuilder.Append("sorttype:\"" + input.Sorttype.ToLower() + "\",");
                        }
                    }
                    else
                    {
                        stringBuilder.Append("sortable:false,");
                    }

                    //对齐格式
                    if (input.Align.IsNullOrEmpty())
                    {
                        input.Align = EnumFieldAlign.Center.ToString().ToLower();
                    }

                    //格式化
                    if (!input.Formatter.IsNullOrEmpty())
                    {
                        stringBuilder.Append("align:\"" + input.Align + "\",");
                        stringBuilder.Append("formatter:\"" + input.Formatter + "\"},\r\n");
                    }
                    else
                    {
                        stringBuilder.Append("align:\"" + input.Align + "\"");
                        stringBuilder.Append(input == listInput.Last() ? "}\r\n" : "},\r\n");
                    }
                }
                else
                {
                    stringBuilder.Append("hidden:true");
                }
            }
            string returnStr = stringBuilder.ToString().TrimEnd(',');

            returnStr = returnStr + "        ]";
            return(returnStr);
        }
        /// <summary>
        ///     根据用户的字段权限拼接界面显示字段表达式
        /// </summary>
        /// <param name="listInput"></param>
        /// <param name="baseInput"></param>
        /// <returns>拼接后的表达式</returns>
        private string GetColModel(IList <SystemCodeGenerationListForListInput> listInput, SystemCodeGenerationBaseInput baseInput)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append("[\r\n");
            foreach (SystemCodeGenerationListForListInput input in listInput)
            {
                stringBuilder.Append("            {");

                if (!string.IsNullOrWhiteSpace(input.field))
                {
                    stringBuilder.Append("field:\"" + input.field.ReplaceFistLower() + "\",");
                }
                else
                {
                    stringBuilder.Append("field:\"" + input.field + "\",");
                }

                //是否隐藏
                if (input.Hidden)
                {
                    stringBuilder.Append("title:\"" + input.title + "\",");

                    stringBuilder.Append("width:" + input.Width + ",");
                    //是否排序
                    if (input.Sort)
                    {
                        stringBuilder.Append("sort:true,");
                    }
                    else
                    {
                        stringBuilder.Append("sort:false,");
                    }

                    //对齐格式
                    if (input.Align.IsNullOrEmpty())
                    {
                        input.Align = "center";
                    }

                    //格式化
                    if (!input.Formatter.IsNullOrEmpty())
                    {
                        stringBuilder.Append("align:\"" + input.Align + "\",");
                        stringBuilder.Append("formatter:\"" + input.Formatter + "\"},\r\n");
                    }
                    else
                    {
                        stringBuilder.Append("align:\"" + input.Align + "\"");
                        stringBuilder.Append(input == listInput.Last() ? "}\r\n" : "},\r\n");
                    }
                }
                else
                {
                    stringBuilder.Append("hidden:true},\r\n");
                }
            }
            string returnStr = stringBuilder.ToString().TrimEnd(',');

            returnStr = returnStr + "        ]";
            return(returnStr);
        }