using Microsoft.AspNetCore.Mvc; using System.Net; using System.Net.Http.Headers; using Microsoft.Extensions.Hosting.Internal; using Microsoft.AspNetCore.Http.Extensions; using IStation.Untity; using Furion.DynamicApiController; using System.ComponentModel.DataAnnotations; using Mapster; using Microsoft.AspNetCore.Authorization; namespace IStation.Application { /// /// Station /// [Route("Main/Station/Logic")] [ApiDescriptionSettings("Main", Name = "泵站(业务)", Order = 899)] public class Station_LogicController : IDynamicApiController { /// /// 通过 ID 获取详细 /// [Route("GetDetailByID@V1.0")] [HttpGet] public StationDetailLogicDto GetDetailByID([FromQuery][Required] IDUnderCorpInput input) { var model = new Service.Station().GetByID(input.CorpID,input.ID); return model==null?null:new StationDetailLogicDto(model); } /// /// 通过 ID 获取详细(不需验证token) /// [AllowAnonymous] [Route("GetDetailByID@V1.1")] [HttpGet] public StationDetailLogicDto GetDetailByIDWithOutToken([FromQuery][Required] IDUnderCorpInput input) { var model = new Service.Station().GetByID(input.CorpID, input.ID); return model == null ? null : new StationDetailLogicDto(model); } /// /// 获取关注列表 /// [Route("GetAttentionList@V1.0")] [HttpGet] public List GetAttentionList() { var userId = UserManager.UserID; var cacheKey = $"Main_Station_Logic_GetAttentionList_{userId}"; var vmList = MemoryCacheHelper.GetSet(cacheKey, () => { var attentionList = new Service.UserAttention().GetByUserIDAndObjectType(UserManager.UserID, IStation.ObjectType.Station); if (attentionList == null || attentionList.Count < 1) return default; var stationService = new Service.Station(); var vmCacheList = new List(); foreach (var attention in attentionList) { var station = stationService.GetByID(attention.CorpID, attention.ObjectID); if (station != null && station.UseStatus == Model.eUseStatus.Enable) { var vmCache = new StationAttentionLogicDto(station); vmCacheList.Add(vmCache); } } return vmCacheList; }, CacheHelper.CacheLevel1); return vmList; } } }