wangzelong
2022-10-24 aa63fe28851c03c57d2df8c6be9deb32a86dc4e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
{
    /// <summary>
    /// Station
    /// </summary>
    [Route("Main/Station/Logic")]
    [ApiDescriptionSettings("Main", Name = "泵站(业务)", Order = 899)]
    public class Station_LogicController : IDynamicApiController 
    {
        /// <summary>
        /// 通过 ID 获取详细
        /// </summary>
        [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); 
        }
 
        /// <summary>
        /// 通过 ID 获取详细(不需验证token)
        /// </summary>
        [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);
        }
 
        /// <summary>
        /// 获取关注列表
        /// </summary>
        [Route("GetAttentionList@V1.0")]
        [HttpGet]
        public List<StationAttentionLogicDto> 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<StationAttentionLogicDto>();
                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;
 
        }
 
 
 
    }
}