You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Tiobon.Web.Core/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs

47 lines
1.6 KiB

using Tiobon.Core.IServices;
using Tiobon.Core.Model.Models;
using Tiobon.Core.Services.BASE;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Common;
using Tiobon.Core.Model;
using AgileObjects.AgileMapper;
using Tiobon.Core.Common.Caches;
namespace Tiobon.Core.Services;
/// <summary>
/// Ghre_Course (服务)
/// </summary>
public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, InsertGhre_CourseInput, EditGhre_CourseInput>, IGhre_CourseServices
{
private readonly IBaseRepository<Ghre_Course> _dal;
private IGhre_CourseClassServices _ghre_CourseClassServices;
public Ghre_CourseServices(IBaseRepository<Ghre_Course> dal,
ICaching caching,
IGhre_CourseClassServices ghre_CourseClassServices)
{
this._dal = dal;
base.BaseDal = dal;
_ghre_CourseClassServices = ghre_CourseClassServices;
base._caching = caching;
}
public override async Task<ServicePageResult<Ghre_CourseDto>> QueryFilterPage(QueryBody body)
{
var data = await BaseDal.QueryFilterPage(body);
var list = Mapper.Map(data.result.DT_TableDataT1).ToANew<List<Ghre_CourseDto>>();
var classIds = list.Select(x => x.CourseClassId).Distinct().ToList();
var classs = await _ghre_CourseClassServices.Query(x => classIds.Contains(x.Id));
list.ForEach(x =>
{
if (x.CourseClassId != null)
x.CourseClassName = classs.FirstOrDefault(o => o.Id == x.CourseClassId)?.ClassName;
});
return new ServicePageResult<Ghre_CourseDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, list);
}
}