服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-12-06 9719a7f0ccbb70e4e51a93cbe1733d1424c16f6d
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
using Rhea.Common;
using Microsoft.AspNetCore.Mvc;
using System;
using Tiger.IBusiness;
using System.Linq;
using System.Threading.Tasks;
using Tiger.Api.DbCache;
 
namespace Tiger.Api.Controllers.Base
{
    public partial class CacheController : ControllerBase
    {
        /// <summary>
        /// GetSysParam(ApiAction(Data:PARAM_CODE))
        /// 根据系统参数代码返回系统参数对象
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> GetSysParam([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(Cache.SysParam[action.Data?.ToString() ?? ""]);
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
 
        /// <summary>
        /// GetSysParamGroup(ApiAction(Data:PRMG_CODE))
        /// 根据系统参数组代码返回系统参数组对象
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> GetSysParamGroup([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(Cache.SysParam.Groups.FirstOrDefault(q => q.PRMG_CODE == (action.Data?.ToString() ?? "")));
            }
            catch (Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
 
        /// <summary>
        /// GetSysParamType(ApiAction(Data:PRMG_TYPE))
        /// 根据系统参数组类型返回系统参数组列表
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> GetSysParamType([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(Cache.SysParam.Groups.Where(q => q.PRMG_TYPE == (action.Data?.ToString() ?? "")).ToList());
            }
            catch (Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}