74 lines
3.2 KiB
C#
74 lines
3.2 KiB
C#
using Cms.Core.Entity;
|
|
using Cms.Core.EntityFramework;
|
|
using Cms.Core.WebApi.Domain.Impl;
|
|
using Cms.Core.WebApi.Dtos;
|
|
using Cms.Core.WebApi.Services.Impl;
|
|
using DG.Core;
|
|
using DG.EntityFramework;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Cms.Core.WebApi.Services
|
|
{
|
|
internal class LiveService : ILiveService
|
|
{
|
|
private readonly IBaseRepository<DncmsbaseDbContext> _dncmsbaseRepository;
|
|
private readonly ICacheDomain _cacheDomain;
|
|
public LiveService(IBaseRepository<DncmsbaseDbContext> dncmsbaseRepository,
|
|
ICacheDomain cacheDomain)
|
|
{
|
|
_dncmsbaseRepository = dncmsbaseRepository;
|
|
_cacheDomain = cacheDomain;
|
|
}
|
|
|
|
public async Task<List<LiveDetailDto>> GetLiveDetails(LiveDetailSearchDto dto)
|
|
{
|
|
var query = from a in _dncmsbaseRepository.GetRepository<ZhiboSystemDiscussion>().Query()
|
|
join b in _dncmsbaseRepository.GetRepository<ZhiboSystemSchedules>().Query() on a.Scheduleid equals b.Id
|
|
join c in _dncmsbaseRepository.GetRepository<ZhiboSystemRoom>().Query() on a.Roomid equals c.Id
|
|
where a.Appid == dto.Appid && a.Appuserid == dto.Appuserid
|
|
select new LiveDetailDto
|
|
{
|
|
Id = a.Id,
|
|
Illegaltype = a.Illegaltype,
|
|
LiveTitle = c.Title,
|
|
Marketingtype = b.Marketingtype,
|
|
Msg = a.Msg,
|
|
Msgtime = a.Msgtime,
|
|
Msgtype = a.Msgtype,
|
|
SchedulesTitle = b.Title,
|
|
Roomid = a.Roomid,
|
|
Scheduleid = a.Scheduleid,
|
|
};
|
|
var data = await query.If(!string.IsNullOrEmpty(dto.Msg), x => x.Where(x => x.Msg.Contains(dto.Msg)))
|
|
.If(dto.Scheduleid.HasValue, x => x.Where(x => x.Scheduleid == dto.Scheduleid))
|
|
.If(dto.Roomid.HasValue, x => x.Where(x => x.Roomid == dto.Roomid))
|
|
.OrderByDescending(x => x.Msgtime)
|
|
.ToListAsync();
|
|
|
|
return data;
|
|
}
|
|
|
|
public async Task<List<SelectItem>> GetSchedules()
|
|
{
|
|
return await _dncmsbaseRepository.GetRepository<ZhiboSystemSchedules>().Query().Where(x => x.Status == 0)
|
|
.Select(x=>new SelectItem(x.Id, x.Title))
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<List<SelectItem>> GetRooms()
|
|
{
|
|
var deptments = await _cacheDomain.GetDeptments();
|
|
var data = await _dncmsbaseRepository.GetRepository<ZhiboSystemRoom>().Query().Where(x => x.Status == 0)
|
|
.ToListAsync();
|
|
var result = new List<SelectItem>();
|
|
foreach (var item in data)
|
|
{
|
|
var deptment = deptments.FirstOrDefault(x => x.Id == item.Deptid);
|
|
result.Add(new SelectItem(item.Id, !string.IsNullOrEmpty(deptment?.Title) ? $"{item.Title}({deptment?.Title} ID: {item.Id})" : item.Title));
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|