Example #1
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc(options =>
     {
         // 注册全局异常过滤器
         options.Filters.Add <GlobalExceptionAttribute>();
     });
     services.AddMvc();
     services.AddSingleton(new WsHandler());
     services.AddSingleton(OrderInfoHandler.GetHandler());
     // 注册redis连接
     services.AddSingleton <IConnectionMultiplexer>(ConnectionMultiplexer.Connect(Configuration.GetConnectionString("RedisConn")));
 }
Example #2
0
        public IActionResult Get(int id, [FromServices] OrderInfoHandler handler)
        {
            var result = new JsonData {
                Success = true
            };
            var list = handler.Get(id);

            if (list == null || list.Count == 0)
            {
                result.Msg = "没有新订单";
            }
            else
            {
                result.Data = list.Select(a => a.Content).ToList();
            }
            return(Json(result));
        }
Example #3
0
 public IActionResult Post([FromBody] PostNewOrderData data, [FromServices] OrderInfoHandler handler)
 {
     handler.Add(data);
     return(Ok("通知成功"));
 }