107 lines
3.4 KiB
Plaintext
107 lines
3.4 KiB
Plaintext
@model GenDbTableDto
|
|
@{
|
|
var className = Model.EntityName;
|
|
var classNameRemark = Model.DisplayName;
|
|
|
|
var ignores = new string[]
|
|
{
|
|
"Id",
|
|
"CreationTime",
|
|
"CreatorUserId",
|
|
"LastModificationTime",
|
|
"LastModifierUserId",
|
|
"DeletionTime",
|
|
"DeleterUserId",
|
|
"IsDeleted",
|
|
"id",
|
|
"creation_time",
|
|
"creator_user_id",
|
|
"last_modification_time",
|
|
"last_modifier_user_id" ,
|
|
"deletion_time",
|
|
"deleter_user_id",
|
|
"is_deleted",
|
|
};
|
|
|
|
var tableInfos = Model.TableInfos
|
|
.Where(w => !ignores.Contains(w.ColumnName))
|
|
.OrderBy(w => w.Position)
|
|
.ToList()
|
|
;
|
|
var dateList = Model.TableInfos.Where(w => w.CsType == "DateTime").OrderBy(w => w.Position).ToList();
|
|
var selectTable = Model.TableInfos.Where(it => it.IsTableSelect ?? false).ToList();
|
|
var searchKeyWords = new[] { "Title", "Name", "Phone", "Address", "Email" };
|
|
var searchKeyWord = string.Empty;
|
|
foreach (var item in searchKeyWords)
|
|
{
|
|
if (tableInfos.Any(w => w.ColumnName.Contains(item)))
|
|
{
|
|
searchKeyWord = item;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
<pre>
|
|
using @(Model.Namespace);
|
|
namespace @(Model.NamespacePrefix).Api.Admin.ApplicationServices.Apps.@(Model.DataBase);
|
|
|
|
/// <summary>
|
|
/// @(classNameRemark) 服务 @(className)Service
|
|
/// </summary>
|
|
public class @(className)Service(IServiceProvider serviceProvider)
|
|
: ApplicationGameService<@(className + ",int" + "," + className + "," + className)>(serviceProvider)
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="pagingSearchInput"></param>
|
|
/// <returns></returns>
|
|
public async override Task<@("PagingView")> FindListAsync(PagingSearchInput<@(className)> pagingSearchInput)
|
|
{
|
|
var query = this.Repository.Select
|
|
@foreach (var x in selectTable)
|
|
{
|
|
if (x.CsType == "Int32")
|
|
{
|
|
<pre>//@(x.DisplayName)
|
|
.WhereIf(pagingSearchInput.Search?.@(x.ColumnName)!=null&&pagingSearchInput.Search?.@(x.ColumnName)>0,
|
|
w => w.@(x.ColumnName)== pagingSearchInput.Search.@(x.ColumnName))</pre>
|
|
}
|
|
else
|
|
{
|
|
<pre>//@(x.DisplayName)
|
|
.WhereIf(!string.IsNullOrWhiteSpace(pagingSearchInput.Search?.@(x.ColumnName)),
|
|
w => w.@(x.ColumnName).Contains(pagingSearchInput.Search.@(x.ColumnName) ?? ""))</pre>
|
|
}
|
|
}
|
|
.OrderByDescending(w => w.Id)
|
|
.Select(w => new
|
|
{
|
|
w.Id,
|
|
@(string.Join(',', tableInfos.Select(w => "w." + w.ColumnName)))@(",")
|
|
})
|
|
;
|
|
var result = await Repository.AsPagingViewAsync(query, pagingSearchInput);
|
|
|
|
// 设置列
|
|
//result.GetColumn(query, w => w.OperatorName).SetColumn("操作人");
|
|
//result.GetColumn(query, w => w. !).SetColumn<@("SysUser")>(w => w.Name!);
|
|
@if (dateList != null && dateList.Count > 0)
|
|
{
|
|
<pre>
|
|
result
|
|
@foreach (var x in dateList)
|
|
{
|
|
<pre>.FormatValue(query, w => w.@(x.ColumnName), (oldValue) => oldValue.ToString("yyyy-MM-dd HH:mm:ss"))</pre>
|
|
}
|
|
;
|
|
</pre>
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
</pre> |