IMapCacheService.cs 2.65 KB
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Rcs.Application.Services
{
    /// <summary>
    /// 地图缓存服务接口 - 负责地图数据的Redis缓存操作
    /// @author zzy
    /// </summary>
    public interface IMapCacheService
    {
        /// <summary>
        /// 从Redis获取地图完整数据(含节点、边、资源)
        /// @author zzy
        /// </summary>
        Task<MapCacheData?> GetMapAsync(Guid mapId);

        /// <summary>
        /// 获取所有地图ID列表
        /// @author zzy
        /// </summary>
        Task<IEnumerable<Guid>> GetAllMapIdsAsync();

        /// <summary>
        /// 通过节点编码快速查找节点ID
        /// @author zzy
        /// </summary>
        Task<Guid?> GetNodeIdByCodeAsync(Guid mapId, string nodeCode);

        /// <summary>
        /// 更新单个地图缓存
        /// @author zzy
        /// </summary>
        Task UpdateMapCacheAsync(Guid mapId);

        /// <summary>
        /// 删除地图缓存
        /// @author zzy
        /// </summary>
        Task RemoveMapCacheAsync(Guid mapId);
    }

    /// <summary>
    /// 地图缓存数据
    /// @author zzy
    /// </summary>
    public class MapCacheData
    {
        public Guid MapId { get; set; }
        public string MapCode { get; set; } = string.Empty;
        public string MapName { get; set; } = string.Empty;
        public int MapType { get; set; }
        public string Version { get; set; } = string.Empty;
        public bool Active { get; set; }
        public List<MapNodeCache> Nodes { get; set; } = new();
        public List<MapEdgeCache> Edges { get; set; } = new();
        public List<MapResourceCache> Resources { get; set; } = new();
    }

    public class MapNodeCache
    {
        public Guid NodeId { get; set; }
        public string NodeCode { get; set; } = string.Empty;
        public double X { get; set; }
        public double Y { get; set; }
        public double? Theta { get; set; }
        public int Type { get; set; }
        public bool Active { get; set; }
    }

    public class MapEdgeCache
    {
        public Guid EdgeId { get; set; }
        public string EdgeCode { get; set; } = string.Empty;
        public Guid FromNode { get; set; }
        public Guid ToNode { get; set; }
        public double Length { get; set; }
        public double? Cost { get; set; }
        public bool Active { get; set; }
    }

    public class MapResourceCache
    {
        public Guid ResourceId { get; set; }
        public string ResourceCode { get; set; } = string.Empty;
        public int Type { get; set; }
        public int? Capacity { get; set; }
    }
}