using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using System.Threading.Tasks;
using XYY.Data.Model.Standard.Tracking._17;
using XYY.Data.Model.Standard.Tracking;
using XYY.Core.Standard.Mvc;
using XYY.TaskTrack.Standard;
using Microsoft.AspNetCore.Authorization;

namespace XYY.API.Tracking.Controllers
{

    [AllowAnonymous]
    [Route("api/[controller]")]
    [ApiController]
    public class _17TrackingWebhookController : ControllerBase
    {
        private IMQManager _MQManager;

        public _17TrackingWebhookController(IMQManager mQManager)
        {
            _MQManager = mQManager;
        }
        [HttpPost]
        public async Task<ApiJsonModel> Post([FromBody] _17TrackingWebhook hook)
        {
            //写入到MQ中
            var data = hook.Copy<_17TrackingMQData>();
            data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(hook.Data);
            //await _MQManager.Publish(data);
            return ApiJsonModel.OK();
        }
    }
}
