Example #1
0
        public static CodeGenerateDto GenerateDtoFromConfig(string val, out List <string> errors)
        {
            var result = new CodeGenerateDto();

            errors = new List <string>();
            var configDto = JsonConvert.DeserializeObject <CodeGenerateConfig>(val);

            result.BasePath       = configDto.BasePath.Trim('\\');
            result.Entities       = CodeGeneraterHelper.GenerateEntitiesModelFromTableModels(configDto, ref errors);
            result.Enums          = GenerateEnumModelFromConfig(configDto.Enums, ref errors);
            result.ExceptApis     = configDto.ExceptApis;
            result.ExceptServices = configDto.ExceptServices;
            return(result);
        }
Example #2
0
        public static VueFieldModel GenerateVueModelFromEntity(EntityFieldModel entityFieldModel)
        {
            var result = new VueFieldModel
            {
                Name    = ToCamel(entityFieldModel.Name),
                Comment = entityFieldModel.Comment,
            };

            if (CodeGeneraterHelper.IsEnumType(entityFieldModel))
            {
                result.Type      = "select";
                result.KeyValues = entityFieldModel.Type == "bool" ? "this.$enum.ETrueFalse" : $"this.$enum.{entityFieldModel.Type}s";
            }
            else
            {
                //支持:string,int,datetime,date,select,multiSelect,time
                switch (entityFieldModel.Type)
                {
                case "string":
                    result.Type = "string";
                    break;

                case "DateTime":
                    result.Type = "datetime";
                    break;

                case "int":
                    result.Type = "int";
                    break;

                default:
                    result.Type = "string";
                    break;
                }
            }
            return(result);
        }