using System.Data;
using System.Threading.Tasks;
using Znyc.Admin.Commons.Dtos;
using Znyc.Admin.Commons.Mapping;
using Znyc.Admin.Commons.Pages;
using Znyc.Admin.Commons.Services;
using Znyc.Admin.Security.Dtos;
using Znyc.Admin.Security.Entitys;
using Znyc.Admin.Security.IRepositories;
using Znyc.Admin.Security.IServices;
namespace Znyc.Admin.Security.Services
{
///
///
///
public class UploadFileService : BaseService, IUploadFileService
{
private readonly IUploadFileRepository _uploadFileRepository;
public UploadFileService(IUploadFileRepository repository) : base(repository)
{
_uploadFileRepository = repository;
}
///
/// 根据应用Id和应用标识批量更新数据
///
/// 应用Id
/// 更新前旧的应用Id
/// 应用标识
///
///
public bool UpdateByBeLongAppId(string beLongAppId, string oldBeLongAppId, string belongApp = null,
IDbTransaction trans = null)
{
return _uploadFileRepository.UpdateByBeLongAppId(beLongAppId, oldBeLongAppId, belongApp, trans);
}
///
/// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
///
/// 查询的条件
/// 指定对象的集合
public override async Task> FindWithPagerAsync(
SearchInputDto search)
{
bool order = search.Order == "asc" ? false : true;
string where = GetDataPrivilege(false);
if (!string.IsNullOrEmpty(search.Keywords))
{
@where += string.Format(" and FileName like '%{0}%' ", search.Keywords);
};
PagerInfo pagerInfo = new PagerInfo
{
CurrenetPageIndex = search.CurrenetPageIndex,
PageSize = search.PageSize
};
System.Collections.Generic.List list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);
PageResult pageResult = new PageResult
{
CurrentPage = pagerInfo.CurrenetPageIndex,
Items = list.MapTo(),
ItemsPerPage = pagerInfo.PageSize,
TotalItems = pagerInfo.RecordCount
};
return pageResult;
}
}
}