92 lines
2.9 KiB
Plaintext
92 lines
2.9 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 searchKeyWords = new[] { "Title", "Name", "Phone", "Address", "Email" };
|
|
var searchKeyWord = string.Empty;
|
|
foreach (var item in searchKeyWords)
|
|
{
|
|
if (tableInfos.Any(w => w.ColumnName == item))
|
|
{
|
|
searchKeyWord = item;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
<pre>
|
|
using @(Model.Namespace).Repository.EntityFramework.Admin.Entities.Apps;
|
|
namespace @(Model.Namespace).Api.Admin.ApplicationServices.Apps;
|
|
|
|
/// <summary>
|
|
/// @(classNameRemark) 服务 @(className)Service
|
|
/// </summary>
|
|
public class @(className)Service(IServiceProvider serviceProvider)
|
|
: ApplicationService<@(className + ",Guid" + "," + className + "," + className)>(serviceProvider)
|
|
{
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="pagingSearchInput"></param>
|
|
/// <returns></returns>
|
|
public override async Task<@("PagingView")> FindListAsync(PagingSearchInput<@(className)> pagingSearchInput)
|
|
{
|
|
var query = this.Repository.SelectNoTracking
|
|
@if (!string.IsNullOrWhiteSpace(searchKeyWord))
|
|
{
|
|
<pre>.WhereIf(!string.IsNullOrWhiteSpace(pagingSearchInput.Search?.@(searchKeyWord)), w => w.@(searchKeyWord).Contains(pagingSearchInput.Search.@(searchKeyWord) ?? ""))</pre>
|
|
}
|
|
.OrderByDescending(w => w.CreationTime)
|
|
.Select(w => new
|
|
{
|
|
w.Id,
|
|
@(string.Join(',', tableInfos.Select(w => "w." + w.ColumnName)))@(",")
|
|
w.LastModificationTime,
|
|
w.CreationTime
|
|
})
|
|
;
|
|
|
|
var result = await _defaultRepository.AsPagingViewAsync(query, pagingSearchInput);
|
|
|
|
// 覆盖值
|
|
result
|
|
.FormatValue(query, w => w.CreationTime, (oldValue) => oldValue.ToString("yyyy-MM-dd"))
|
|
.FormatValue(query, w => w.LastModificationTime, (oldValue) => oldValue?.ToString("yyyy-MM-dd"))
|
|
;
|
|
|
|
// 设置列
|
|
//result.GetColumn(query, w => w.OperatorName).SetColumn("操作人");
|
|
//result.GetColumn(query, w => w.OperatorName!).SetColumn<@("SysUser")>(w => w.Name!);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
</pre> |