namespace MiaoYu.Api.Admin.ApplicationServices.Systems;
///
/// 服务 SysDataAuthorityCustomService
///
public class SysDataAuthorityCustomService : ApplicationService>
{
public SysDataAuthorityCustomService(IRepository defaultRepository)
: base(defaultRepository)
{
}
///
/// 获取列表数据
///
/// page
///
public async Task FindListAsync(PagingSearchInput pagingSearchInput)
{
var query = _defaultRepository.Select
.OrderByDescending(w => w.CreationTime)
.Select(w => new
{
w.SysDataAuthorityId,
w.SysOrganizationId,
w.LastModificationTime,
w.CreationTime,
w.Id,
})
;
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"))
;
return result;
}
///
/// 根据id数组删除
///
/// ids
///
public async Task DeleteListAsync(List ids)
{
await _defaultRepository.DeleteByIdsAsync(ids);
}
///
/// 查询表单数据
///
/// id
///
public async Task> FindFormAsync(Guid id)
{
var res = new Dictionary();
var form = await _defaultRepository.FindByIdAsync(id);
form = form.NullSafe();
res[nameof(id)] = id == Guid.Empty ? "" : id;
res[nameof(form)] = form;
return res;
}
///
/// 保存数据
///
/// form
///
public async Task SaveFormAsync(SysDataAuthorityCustom form)
{
await _defaultRepository.InsertOrUpdateAsync(form);
}
///
/// 导出Excel
///
///
///
public async Task ExportExcelAsync(PagingSearchInput pagingSearchInput)
{
pagingSearchInput.Page = -1;
var tableViewModel = await FindListAsync(pagingSearchInput);
return ExcelUtil.ExportExcelByPagingView(tableViewModel, null, "Id");
}
}