using MiaoYu.Repository.ChatAI.Admin.Entities.Apps; namespace MiaoYu.Api.Admin.ApplicationServices.Apps; /// /// 验证码表 服务 T_Verification_CodeService /// public class T_Verification_CodeService : ApplicationService> { public T_Verification_CodeService(IRepository defaultRepository) : base(defaultRepository) { } /// /// 获取列表数据 /// /// /// public async Task FindListAsync(PagingSearchInput pagingSearchInput) { var query = this._defaultRepository.Select //项目 .WhereIf(pagingSearchInput.Search?.TenantId!=null, w => w.TenantId==pagingSearchInput.Search.TenantId) .OrderByDescending(w => w.Id) .Select(w => new { w.Id, w.Key,w.Code,w.CreateDay,w.ExpireAt,w.CreateAt,w.Remarks,w.TenantId,w.VerificationType, // 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(w => w.Name!); return result; } /// /// 根据id数组删除 /// /// ids /// public async Task DeleteListAsync(List ids) { await this._defaultRepository.DeleteByIdsAsync(ids); } /// /// 查询表单数据 /// /// id /// public async Task> FindFormAsync(int id) { var res = new Dictionary(); var form = await this._defaultRepository.FindByIdAsync(id); form = form.NullSafe(); //if (form.CreateTime == null || form.CreateTime == DateTime.MinValue) //{ // form.CreateTime = DateTime.Now; //} //if (form.UpdateTime == null || form.UpdateTime == DateTime.MinValue) //{ // form.UpdateTime = DateTime.Now; //} res[nameof(id)] = id; res[nameof(form)] = form; return res; } /// /// 保存数据 /// /// form /// public Task SaveFormAsync(T_Verification_Code form) { return this._defaultRepository.InsertOrUpdateAsync(form); } /// /// 导出Excel /// /// /// public async Task ExportExcelAsync(PagingSearchInput pagingSearchInput) { pagingSearchInput.Page = -1; var tableViewModel = await this.FindListAsync(pagingSearchInput); return ExcelUtil.ExportExcelByPagingView(tableViewModel, null, "Id"); } }