ACSController.cs 1.99 KB
using System;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using WebApp;
using WebRepository;

namespace WebMvc.Areas.Api.Controllers
{
    /// <summary>
    /// RCS回调接口
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ACSController : ControllerBase
    {
        private readonly AcsApiApp _app;

        /// <summary>
        /// 控制器构造函数
        /// </summary>
        /// <param name="unitWork">注入工作单元</param>
        /// <param name="auth">注入授权信息</param>
        /// <param name="context">EF上下文</param>
        public ACSController(IUnitWork unitWork, IAuth auth, BaseDbContext context)
        {
            _app = new AcsApiApp(unitWork, auth, context);
        }

        /// <summary>
        /// 任务状态刷新
        /// </summary>
        /// <param name="taskRefreshModel"></param>
        /// <returns></returns>
        [HttpPost("TaskRefresh")]
        public string TaskRefresh(TaskRefreshModel taskRefreshModel)
        {
            var resp = new Response();

            try
            {
                _app.TaskRefresh(taskRefreshModel);
            }
            catch (Exception e)
            {
                resp.Code = 500;
                resp.Message = e.Message;
            }

            return JsonHelper.Instance.Serialize(resp);
        }

        /// <summary>
        /// 对接/自动任务返回
        /// </summary>
        /// <param name="toWebTaskReturnModel"></param>
        /// <returns></returns>
        [HttpPost("ToWebTaskReturn")]
        public string ToWebTaskReturn(ToWebTaskReturnModel toWebTaskReturnModel)
        {
            var resp = new Response();

            try
            {
                _app.ToWebTaskReturn(toWebTaskReturnModel);
            }
            catch (Exception e)
            {
                resp.Code = 500;
                resp.Message = e.Message;
            }

            return JsonHelper.Instance.Serialize(resp);
        }
    }
}