ServiceTemplateCode.cs
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
private readonly string TableDescription;
private readonly bool IsDetail;
public ServiceTemplate(string areaName, string tableName, List<TableColumnInfo> tableColumns, string description, int filter = 3)
{
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))
{
exp.And(x => x.ToString().Contains(item.ColumnName));
}
}
TableDescription = description;
IsDetail = tableName.EndsWith("detail", System.StringComparison.OrdinalIgnoreCase);
}
}
}