Esempio n. 1
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, _model.Project.Code,
                                   $"src/UI/{_model.Project.WebUIDicName}/src/api/components");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name.FirstCharToLower()}.js");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 2
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, "src/Web/Controllers");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Controller.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 3
0
        public void Save()
        {
            var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Infrastructure/Repositories/SqlServer");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Repository.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 4
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Domain", _class.Name, "Models");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    _propertyList = classModel.ModelPropertyList
                                    .Where(m => m.ModelType == ModelType.Query).ToList();

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}QueryModel.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 5
0
 public EntityEnum(TemplateBuildModel model, ClassBuildModel @class, EnumBuildModel @enum)
 {
     _model  = model;
     _class  = @class;
     _prefix = model.Project.Prefix;
     _enum   = @enum;
 }
Esempio n. 6
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, "src/Library/Domain", _class.Name);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    _baseEntityName = _class.BaseEntityType.ToDescription();
                    if (_baseEntityName.Contains("Guid"))
                    {
                        _baseEntityName = _baseEntityName.Replace("<Guid>", "");
                    }

                    if (_baseEntityName.Contains("SoftDelete"))
                    {
                        _baseEntityName = _baseEntityName.Replace(">", ", Guid>");
                    }

                    _propertyList = _class.PropertyList ?? new List <PropertyBuildModel>();

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, _class.Name + "Entity.cs");
                    File.WriteAllText(filePath, content);

                    #region ==处理枚举==

                    foreach (var property in classModel.PropertyList)
                    {
                        if (property.Type == PropertyType.Enum && property.Enum != null && !_hasCreadedEnumList.Contains(property.Enum.Id))
                        {
                            var enumHandler  = new EntityEnum(_model, classModel, property.Enum);
                            var enumContent  = enumHandler.TransformText();
                            var enumFilePath = Path.Combine(dir, property.Enum.Name + ".cs");
                            File.WriteAllText(enumFilePath, enumContent);
                        }
                    }

                    #endregion
                }
            }
        }
Esempio n. 7
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class      = classModel;
                    _properties = _class.PropertyList.Where(m => m.ShowInList).ToList();
                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, $"src/UI/{_model.Project.WebUIDicName}/src/views", _class.Name.FirstCharToLower(), "index");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"cols.js");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 8
0
        public void Save()
        {
            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, "src/Library/Application", _class.Name + "Service");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, $"{_class.Name}Service.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }
        public void Save()
        {
            if (_model.Module.ClassList != null && _model.Module.ClassList.Any())
            {
                foreach (var classModel in _model.Module.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, $"src/UI/{_model.Module.WebUIDicName}/src/views", _class.Name.FirstCharToLower(), "index");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, "index.vue");
                    File.WriteAllText(filePath, content);
                }
            }
        }
Esempio n. 10
0
        public void Save()
        {
            if (_model.Project.ClassList != null && _model.Project.ClassList.Any())
            {
                foreach (var classModel in _model.Project.ClassList)
                {
                    _class = classModel;

                    var dir = Path.Combine(_model.RootPath, _model.Project.Code, "src/Library/Domain", _class.Name);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //清空
                    GenerationEnvironment.Clear();

                    var content = TransformText();

                    var filePath = Path.Combine(dir, _class.Name + "Entity.Extend.cs");
                    File.WriteAllText(filePath, content);
                }
            }
        }