using MyCode.Project.Infrastructure;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace MyCode.Project.Generate.Template
{
public class BaseTemplate
{
///
/// 表名
///
private string _tableName;
///
/// 要保存的路径
///
protected string SavePath { get; set; }
///
/// 模板内容
///
protected string TemplateContent { get; set; }
public BaseTemplate(string tableName)
{
_tableName = tableName;
}
///
/// 根据原始表格名得到驼峰格式的
///
///
///
public string GetHumpTableName(string tableName)
{
var tableParts = tableName.Split('_');
var str = "";
foreach (var part in tableParts)
{
str += MyUtils.FirstCharToUpper(part);
}
return str;
}
///
/// 生成文件
///
public void CreateFile() {
if (!FileUtils.IsFileExists(SavePath))
{
FileUtils.CreateFile(SavePath, TemplateContent);
}
}
}
}