JavaScriptTemplateCode.cs 1.11 KB
using Hh.Mes.POJO.WebEntity.tool;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace Hh.Mes.T4
{
    public partial class JavaScriptTemplate
    {
        private readonly string AreaName;
        private readonly string ControllerName;
        private readonly Dictionary<string, string> Data;
        private readonly bool IsDetail;

        /// <summary>
        /// 初始化Js数据模板
        /// </summary>
        /// <param name="areaName">区域名称</param>
        /// <param name="tableName">表名</param>
        /// <param name="tableColumns">数据</param>
        public JavaScriptTemplate(string areaName, string tableName, List<TableColumnInfo> tableColumns)
        {
            AreaName = areaName;
            var str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(tableName);
            ControllerName = string.Join("", str.Split("_"));
            Data = tableColumns.ToDictionary(x => x.ColumnName, x => x.ColumnDescription);
            IsDetail = tableName.EndsWith("detail", System.StringComparison.OrdinalIgnoreCase);
        }
    }
}