using Mapster;
|
using Masuit.Tools;
|
using SqlSugar;
|
using System.ComponentModel.DataAnnotations;
|
using System.Linq.Expressions;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_DTO.Basic;
|
using WIDESEA_IOrderRepository;
|
|
namespace WIDESEA_StorageBasicService;
|
|
public class BoxingInfoService : ServiceBase<DtBoxingInfo, IBoxingInfoRepository>, IBoxingInfoService
|
{
|
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
public BoxingInfoService(IBoxingInfoRepository BaseDal,IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
|
{
|
_unitOfWorkManage = unitOfWorkManage;
|
}
|
public override PageGridData<DtBoxingInfo> GetPageData(PageDataOptions options)
|
{
|
string wheres = ValidatePageOptions(options);
|
//获取排序字段
|
Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
|
List<OrderByModel> orderByModels = new List<OrderByModel>();
|
foreach (var item in orderbyDic)
|
{
|
OrderByModel orderByModel = new()
|
{
|
FieldName = item.Key,
|
OrderByType = item.Value
|
};
|
orderByModels.Add(orderByModel);
|
}
|
|
|
int totalCount = 0;
|
List<SearchParameters> searchParametersList = new List<SearchParameters>();
|
if (!string.IsNullOrEmpty(options.Wheres))
|
{
|
try
|
{
|
searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
|
options.Filter = searchParametersList;
|
}
|
catch { }
|
}
|
var data = BaseDal.Db.Queryable<DtBoxingInfo>()
|
.Includes(x => x.BoxingInfoDetails)
|
.WhereIF(!wheres.IsNullOrEmpty(), wheres)
|
.OrderBy(orderByModels)
|
.ToPageList(options.Page, options.Rows, ref totalCount);
|
new PageGridData<DtBoxingInfo>(totalCount, data);
|
return new PageGridData<DtBoxingInfo>(totalCount, data);
|
}
|
}
|