Blame view

Hh.Mes.T4/ServiceTemplateCode.cs 1.48 KB
赖素文 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using Hh.Mes.POJO.WebEntity.tool;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace Hh.Mes.T4
{
    public partial class ServiceTemplate
    {
        private readonly string AreaName;
        private readonly string TableName;
        private readonly string ControllerName;
        private readonly List<TableColumnInfo> FilterColumns;
唐召明 authored
16
17
18
        private readonly string TableDescription;
        private readonly bool IsDetail;
        public ServiceTemplate(string areaName, string tableName, List<TableColumnInfo> tableColumns, string description, int filter = 3)
赖素文 authored
19
20
21
22
23
24
25
26
27
28
29
        {
            AreaName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(areaName);
            TableName = tableName;
            var str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(tableName);
            ControllerName = string.Join("", str.Split("_"));
            FilterColumns = tableColumns.Where(x => x.TypeName.Equals("string", StringComparison.OrdinalIgnoreCase)).Take(filter).ToList();
            var exp = Expressionable.Create<object>();
            foreach (var item in FilterColumns)
            {
                if (!string.IsNullOrWhiteSpace(item.ColumnName))
                {
唐召明 authored
30
                    exp.And(x => x.ToString().Contains(item.ColumnName));
赖素文 authored
31
32
                }
            }
唐召明 authored
33
34
            TableDescription = description;
            IsDetail = tableName.EndsWith("detail", System.StringComparison.OrdinalIgnoreCase);
赖素文 authored
35
36
37
        }
    }
}