服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-12-08 006c12987d7dc7c2081fbf6715ebea98b93fdca0
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
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>
        /// GetMesDefect(ApiAction(Data:PARAM_CODE))
        /// 根据不良代码返回不良代码对象
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost("[action]")]
        public async Task<IActionResult> GetMesDefect([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(Cache.MesDefect[action.Data?.ToString() ?? ""]);
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
 
        /// <summary>
        /// GetMesDefectGroup(ApiAction(Data:DFTG_CODE))
        /// 根据不良代码组代码返回不良代码组对象
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost("[action]")]
        public async Task<IActionResult> GetMesDefectGroup([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(Cache.MesDefect.Groups.FirstOrDefault(q => q.DFTG_CODE == (action.Data?.ToString() ?? "")));
            }
            catch (Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}