ComplianceServer/oldcode/WX.CRM.DataSynApi/Controllers/DataSyncController.cs

48 lines
1.4 KiB
C#

using Swashbuckle.Swagger.Annotations;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using WX.CRM.Common;
using WX.CRM.DataSynApi.Application;
namespace WX.CRM.DataSynApi.Controllers
{
/// <summary>
/// 同步数据接口
/// </summary>
public class DataSyncController : ApiController
{
private readonly SyncPushService _services = new SyncPushService();
/// <summary>
/// 提交数据
/// </summary>
/// <param name="dto"></param>
[SwaggerOperation("Create")]
[SwaggerResponse(HttpStatusCode.Created)]
public HttpResponseMessage Post([FromBody] SYNC_PUSH_DTO dto)
{
try
{
_services.AddPushSync(dto);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(new { result = true }.ToJson(), Encoding.UTF8, "text/json")
};
}
catch (Exception ex)
{
LogHelper.Error("错误对象:" + dto.ToJson());
LogHelper.Error(ex.ToString());
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(new { result = false }.ToJson(), Encoding.UTF8, "text/json")
};
}
}
}
}