using Hotline.Caching.Interfaces;
using Hotline.FlowEngine;
using Hotline.Repository.SqlSugar.Extensions;
using Hotline.Settings;
using Hotline.Settings.Hotspots;
using Hotline.Settings.TimeLimits;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.Hotspots;
using Hotline.Share.Dtos.Settings;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using MapsterMapper;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using StackExchange.Redis;
using XF.Domain.Exceptions;
using XF.Domain.Repository;
using XF.Utility.EnumExtensions;
namespace Hotline.Api.Controllers
{
///
/// 热点
///
public class HotspotController : BaseController
{
private readonly IRepository _hotspotTypeRepository;
private readonly IMapper _mapper;
private readonly ITimeLimitDomainService _timeLimitDomainService;
private readonly ITimeLimitRepository _timeLimitRepository;
private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
private readonly IEventCategoryRepository _eventCategoryRepository;
public HotspotController(IRepository hotspotTypeRepository,
IMapper mapper, ITimeLimitDomainService timeLimitDomainService, ITimeLimitRepository timeLimitRepository, ISystemDicDataCacheManager sysDicDataCacheManager, IEventCategoryRepository eventCategoryRepository)
{
_hotspotTypeRepository = hotspotTypeRepository;
_mapper = mapper;
_timeLimitDomainService = timeLimitDomainService;
_timeLimitRepository = timeLimitRepository;
_sysDicDataCacheManager = sysDicDataCacheManager;
_eventCategoryRepository = eventCategoryRepository;
}
#region 热点
///
/// 查询子项
///
[HttpGet("children")]
public async Task> GetChildren([FromQuery] string? id)
{
var list = await _hotspotTypeRepository.Queryable()
.WhereIF(!string.IsNullOrEmpty(id), x => x.ParentId == id)
.WhereIF(string.IsNullOrEmpty(id), x => x.ParentId == null || x.ParentId == "")
.OrderBy(d => d.HotSpotName)
.Select(x=> new Hotspot
{
Id = x.Id,
HotSpotName = x.HotSpotName,
ParentId = x.ParentId,
HotSpotFullName = x.HotSpotFullName,
ProvinceCode = x.ProvinceCode,
HasChild = SqlFunc.Subqueryable().Where(d=>d.ParentId == x.Id).NotAny(),
}).ToListAsync();
return list;
}
///
/// 名称检索热点树形
///
///
///
[HttpGet("children-hasname")]
public async Task> GetChildrenHasName([FromQuery]string name)
{
var arr = _hotspotTypeRepository.Queryable()
.WhereIF(!string.IsNullOrEmpty(name), x => x.HotSpotName.Contains(name)).Select(x=>x.Id).ToList().Cast